-- cgit v1.2.3 From 31fc967a88f527319309623d62177ec0b5304ceb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 28 Apr 1993 19:04:17 +0000 Subject: Initial revision --- mkbootfs/mkbootfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 mkbootfs/mkbootfs.c diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c new file mode 100644 index 00000000..22c8f647 --- /dev/null +++ b/mkbootfs/mkbootfs.c @@ -0,0 +1,43 @@ +/* Make a bootstrap filesystem from a filesystem and an exec server + Copyright (C) 1993 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +/* The job is to write a .o corresponding to the exec server. This + .o contains the following symbols: + + _execserver_text_size + _execserver_data_size + _execserver_bss_size + _execserver_text + _execserver_data + _execserver_start + + The .o will then be linked along with the rest of the filesystem, which + will spawn an execserver with the right bits when it starts. */ + +/* This is non-general, and only intended for the i386 Mach 3.0 with its + own weird format. */ + +/* Usage: mkbootfs execserver */ + +main (int argc, char **argv) +{ + if (argc != + -- cgit v1.2.3 From c4bbb0b01bbfd4c28ba8e4e2ae173cb2f089a43b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 28 Apr 1993 19:20:23 +0000 Subject: Formerly mkbootfs.c.~2~ --- mkbootfs/mkbootfs.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index 22c8f647..75e1523e 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -39,5 +39,19 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ main (int argc, char **argv) { - if (argc != - + int execserver; + + if (argc != 2) + { + fprintf (stderr, "Usage: %s execserver\n", argv[0]); + exit (1); + } + + execserver = open (argv[1]); + if (execserver == -1) + { + perror (argv[1]); + exit (1); + } + + -- cgit v1.2.3 From 3a353a37f816d77850be19c6913f409e2898d0f8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 30 Apr 1993 01:07:25 +0000 Subject: Formerly mkbootfs.c.~3~ --- mkbootfs/mkbootfs.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index 75e1523e..42c7e2bd 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -30,28 +30,113 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ _execserver_start The .o will then be linked along with the rest of the filesystem, which - will spawn an execserver with the right bits when it starts. */ + will spawn an execserver with the right bits when it starts. -/* This is non-general, and only intended for the i386 Mach 3.0 with its - own weird format. */ + The text should be loaded at 0x10000 and the data at + 0x10000 + _execserver_text_size and the bss cleared at + 0x10000 + _execserver_text_size + _execserver_data_size. + */ -/* Usage: mkbootfs execserver */ +/* This is non-general, and only intended for the i386 Mach 3.0 with + its own weird format. It expects the header files to be from such a + Mach system as CMU sets them up. */ + +/* Usage: mkbootfs execserver newdoto */ main (int argc, char **argv) { - int execserver; + int execserver, newdoto; + struct exec a, newa; + unsigned long foo; + void *buf; + struct nlist n; - if (argc != 2) + if (argc != 3) { - fprintf (stderr, "Usage: %s execserver\n", argv[0]); + fprintf (stderr, "Usage: %s execserver newdoto\n", argv[0]); exit (1); } - execserver = open (argv[1]); + execserver = open (argv[1], O_RDONLY); if (execserver == -1) { perror (argv[1]); exit (1); } + newdoto = open (argv[2], O_WRONLY | O_CREAT, 0666); + if (newdoto == -1) + { + perror (argv[2]); + exit (1); + } + + read (execserver, &a, sizeof (struct exec)); + + /* Write the new data segment to the new file. */ + lseek (newdoto, sizeof (struct exec), L_SET); + + /* First, _execserver_text_size */ + foo = a.a_text + sizeof (struct exec); + write (newdoto, &foo, sizeof foo); + + /* Next, _execserver_data_size */ + write (newdoto, &a.a_data, sizeof a.a_data); + + /* Next, _execserver_bss_size */ + write (newdoto, &a.a_bss, sizeof a.a_bss); + + /* Next, _execserver_text */ + buf = malloc (a.a_text + sizeof (struct exec)); + lseek (execserver, 0, L_SET); + read (execserver, buf, a.a_text + sizeof (struct exec)); + write (newdoto, buf, a.a_text + sizeof (struct exec)); + free (buf); + + /* Next, _execserver_data */ + buf = malloc (a.a_data); + read (execserver, buf, a.a_data); + write (newdoto, buf, a.a_data); + free (bof); + + /* Finally, _execserver_start */ + write (newdoto, &a.a_entry, sizeof a.a_entry); + + /* We have no relocation information */ + + /* Now, write the symbol table */ + n.n_un.n_strx = 50; + n.n_type = N_DATA | N_EXT; + n.n_value = 0; + + /* First, _execserver_text_size */ + write (newdoto, &n, sizeof (n)); + n.n_value += sizeof (foo); + + /* Now, _execserver_data_size */ + n.n_un.n_strx += 50; + write (newdoto, &n, sizeof (n)); + n.n_value += sizeof (foo); + + /* Now, _execserver_bss_size */ + n.n_un.n_strx += 50; + write (newdoto, &n, sizeof (n)); + n.n_value += sizeof (foo); + + /* Now, _execserver_text */ + n.n_un.n_strx += 50; + write (newdoto, &n, sizeof (n)); + n.n_value += a.a_text + sizeof (struct exec); + + /* Now, _execserver_data */ + n.n_un.n_strx += 50; + write (newdoto, &n, sizeof (n)); + n.n_value += a.a_data; + + /* Now, _execserver_start */ + n.n_un.n_strx += 50; + write (newdoto, &n, sizeof (n)); + n.n_value += sizeof (foo); + + /* Now, we have to write out the string table */ -- cgit v1.2.3 From 1d9a48eb71bea19452d25d9f9d9ca46a76bfd872 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 May 1993 21:35:27 +0000 Subject: Formerly mkbootfs.c.~4~ --- mkbootfs/mkbootfs.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index 42c7e2bd..e2599da8 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -41,6 +41,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ its own weird format. It expects the header files to be from such a Mach system as CMU sets them up. */ +#include +#include +#include + /* Usage: mkbootfs execserver newdoto */ main (int argc, char **argv) @@ -50,7 +54,7 @@ main (int argc, char **argv) unsigned long foo; void *buf; struct nlist n; - + if (argc != 3) { fprintf (stderr, "Usage: %s execserver newdoto\n", argv[0]); @@ -97,7 +101,7 @@ main (int argc, char **argv) buf = malloc (a.a_data); read (execserver, buf, a.a_data); write (newdoto, buf, a.a_data); - free (bof); + free (buf); /* Finally, _execserver_start */ write (newdoto, &a.a_entry, sizeof a.a_entry); @@ -139,4 +143,39 @@ main (int argc, char **argv) n.n_value += sizeof (foo); /* Now, we have to write out the string table */ +#define DOSTRING(x) \ + write (newdoto, x, strlen (x) + 1); \ + lseek (newdoto, 50 - strlen (x) - 1, L_INCR); + + foo = 350; /* six strings and the beginning */ + write (newdoto, &foo, sizeof foo); + lseek (newdoto, 50 - sizeof foo, L_INCR); + + DOSTRING ("_execserver_text_size"); + DOSTRING ("_execserver_data_size"); + DOSTRING ("_execserver_bss_size"); + DOSTRING ("_execserver_text"); + DOSTRING ("_execserver_data"); + DOSTRING ("_execserver_start"); + + lseek (newdoto, -1, L_INCR); + foo = 0; + write (newdoto, &foo, 1); + + /* Now write out the header */ + a.a_data = + (4 * sizeof (int) + a.a_text + a.a_data + sizeof (struct exec)); + a.a_text = 0; + a.a_bss = 0; + a.a_syms = 6 * sizeof n; + a.a_entry = 0; + a.a_trsize = 0; + a.a_drsize = 0; + lseek (newdoto, 0, L_SET); + write (newdoto, &a, sizeof a); + + exit (0); +} + + -- cgit v1.2.3 From d3c7bfde1946b573203bfc360deb886c56e34891 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 20 Sep 1993 16:50:24 +0000 Subject: Formerly mkbootfs.c.~5~ --- mkbootfs/mkbootfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index e2599da8..cd4cac05 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -68,7 +68,7 @@ main (int argc, char **argv) exit (1); } - newdoto = open (argv[2], O_WRONLY | O_CREAT, 0666); + newdoto = open (argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0666); if (newdoto == -1) { perror (argv[2]); -- cgit v1.2.3 From a9812b88e4ac22450fb213d4beef7e49f3a9d191 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 7 Dec 1993 03:23:46 +0000 Subject: Initial revision --- mkbootfs/Makefile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mkbootfs/Makefile diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile new file mode 100644 index 00000000..1fb23af8 --- /dev/null +++ b/mkbootfs/Makefile @@ -0,0 +1,20 @@ +# +# Copyright (C) 1993 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 +# published by the Free Software Foundation; either version 2, 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. + +dir := mkbootfs +include ../Makeconf +DIST_FILES = mkbootfs.c Makefile -- cgit v1.2.3 From 9096d4c90d05d868da95a1c7e5d5a1f49028c8d3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 22 Jan 1994 01:42:47 +0000 Subject: Formerly Makefile.~2~ --- mkbootfs/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index 1fb23af8..af663942 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1993 Free Software Foundation +# Copyright (C) 1993, 1994 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 @@ -18,3 +18,6 @@ dir := mkbootfs include ../Makeconf DIST_FILES = mkbootfs.c Makefile +all: mkbootfs +mkbootfs: mkbootfs.c + $(CC) mkbootfs.c -o mkbootfs -- cgit v1.2.3 From 8f079ded6727e0b05cc83795af8509007e8700be Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 22 Jan 1994 01:43:09 +0000 Subject: Formerly mkbootfs.c.~6~ --- mkbootfs/mkbootfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index cd4cac05..19dd8c11 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -1,5 +1,5 @@ /* Make a bootstrap filesystem from a filesystem and an exec server - Copyright (C) 1993 Free Software Foundation + Copyright (C) 1993, 1994 Free Software Foundation This file is part of the GNU Hurd. @@ -163,6 +163,7 @@ main (int argc, char **argv) write (newdoto, &foo, 1); /* Now write out the header */ + a.a_magic = OMAGIC; a.a_data = (4 * sizeof (int) + a.a_text + a.a_data + sizeof (struct exec)); a.a_text = 0; -- cgit v1.2.3 From 38b825eb63efa534965edc4df26aaf391b40ebb6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Feb 1994 19:48:55 +0000 Subject: Initial revision --- ufs/hyper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ufs/hyper.c diff --git a/ufs/hyper.c b/ufs/hyper.c new file mode 100644 index 00000000..9f5cae8d --- /dev/null +++ b/ufs/hyper.c @@ -0,0 +1,43 @@ +/* Fetching and storing the hypermetadata (superblock and cg summary info). + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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. */ + + +void +get_hypermetadata (void) +{ + error_t err; + + err = dev_read_sync (SBLOCK, (vm_address_t *)&sblock, SBSIZE); + assert (!err); + + /* If this is an old filesystem, then we have some more + work to do; some crucial constants might not be set; we + are therefore forced to set them here. */ + if (sblock->fs_npsect < sblock->fs_nsect) + sblock->fs_npsect = sblock->fs_nsect; + if (sblock->fs_interleave < 1) + sblock->fs_interleave = 1; + if (sblock->fs_postblformat == FS_42POSTBLFMT) + sblock->fs_nrpos = 8; + + err = dev_read_sync (fsbtodb (sblock->fs_csaddr), (vm_address_t *) &csum, + sblock->fs_fsize * howmany (sblock->fs_cssize, + sblock->fs_fsize)); + assert (!err); +} + + -- cgit v1.2.3 From 6a0c7935a3dcc4e244cc696bb5fe712cd5b80e39 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Feb 1994 19:53:41 +0000 Subject: Formerly hyper.c.~2~ --- ufs/hyper.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 9f5cae8d..2793985e 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -40,4 +40,31 @@ get_hypermetadata (void) assert (!err); } - +/* Write the superblock and cg summary info to disk. If WAIT is set, + we must wait for everything to hit the disk; if CLEAN is set, then + mark the clean bit. */ +void +diskfs_set_hypermetadata (int wait, int clean) +{ + error_t (*writefn) (daddr_t, vm_address_t, vm_size_t); + writefn = (wait ? dev_write_sync : dev_write); + + (*writefn)(fsbtodb (sblock->fs_csaddr), (vm_address_t) csum, + sblock->fs_fsize * howmany (sblock->fs_cssize, + sblock->fs_fssize)); + + if (clean) + sblock->fs_clean = 1; + if (sblock->fs_postblformat == FS_42POSTBLFMT) + { + char sblockcopy[SBSIZE]; + bcopy (sblock, sblockcopy, SBSIZE); + ((struct fs *)sblockcopy)->fs_nrpos = -1; + (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); + } + else + (*writefn) (SBLOCK, (vm_address_t) sblock, SBSIZE); + sblock->fs_clean = 0; +} + + -- cgit v1.2.3 From 8cb8d253067c9d0591ee98e387f0fd8cd27e8ca2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Feb 1994 19:58:40 +0000 Subject: Initial revision --- ufs/consts.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ufs/consts.c diff --git a/ufs/consts.c b/ufs/consts.c new file mode 100644 index 00000000..dd4d03de --- /dev/null +++ b/ufs/consts.c @@ -0,0 +1,25 @@ +/* Various constants wanted by the diskfs library + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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. */ + +size_t diskfs_dirstat_size = sizeof (struct dirstat); +int diskfs_link_max = LINK_MAX; +int diskfs_maxsymlinks = 8; +int diskfs_shortcut_symlink = 1; +int diskfs_shortcut_chrdev = 1; +int diskfs_shortcut_blkdev = 1; +int diskfs_shortcut_fifo = 1; +int diskfs_shortcut_ifsock = 1; -- cgit v1.2.3 From 085fc9bbf1ebf12a8fdf554df4625bd985e65ad6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 9 Feb 1994 19:40:25 +0000 Subject: Formerly consts.c.~2~ --- ufs/consts.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/consts.c b/ufs/consts.c index dd4d03de..54aa82de 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -size_t diskfs_dirstat_size = sizeof (struct dirstat); int diskfs_link_max = LINK_MAX; int diskfs_maxsymlinks = 8; int diskfs_shortcut_symlink = 1; -- cgit v1.2.3 From 3d8feee8b3c3180e4f98f351e7014d79d8403847 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 18:38:52 +0000 Subject: Initial revision --- ufs/devio.c | 74 +++++++++++++++++++++++ ufs/subr.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ufs/tables.c | 122 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 383 insertions(+) create mode 100644 ufs/devio.c create mode 100644 ufs/subr.c create mode 100644 ufs/tables.c diff --git a/ufs/devio.c b/ufs/devio.c new file mode 100644 index 00000000..957f2504 --- /dev/null +++ b/ufs/devio.c @@ -0,0 +1,74 @@ +/* Device input and output + Copyright (C) 1992, 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "ufs.h" +#include +#include +#include +#include + +/* Write disk block ADDR with DATA of LEN bytes, waiting for completion. */ +error_t +dev_write_sync (daddr_t addr, + vm_address_t data, + long len) +{ + int foo; + assert (!readonly); + if (device_write (ufs_device, 0, addr, (io_buf_ptr_t) data, len, &foo) + || foo != len) + return EIO; + return 0; +} + +/* Write diskblock ADDR with DATA of LEN bytes; don't bother waiting + for completion. */ +error_t +dev_write (daddr_t addr, + vm_address_t data, + long len) +{ + int foo; + assert (!readonly); + if (device_write_request (ufs_device, MACH_PORT_NULL, 0, addr, + (io_buf_ptr_t) data, len, &foo) + || foo != len) + return EIO; + return 0; +} + +static int deverr; + +/* Read disk block ADDR; put the address of the data in DATA; read LEN + bytes. Always *DATA should be a full page no matter what. */ +error_t +dev_read_sync (daddr_t addr, + vm_address_t *data, + long len) +{ + int foo; + deverr = device_read (ufs_device, 0, addr, len, (io_buf_ptr_t *)data, + (u_int *)&foo); + if (deverr || foo != len) + return EIO; + return 0; +} + diff --git a/ufs/subr.c b/ufs/subr.c new file mode 100644 index 00000000..b61b09d6 --- /dev/null +++ b/ufs/subr.c @@ -0,0 +1,187 @@ +/* Miscellaneous map manipulation routines + Copyright (C) 1991, 1992, 1994 Free Software Foundation + +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. */ + +/* Slightly modified from UCB by Michael I. Bushnell. */ + +/* + * Copyright (c) 1982, 1986, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 + */ + + +#include + +extern int around[9]; +extern int inside[9]; +extern u_char *fragtbl[]; + +/* + * Update the frsum fields to reflect addition or deletion + * of some frags. + */ +void +fragacct(int fragmap, + long fraglist[], + int cnt) +{ + int inblk; + int field, subfield; + int siz, pos; + + inblk = (int)(fragtbl[sblock->fs_frag][fragmap]) << 1; + fragmap <<= 1; + for (siz = 1; siz < sblock->fs_frag; siz++) { + if ((inblk & (1 << (siz + (sblock->fs_frag % NBBY)))) == 0) + continue; + field = around[siz]; + subfield = inside[siz]; + for (pos = siz; pos <= sblock->fs_frag; pos++) { + if ((fragmap & field) == subfield) { + fraglist[siz] += cnt; + pos += siz; + field <<= siz; + subfield <<= siz; + } + field <<= 1; + subfield <<= 1; + } + } +} + +/* + * block operations + * + * check if a block is available + */ +int +isblock(u_char *cp, + daddr_t h) +{ + u_char mask; + + switch ((int)sblock->fs_frag) { + case 8: + return (cp[h] == 0xff); + case 4: + mask = 0x0f << ((h & 0x1) << 2); + return ((cp[h >> 1] & mask) == mask); + case 2: + mask = 0x03 << ((h & 0x3) << 1); + return ((cp[h >> 2] & mask) == mask); + case 1: + mask = 0x01 << (h & 0x7); + return ((cp[h >> 3] & mask) == mask); + default: + assert (0); + } +} + +/* + * take a block out of the map + */ +void +clrblock(u_char *cp, + daddr_t h) +{ + + switch ((int)sblock->fs_frag) { + case 8: + cp[h] = 0; + return; + case 4: + cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2)); + return; + case 2: + cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1)); + return; + case 1: + cp[h >> 3] &= ~(0x01 << (h & 0x7)); + return; + default: + assert (0); + } +} + +/* + * put a block into the map + */ +void +setblock(u_char *cp, + daddr_t h) +{ + switch ((int)sblock->fs_frag) { + + case 8: + cp[h] = 0xff; + return; + case 4: + cp[h >> 1] |= (0x0f << ((h & 0x1) << 2)); + return; + case 2: + cp[h >> 2] |= (0x03 << ((h & 0x3) << 1)); + return; + case 1: + cp[h >> 3] |= (0x01 << (h & 0x7)); + return; + default: + assert (0); + } +} + +int +skpc(u_char mask, + u_int size, + u_char *cp) +{ + u_char *end = &cp[size]; + + while (cp < end && *cp == mask) + cp++; + return (end - cp); +} + +int +scanc(u_int size, + u_char *cp, + u_char table[], + u_char mask) +{ + register u_char *end = &cp[size]; + + while (cp < end && (table[*cp] & mask) == 0) + cp++; + return (end - cp); +} diff --git a/ufs/tables.c b/ufs/tables.c new file mode 100644 index 00000000..42badaed --- /dev/null +++ b/ufs/tables.c @@ -0,0 +1,122 @@ +/* Tables for fast computation */ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)ufs_tables.c 7.4 (Berkeley) 6/28/90 + */ + +/* + * Bit patterns for identifying fragments in the block map + * used as ((map & around) == inside) + */ +int around[9] = { + 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff +}; +int inside[9] = { + 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe +}; + +/* + * Given a block map bit pattern, the frag tables tell whether a + * particular size fragment is available. + * + * used as: + * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { + * at least one fragment of the indicated size is available + * } + * + * These tables are used by the scanc instruction on the VAX to + * quickly find an appropriate fragment. + */ +u_char fragtbl124[256] = { + 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e, + 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, + 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e, + 0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae, + 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, + 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, + 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, + 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, + 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, + 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, + 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, + 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, + 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, + 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, + 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, + 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce, + 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a, +}; + +u_char fragtbl8[256] = { + 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, + 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, + 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, + 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, + 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, + 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, + 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, + 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, + 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, + 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, + 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21, + 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, + 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, + 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12, + 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, + 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c, + 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c, + 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80, +}; + +/* + * The actual fragtbl array. + */ +u_char *fragtbl[MAXFRAG + 1] = { + 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, +}; -- cgit v1.2.3 From 73b5d5fec8e66debd74b963310dc635b9e995e14 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 18:39:04 +0000 Subject: Formerly devio.c.~2~ --- ufs/devio.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ufs/devio.c b/ufs/devio.c index 957f2504..81423d73 100644 --- a/ufs/devio.c +++ b/ufs/devio.c @@ -19,12 +19,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Michael I. Bushnell. */ -#include "ufs.h" -#include -#include -#include -#include - /* Write disk block ADDR with DATA of LEN bytes, waiting for completion. */ error_t dev_write_sync (daddr_t addr, -- cgit v1.2.3 From e78eb00a4ec04c666c505cf674d58b1f492b1ac6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 19:19:12 +0000 Subject: Initial revision --- ufs/Makefile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ufs/Makefile diff --git a/ufs/Makefile b/ufs/Makefile new file mode 100644 index 00000000..11b82256 --- /dev/null +++ b/ufs/Makefile @@ -0,0 +1,21 @@ +# +# Copyright (C) 1994 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 +# published by the Free Software Foundation; either version 2, 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. + +dir := ufs + +include ../Makeconf + -- cgit v1.2.3 From 5c0128e3a3c729bc4d333967575ab95503d142ea Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 20:28:20 +0000 Subject: Initial revision --- ufs/dinode.h | 122 ++++++++++++++++ ufs/fs.h | 454 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 576 insertions(+) create mode 100644 ufs/dinode.h create mode 100644 ufs/fs.h diff --git a/ufs/dinode.h b/ufs/dinode.h new file mode 100644 index 00000000..dfde2050 --- /dev/null +++ b/ufs/dinode.h @@ -0,0 +1,122 @@ +/* Format of an inode on disk + Copyright (C) 1991, 1993 Free Software Foundation + +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. */ + +/* Modified from UCB by Michael I. Bushnell. */ + +/* + * Copyright (c) 1982, 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)dinode.h 7.9 (Berkeley) 6/28/90 + */ + +/* + * This structure defines the on-disk format of an inode. + */ + +#define NDADDR 12 /* direct addresses in inode */ +#define NIADDR 3 /* indirect addresses in inode */ + +/* Indexes into di_ib */ +#define INDIR_SINGLE 0 +#define INDIR_DOUBLE 1 +#define INDIR_TRIPLE 2 /* NOT SUPPORTED */ + +struct dinode { + u_short di_model; /* 0: mode and type of file (low bits) */ + nlink_t di_nlink; /* 2: number of links to file */ + u_short di_uidl; /* 4: owner's user id (low bits) */ + u_short di_gidl; /* 6: owner's group id (low bits) */ + u_quad di_qsize; /* 8: number of bytes in file */ + time_t di_atime; /* 16: time last accessed */ + long di_atusec; + time_t di_mtime; /* 24: time last modified */ + long di_mtusec; + time_t di_ctime; /* 32: last time inode changed */ + long di_ctusec; + daddr_t di_db[NDADDR]; /* 40: disk block addresses */ + daddr_t di_ib[NIADDR]; /* 88: indirect blocks */ + long di_flags; /* 100: status, currently unused */ + long di_blocks; /* 104: blocks actually held */ + long di_gen; /* 108: generation number */ + long di_trans; /* 112: filesystem tranlator */ + uid_t di_author; /* 116: author id */ + u_short di_uidh; /* 120: user id (high bits) */ + u_short di_gidh; /* 122: group id (high bits) */ + u_short di_modeh; /* 124: mode (high bits) */ + short di_spare; /* 126: reserved, currently unused */ +}; + +#define DI_UID(di) ((di)->di_uidl | ((int)(di)->di_uidh << 16)) +#define DI_GID(di) ((di)->di_gidl | ((int)(di)->di_gidh << 16)) +#define DI_MODE(di) ((di)->di_model | ((int)(di)->di_modeh << 16)) + +#define LINK_MAX 32767 /* limited by width of nlink_t == 16 bits */ + +#if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */ +#define di_size di_qsize.val[0] +#else /* BYTE_ORDER == BIG_ENDIAN */ +#define di_size di_qsize.val[1] +#endif +#define di_rdev di_db[0] + +/* file modes -- these are known to match appropriate values in gnu/stat.h */ +#define IFMT 000000170000 /* type of file */ +#define IFIFO 000000010000 /* named pipe (fifo) */ +#define IFCHR 000000020000 /* character special */ +#define IFDIR 000000040000 /* directory */ +#define IFBLK 000000060000 /* block special */ +#define IFREG 000000100000 /* regular */ +#define IFLNK 000000120000 /* symbolic link */ +#define IFSOCK 000000140000 /* socket */ + +#define ISPEC 000000607000 /* special user-changeable bits */ +#define INOCACHE 000000400000 /* don't cache contents */ +#define IUSEUNK 000000200000 /* use IUNK in pref to IKNOWN */ +#define ISUID 000000004000 /* set user id on execution */ +#define ISGID 000000002000 /* set group id on execution */ +#define ISVTX 000000001000 /* caching preference / append only dir */ + +/* masks for various sets of permissions: */ +#define IOWNER 000000000700 /* owner of file */ +#define IGROUP 000000000070 /* group of file */ +#define IKNOWN 000000000007 /* anyone who possesses a uid */ +#define IUNKNOWN 000007000000 /* anyone who doesn't possess a uid */ + +#define ISPARE 037770000000 /* unused (yet) */ + +#define IREAD 0400 /* read, write, execute permissions */ +#define IWRITE 0200 +#define IEXEC 0100 + diff --git a/ufs/fs.h b/ufs/fs.h new file mode 100644 index 00000000..c1dd5681 --- /dev/null +++ b/ufs/fs.h @@ -0,0 +1,454 @@ +/* Format of a filesystem on disk (superblock and cylinder groups) + Copyright (C) 1991, 1993 Free Software Foundation + +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. */ + +/* Modified from UCB by Michael I. Bushnell. */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED 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.10 (Berkeley) 6/28/90 + */ + +/* + * 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 +#define MAXFRAG 8 + +/* + * 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 { + long cs_ndir; /* number of directories */ + long cs_nbfree; /* number of free blocks */ + long cs_nifree; /* number of free inodes */ + long cs_nffree; /* number of free frags */ +}; + +/* + * Super block for a file system. + */ +#define FS_MAGIC 0x011954 +#define FSOKAY 0x7c269d38 +struct fs +{ + struct fs *fs_link; /* linked list of file systems */ + struct fs *fs_rlink; /* used for incore super blocks */ + 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 */ + long fs_cgoffset; /* cylinder group offset in cylinder */ + long fs_cgmask; /* used to calc mod fs_ntrak */ + long fs_time; /* last time written */ + long fs_size; /* number of blocks in fs */ + long fs_dsize; /* number of data blocks in fs */ + long fs_ncg; /* number of cylinder groups */ + long fs_bsize; /* size of basic blocks in fs */ + long fs_fsize; /* size of frag blocks in fs */ + long fs_frag; /* number of frags in a block in fs */ +/* these are configuration parameters */ + long fs_minfree; /* minimum percentage of free blocks */ + long fs_rotdelay; /* num of ms for optimal next block */ + long fs_rps; /* disk revolutions per second */ +/* these fields can be computed from the others */ + long fs_bmask; /* ``blkoff'' calc of blk offsets */ + long fs_fmask; /* ``fragoff'' calc of frag offsets */ + long fs_bshift; /* ``lblkno'' calc of logical blkno */ + long fs_fshift; /* ``numfrags'' calc number of frags */ +/* these are configuration parameters */ + long fs_maxcontig; /* max number of contiguous blks */ + long fs_maxbpg; /* max number of blks per cyl group */ +/* these fields can be computed from the others */ + long fs_fragshift; /* block to frag shift */ + long fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + long fs_sbsize; /* actual size of super block */ + long fs_csmask; /* csum block offset */ + long fs_csshift; /* csum block number */ + long fs_nindir; /* value of NINDIR */ + long fs_inopb; /* value of INOPB */ + long fs_nspf; /* value of NSPF */ +/* yet another configuration parameter */ + long fs_optim; /* optimization preference, see below */ +/* these fields are derived from the hardware */ + long fs_npsect; /* # sectors/track including spares */ + long fs_interleave; /* hardware sector interleave */ + long fs_trackskew; /* sector 0 skew, per track */ + long fs_headswitch; /* head switch time, usec */ + long 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 */ + long fs_cssize; /* size of cyl grp summary area */ + long fs_cgsize; /* cylinder group size */ +/* these fields are derived from the hardware */ + long fs_ntrak; /* tracks per cylinder */ + long fs_nsect; /* sectors per track */ + long fs_spc; /* sectors per cylinder */ +/* this comes from the disk driver partitioning */ + long fs_ncyl; /* cylinders in file system */ +/* these fields can be computed from the others */ + long fs_cpg; /* cylinders per group */ + long fs_ipg; /* inodes per group */ + long 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 */ + long fs_cgrotor; /* last cg searched */ + struct csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */ + long fs_cpc; /* cyl per cycle in postbl */ + short fs_opostbl[16][8]; /* old rotation block list head */ + long fs_sparecon[55]; /* reserved for future constants */ + long fs_state; /* validate fs_clean field */ + quad fs_qbmask; /* ~fs_bmask - for use with quad size */ + quad fs_qfmask; /* ~fs_fmask - for use with quad size */ + long fs_postblformat; /* format of positional layout tables */ + long fs_nrpos; /* number of rotaional positions */ + long fs_postbloff; /* (short) rotation block list head */ + long fs_rotbloff; /* (u_char) blocks for each rotation */ + long fs_magic; /* magic number */ + unsigned 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(cylno) \ + ((sblock->fs_postblformat == FS_42POSTBLFMT) \ + ? (sblock->fs_opostbl[cylno]) \ + : ((short *)((char *)sblock + sblock->fs_postbloff) \ + + (cylno) * sblock->fs_nrpos)) +#define fs_rotbl \ + ((sblock->fs_postblformat == FS_42POSTBLFMT) \ + ? (sblock->fs_space) \ + : ((unsigned char *)((char *)sblock + sblock->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(indx) \ + fs_csp[(indx) >> sblock->fs_csshift][(indx) & ~sblock->fs_csmask] + +/* + * Cylinder group block for a file system. + */ +#define CG_MAGIC 0x090255 +struct cg { + struct cg *cg_link; /* linked list of cyl groups */ + long cg_magic; /* magic number */ + long cg_time; /* time last written */ + long 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 */ + long cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + long cg_rotor; /* position of last used block */ + long cg_frotor; /* position of last used frag */ + long cg_irotor; /* position of last used inode */ + long cg_frsum[MAXFRAG]; /* counts of available frags */ + long cg_btotoff; /* (long) block totals per cylinder */ + long cg_boff; /* (short) free block positions */ + long cg_iusedoff; /* (char) used inode map */ + long cg_freeoff; /* (u_char) free block map */ + long cg_nextfreeoff; /* (u_char) next available space */ + long cg_sparecon[16]; /* reserved for future use */ + unsigned 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) \ + : ((long *)((char *)(cgp) + (cgp)->cg_btotoff))) +#define cg_blks(cgp, cylno) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_b[cylno]) \ + : ((short *)((char *)(cgp) + (cgp)->cg_boff) + (cylno) * sblock->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) \ + : ((unsigned 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 { + struct ocg *cg_link; /* linked list of cyl groups */ + struct ocg *cg_rlink; /* used for incore cyl groups */ + long cg_time; /* time last written */ + long 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 */ + long cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + long cg_rotor; /* position of last used block */ + long cg_frotor; /* position of last used frag */ + long cg_irotor; /* position of last used inode */ + long cg_frsum[8]; /* counts of available frags */ + long cg_btot[32]; /* block totals per cylinder */ + short cg_b[32][8]; /* positions of free blocks */ + char cg_iused[256]; /* used inode map */ + long cg_magic; /* magic number */ + unsigned 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(b) ((b) << sblock->fs_fsbtodb) +#define dbtofsb(b) ((b) >> sblock->fs_fsbtodb) + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc file system addresses of cylinder group data structures. + */ +#define cgbase(c) ((daddr_t)(sblock->fs_fpg * (c))) +#define cgstart(c) \ + (cgbase(c) + sblock->fs_cgoffset * ((c) & ~(sblock->fs_cgmask))) +#define cgsblock(c) (cgstart(c) + sblock->fs_sblkno) /* super blk */ +#define cgtod(c) (cgstart(c) + sblock->fs_cblkno) /* cg block */ +#define cgimin(c) (cgstart(c) + sblock->fs_iblkno) /* inode blk */ +#define cgdmin(c) (cgstart(c) + sblock->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(x) ((x) % INOPB) +#define itog(x) ((x) / sblock->fs_ipg) +#define itod(x) \ + ((daddr_t)(cgimin(itog(x)) + \ + (blkstofrags((((x) % sblock->fs_ipg) / INOPB))))) + +/* + * Give cylinder group number for a file system block. + * Give cylinder group block number for a file system block. + */ +#define dtog(d) ((d) / sblock->fs_fpg) +#define dtogd(d) ((d) % sblock->fs_fpg) + +/* + * Extract the bits for a block from a map. + * Compute the cylinder and rotational position of a cyl block addr. + */ +#define blkmap(map, loc) \ + (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - sblock->fs_frag))) +#define cbtocylno(bno) \ + ((bno) * NSPF / sblock->fs_spc) +#define cbtorpos(bno) \ + (((bno) * NSPF % sblock->fs_spc / sblock->fs_nsect * sblock->fs_trackskew + \ + (bno) * NSPF % sblock->fs_spc % sblock->fs_nsect * sblock->fs_interleave) % \ + sblock->fs_nsect * sblock->fs_nrpos / sblock->fs_npsect) + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ +#define blkoff(loc) /* calculates (loc % fs->fs_bsize) */ \ + ((loc) & ~sblock->fs_bmask) +#define fragoff(loc) /* calculates (loc % fs->fs_fsize) */ \ + ((loc) & ~sblock->fs_fmask) +#define lblktosize(blk) /* calculates (blk * fs->fs_bsize) */ \ + ((blk) << sblock->fs_bshift) +#define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \ + ((loc) >> sblock->fs_bshift) +#define numfrags(loc) /* calculates (loc / fs->fs_fsize) */ \ + ((loc) >> sblock->fs_fshift) +#define blkroundup(size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + sblock->fs_bsize - 1) & sblock->fs_bmask) +#define fragroundup(size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + sblock->fs_fsize - 1) & sblock->fs_fmask) +#define fragstoblks(frags) /* calculates (frags / fs->fs_frag) */ \ + ((frags) >> sblock->fs_fragshift) +#define blkstofrags(blks) /* calculates (blks * fs->fs_frag) */ \ + ((blks) << sblock->fs_fragshift) +#define fragnum(fsb) /* calculates (fsb % fs->fs_frag) */ \ + ((fsb) & (sblock->fs_frag - 1)) +#define blknum(fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ + ((fsb) &~ (sblock->fs_frag - 1)) + +/* + * Determine the number of available frags given a + * percentage to hold in reserve + */ +#define freespace(percentreserved) \ + (blkstofrags(sblock->fs_cstotal.cs_nbfree) + \ + sblock->fs_cstotal.cs_nffree - (sblock->fs_dsize * (percentreserved) / 100)) + +/* + * Determining the size of a file block in the file system. + */ +#define blksize(ip, lbn) \ + (((lbn) >= NDADDR || (ip)->i_allocsize >= ((lbn) + 1) << sblock->fs_bshift) \ + ? sblock->fs_bsize \ + : (fragroundup(blkoff((ip)->i_allocsize)))) +#define dblksize(dip, lbn) \ + (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << sblock->fs_bshift) \ + ? sblock->fs_bsize \ + : (fragroundup(blkoff((dip)->di_size)))) + +/* + * Number of disk sectors per block; assumes DEV_BSIZE byte sector size. + */ +#define NSPB (sblock->fs_nspf << sblock->fs_fragshift) +#define NSPF (sblock->fs_nspf) + +/* + * INOPB is the number of inodes in a secondary storage block. + */ +#define INOPB (sblock->fs_inopb) +#define INOPF (sblock->fs_inopb >> sblock->fs_fragshift) + +/* + * NINDIR is the number of indirects in a file system block. + */ +#define NINDIR (sblock->fs_nindir) + +#ifdef KERNEL +struct fs *getfs(); +#endif -- cgit v1.2.3 From cc72a838ef149364e787a804fb86d35bb6a2d4cb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 20:49:26 +0000 Subject: Formerly consts.c.~3~ --- ufs/consts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs/consts.c b/ufs/consts.c index 54aa82de..dd63b410 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -15,6 +15,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "ufs.h" +#include "dinode.h" + int diskfs_link_max = LINK_MAX; int diskfs_maxsymlinks = 8; int diskfs_shortcut_symlink = 1; -- cgit v1.2.3 From 4fc263fd16e28c759c6e0967a30ca02b97e30257 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 22:05:14 +0000 Subject: entered into RCS --- ufs/devio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ufs/devio.c b/ufs/devio.c index 81423d73..2e5cc332 100644 --- a/ufs/devio.c +++ b/ufs/devio.c @@ -19,6 +19,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Michael I. Bushnell. */ +#include "ufs.h" +#include +#include + /* Write disk block ADDR with DATA of LEN bytes, waiting for completion. */ error_t dev_write_sync (daddr_t addr, @@ -26,7 +30,7 @@ dev_write_sync (daddr_t addr, long len) { int foo; - assert (!readonly); + assert (!diskfs_readonly); if (device_write (ufs_device, 0, addr, (io_buf_ptr_t) data, len, &foo) || foo != len) return EIO; @@ -40,11 +44,9 @@ dev_write (daddr_t addr, vm_address_t data, long len) { - int foo; - assert (!readonly); + assert (!diskfs_readonly); if (device_write_request (ufs_device, MACH_PORT_NULL, 0, addr, - (io_buf_ptr_t) data, len, &foo) - || foo != len) + (io_buf_ptr_t) data, len)) return EIO; return 0; } -- cgit v1.2.3 From c2e9f68ae30d9f4e73931fc3d62aaca65a4fb812 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 22:13:51 +0000 Subject: Formerly hyper.c.~3~ --- ufs/hyper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 2793985e..dfe76bcf 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -15,6 +15,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "ufs.h" +#include "fs.h" +#include void get_hypermetadata (void) @@ -46,12 +49,12 @@ get_hypermetadata (void) void diskfs_set_hypermetadata (int wait, int clean) { - error_t (*writefn) (daddr_t, vm_address_t, vm_size_t); + error_t (*writefn) (daddr_t, vm_address_t, long); writefn = (wait ? dev_write_sync : dev_write); (*writefn)(fsbtodb (sblock->fs_csaddr), (vm_address_t) csum, sblock->fs_fsize * howmany (sblock->fs_cssize, - sblock->fs_fssize)); + sblock->fs_fsize)); if (clean) sblock->fs_clean = 1; -- cgit v1.2.3 From c7ad3c1c1cb38db62050ccb04914d1e34b1d33f7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 22:25:42 +0000 Subject: Formerly fs.h.~2~ --- ufs/fs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/fs.h b/ufs/fs.h index c1dd5681..2efc6910 100644 --- a/ufs/fs.h +++ b/ufs/fs.h @@ -1,5 +1,5 @@ /* Format of a filesystem on disk (superblock and cylinder groups) - Copyright (C) 1991, 1993 Free Software Foundation + Copyright (C) 1991, 1993, 1994 Free Software Foundation This file is part of the GNU Hurd. @@ -423,10 +423,10 @@ struct ocg { /* * Determining the size of a file block in the file system. */ -#define blksize(ip, lbn) \ - (((lbn) >= NDADDR || (ip)->i_allocsize >= ((lbn) + 1) << sblock->fs_bshift) \ +#define blksize(np, lbn) \ + (((lbn) >= NDADDR || (np)->allocsize >= ((lbn) + 1) << sblock->fs_bshift) \ ? sblock->fs_bsize \ - : (fragroundup(blkoff((ip)->i_allocsize)))) + : (fragroundup(blkoff((np)->allocsize)))) #define dblksize(dip, lbn) \ (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << sblock->fs_bshift) \ ? sblock->fs_bsize \ -- cgit v1.2.3 From 8107f1ff5809374655541190c1ccc1cb05ba12ef Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 22:34:41 +0000 Subject: Formerly subr.c.~2~ --- ufs/subr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/subr.c b/ufs/subr.c index b61b09d6..25990835 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -41,8 +41,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ * @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 */ +#include "ufs.h" +#include "fs.h" -#include extern int around[9]; extern int inside[9]; -- cgit v1.2.3 From ffcb07b0b67eb70cdcd62a232d75bde7dd29e99e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Feb 1994 22:36:44 +0000 Subject: Formerly Makefile.~2~ --- ufs/Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index 11b82256..cf4d2be1 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -19,3 +19,36 @@ dir := ufs include ../Makeconf +SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ + subr.c tables.c + +DISTFILES=$(SRCS) ufs.h Makefile + +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o + +LIBS= $(libdiskfs) $(libpager) $(libioserver) $(libfshelp) \ + $(libports) $(libthreads) + +all: ufs + +ufs: $(OBJS) $(LIBS) + $(link) + +exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs + ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o + +$(OBJS): ufs.h +$(OBJS): $(addprefix $(headers)/hurd/,diskfs.h pager.h ioserver.h \ + fshelp.h ports.h) +alloc.o: fs.h dinode.h +consts.o: dinode.h +dir.o: dir.h +hyper.o: fs.h +inode.o: dinode.h fs.h +main.o: fs.h +pager.o: fs.h dinode.h +subr.o: fs.h +tables.o: fs.h + +$(foreach dir,mkbootfs exec,../$(dir)/%): FORCE + $(MAKE) -C $(@D) $(@F) -- cgit v1.2.3 From 50cefe1c1ec69dee59590f666c0e34d7cbbe505c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 11 Feb 1994 20:52:12 +0000 Subject: Formerly Makefile.~3~ --- ufs/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index cf4d2be1..90e567b2 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,8 +26,9 @@ DISTFILES=$(SRCS) ufs.h Makefile OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -LIBS= $(libdiskfs) $(libpager) $(libioserver) $(libfshelp) \ - $(libports) $(libthreads) +LIBS= $(libdiskfs) $(libpager) $(libioserver) $(libports) $(libfshelp) \ + $(libthreads) +EXTRALIBS=$(libdiskfs) all: ufs -- cgit v1.2.3 From b4b43fec2f277ef5d9312ff4fcba3ca1f26df41f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 14 Feb 1994 22:57:09 +0000 Subject: Formerly Makefile.~4~ --- ufs/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 90e567b2..3e235668 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -20,15 +20,16 @@ dir := ufs include ../Makeconf SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ - subr.c tables.c + sizes.c subr.c tables.c -DISTFILES=$(SRCS) ufs.h Makefile +DISTFILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o +PRELIBS = $(libdiskfs) $(libports) LIBS= $(libdiskfs) $(libpager) $(libioserver) $(libports) $(libfshelp) \ $(libthreads) -EXTRALIBS=$(libdiskfs) +POSTLIBS=$(libdiskfs) all: ufs @@ -48,6 +49,7 @@ hyper.o: fs.h inode.o: dinode.h fs.h main.o: fs.h pager.o: fs.h dinode.h +sizes.o: fs.h dinode.h subr.o: fs.h tables.o: fs.h -- cgit v1.2.3 From 138ff83c86dec85093e68b075b13e15ea742916a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 15 Feb 1994 17:37:52 +0000 Subject: Formerly Makefile.~5~ --- ufs/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 3e235668..7d767c79 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,16 +26,16 @@ DISTFILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -PRELIBS = $(libdiskfs) $(libports) -LIBS= $(libdiskfs) $(libpager) $(libioserver) $(libports) $(libfshelp) \ - $(libthreads) -POSTLIBS=$(libdiskfs) +LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ + $(libports) $(libfshelp) $(libthreads) $(libdiskfs) all: ufs -ufs: $(OBJS) $(LIBS) +ufs: $(OBJS) $(link) +ufs: $(LIBS) + exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o -- cgit v1.2.3 From 773e0f944fc77a8dbc30a1ebda337c8b67a8e8f3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 15 Feb 1994 17:48:00 +0000 Subject: Formerly Makefile.~6~ --- ufs/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 7d767c79..97a48df3 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -27,15 +27,13 @@ DISTFILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ - $(libports) $(libfshelp) $(libthreads) $(libdiskfs) + $(libfshelp) $(libdiskfs) $(libthreads) all: ufs -ufs: $(OBJS) +ufs: $(OBJS) $(LIBS) $(link) -ufs: $(LIBS) - exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o -- cgit v1.2.3 From dd6e2d59aa6fe10fec7f7cc642a4570d6e7355f8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 15 Feb 1994 17:59:41 +0000 Subject: Formerly consts.c.~4~ --- ufs/consts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/consts.c b/ufs/consts.c index dd63b410..0004230f 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -25,3 +25,7 @@ int diskfs_shortcut_chrdev = 1; int diskfs_shortcut_blkdev = 1; int diskfs_shortcut_fifo = 1; int diskfs_shortcut_ifsock = 1; +char *diskfs_server_name = "ufs"; +int diskfs_major_version = 0; +int diskfs_minor_version = 0; +int diskfs_edit_version = 0; -- cgit v1.2.3 From 1d1c5649b56d3a32400fa81cd3ea70ee5f119812 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 16 Feb 1994 17:42:47 +0000 Subject: Formerly Makefile.~7~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 97a48df3..284befb9 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -27,7 +27,7 @@ DISTFILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ - $(libfshelp) $(libdiskfs) $(libthreads) + $(libfshelp) $(libdiskfs) $(libthreads) $(libports) all: ufs -- cgit v1.2.3 From ac3b794b9a8dadbdae074fd4b56df8d0330a91b0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 28 Feb 1994 23:30:11 +0000 Subject: Formerly Makefile.~8~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 284befb9..d89b75b8 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -22,7 +22,7 @@ include ../Makeconf SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c -DISTFILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h +DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -- cgit v1.2.3 From 54146a1962005507a2957b0af6ac67bbc66df7be Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 1 Mar 1994 19:05:40 +0000 Subject: Formerly Makefile.~3~ --- mkbootfs/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index af663942..10106986 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -21,3 +21,6 @@ DIST_FILES = mkbootfs.c Makefile all: mkbootfs mkbootfs: mkbootfs.c $(CC) mkbootfs.c -o mkbootfs + +clean: + rm -f mkbootfs *.o -- cgit v1.2.3 From ba27e1d6005e62917e0b9f2e17f329a10c6cf335 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 1 Mar 1994 19:07:29 +0000 Subject: Formerly Makefile.~9~ --- ufs/Makefile | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index d89b75b8..d718e390 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,41 +1,4 @@ -# -# Copyright (C) 1994 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 -# published by the Free Software Foundation; either version 2, 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. - -dir := ufs - -include ../Makeconf - -SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ - sizes.c subr.c tables.c - -DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h - -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o - -LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ - $(libfshelp) $(libdiskfs) $(libthreads) $(libports) - -all: ufs - -ufs: $(OBJS) $(LIBS) - $(link) - -exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs - ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o + rm -f *.o ufs $(OBJS): ufs.h $(OBJS): $(addprefix $(headers)/hurd/,diskfs.h pager.h ioserver.h \ -- cgit v1.2.3 From ab0a73bb86ebfee4404d436aa05a649292435b4f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 1 Mar 1994 19:11:17 +0000 Subject: Formerly Makefile.~10~ --- ufs/Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index d718e390..160e98f4 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,3 +1,43 @@ + +# Copyright (C) 1994 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 +# published by the Free Software Foundation; either version 2, 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. + +dir := ufs + +include ../Makeconf + +SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ + sizes.c subr.c tables.c + +DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h + +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o + +LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ + $(libfshelp) $(libdiskfs) $(libthreads) $(libports) + +all: ufs + +ufs: $(OBJS) $(LIBS) + $(link) + +exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs + ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o + +clean: rm -f *.o ufs $(OBJS): ufs.h -- cgit v1.2.3 From 08f49203ca7a559f4a784e2bf1dc77d9c536a8d9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 2 Mar 1994 20:46:41 +0000 Subject: Formerly Makefile.~11~ --- ufs/Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 160e98f4..2676862e 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,8 +26,9 @@ DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ - $(libfshelp) $(libdiskfs) $(libthreads) $(libports) +LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) + +LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) all: ufs @@ -54,5 +55,16 @@ sizes.o: fs.h dinode.h subr.o: fs.h tables.o: fs.h +$(hurdinst)/lib/libdiskfscombined.a: $(LIBPARTS) + -mkdir foo + cd foo; $(AR) x $(libdiskfs) + cd foo; $(AR) x $(libports) + cd foo; $(AR) x $(libpager) + cd foo; $(AR) x $(libioserver) + cd foo; $(AR) x $(libfshelp) + cd foo; $(AR) cr $(hurdinst)/lib/libdiskfscombined.a * + rm -rf foo + $(RANLIB) $(hurdinst)/lib/libdiskfscombined.a + $(foreach dir,mkbootfs exec,../$(dir)/%): FORCE $(MAKE) -C $(@D) $(@F) -- cgit v1.2.3 From 17ab50e0f795394c5610cec4dba225c9165a8407 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 4 Mar 1994 07:28:08 +0000 Subject: Initial revision --- =Maketools | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 =Maketools diff --git a/=Maketools b/=Maketools new file mode 100644 index 00000000..1a73e4a9 --- /dev/null +++ b/=Maketools @@ -0,0 +1,22 @@ +# This is the directory holding ar and ranlib +tooldir := /usr/local/i386-mach/bin + +# This is a machine on which to run MiG. (MiG writes CPU dependent code, +# so MiG has to be run on a machine that's the same as the one that will +# run the eventual code.) If you are not doing cross-compilation, then +# you need to set MIGCOM and MIG below to the plain pathnames of those +# two programs respectively. +mighost := ernst + +# Set these options to the GCC compiler spec (the correct value +# can be found in /usr/local/lib/lib-gcc). +CCTARGET=i386-mach +CCVERSION=2.5.8 +CCTYPE=-b $(CCTARGET) -V $(CCVERSION) + +CC=gcc $(CCTYPE) -O6 -pipe +MIGCOM=rsh $(mighost) cd $(hurdsource)/$(dir) \; /usr/local/lib/migcom +CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp +MIG=rsh $(mighost) cd $(hurdsource)/$(dir) \; mig +AR=$(tooldir)/ar +RANLIB=$(tooldir)/ranlib -- cgit v1.2.3 From 2afc11d802d9bcfb007acdcdf1c1c5851771b3bc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 4 Mar 1994 19:05:46 +0000 Subject: Formerly Maketools.~2~ --- =Maketools | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index 1a73e4a9..03a4c430 100644 --- a/=Maketools +++ b/=Maketools @@ -14,9 +14,13 @@ CCTARGET=i386-mach CCVERSION=2.5.8 CCTYPE=-b $(CCTARGET) -V $(CCVERSION) +HOST_CC := $(CC) CC=gcc $(CCTYPE) -O6 -pipe -MIGCOM=rsh $(mighost) cd $(hurdsource)/$(dir) \; /usr/local/lib/migcom +MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp -MIG=rsh $(mighost) cd $(hurdsource)/$(dir) \; mig +export CPP +# I put a /usr/local/bin/mig on the hp300s that will run $CPP locally and +# rsh to ernst to run migcom. --roland +MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib -- cgit v1.2.3 From 64fdd3a5cfdc7b8796e7ee2bc5ca2d883ddc6c95 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 4 Mar 1994 21:29:58 +0000 Subject: Formerly Makefile.~13~ --- ufs/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 2676862e..313bd838 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,7 +26,9 @@ DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) +#LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) +LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ + $(libfshelp) $(libdiskfs) $(libthreads) $(libports) LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) -- cgit v1.2.3 From d035d62ceaae7f05fdceb36870654842661a4071 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Mar 1994 19:42:10 +0000 Subject: Formerly Makefile.~14~ --- ufs/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 313bd838..03628376 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -19,12 +19,14 @@ dir := ufs include ../Makeconf +VPATH=.:../machine + SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o boot_machdep.o #LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ -- cgit v1.2.3 From 5b24daccc6788690dc4fb5f6591c84904d853d14 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Mar 1994 19:52:17 +0000 Subject: Formerly Maketools.~3~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 03a4c430..a89a8914 100644 --- a/=Maketools +++ b/=Maketools @@ -15,7 +15,7 @@ CCVERSION=2.5.8 CCTYPE=-b $(CCTARGET) -V $(CCVERSION) HOST_CC := $(CC) -CC=gcc $(CCTYPE) -O6 -pipe +CC=gcc $(CCTYPE) -O2 -pipe MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp export CPP -- cgit v1.2.3 From 2251c0527db1bb2230d7af971b3671cc749cd696 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Mar 1994 23:28:32 +0000 Subject: Formerly Makefile.~15~ --- ufs/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/Makefile b/ufs/Makefile index 03628376..b6b006f6 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -40,6 +40,7 @@ ufs: $(OBJS) $(LIBS) $(link) exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs + rsh $(mighost) cd `pwd` \; \ ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o clean: -- cgit v1.2.3 From e641abc3b1f01e285240035221f5ddae32209bb3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 14 Mar 1994 21:35:06 +0000 Subject: Formerly Maketools.~4~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index a89a8914..e4f22c5f 100644 --- a/=Maketools +++ b/=Maketools @@ -15,7 +15,7 @@ CCVERSION=2.5.8 CCTYPE=-b $(CCTARGET) -V $(CCVERSION) HOST_CC := $(CC) -CC=gcc $(CCTYPE) -O2 -pipe +CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp export CPP -- cgit v1.2.3 From b4cc3bdd6720011c09bddfd3bd8d5e88c6215d22 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 23 Mar 1994 18:45:48 +0000 Subject: Formerly Maketools.~5~ --- =Maketools | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index e4f22c5f..b8d02bab 100644 --- a/=Maketools +++ b/=Maketools @@ -14,7 +14,9 @@ CCTARGET=i386-mach CCVERSION=2.5.8 CCTYPE=-b $(CCTARGET) -V $(CCVERSION) -HOST_CC := $(CC) +ifndef HOST_CC +export HOST_CC := $(CC) +endif CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp -- cgit v1.2.3 From c0e4f35272ccf8a8d9e9e87167b39e66dc1243f4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 31 Mar 1994 18:14:53 +0000 Subject: Formerly Makefile.~4~ --- mkbootfs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index 10106986..ba6ab062 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -20,7 +20,7 @@ include ../Makeconf DIST_FILES = mkbootfs.c Makefile all: mkbootfs mkbootfs: mkbootfs.c - $(CC) mkbootfs.c -o mkbootfs + rsh $(mighost) cd `pwd` \; $(CC) mkbootfs.c -o mkbootfs clean: rm -f mkbootfs *.o -- cgit v1.2.3 From 1c93aeda573a9ba671377c235a861d0e8ccd02a8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 31 Mar 1994 18:15:33 +0000 Subject: Formerly Makefile.~16~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index b6b006f6..9ec865b3 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,7 +26,7 @@ SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o boot_machdep.o +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o #LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ -- cgit v1.2.3 From 19f45213a2d18f4f0f343dd8cb3e9cca502b2902 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 1 Apr 1994 22:54:29 +0000 Subject: Formerly Maketools.~6~ --- =Maketools | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/=Maketools b/=Maketools index b8d02bab..8e3995da 100644 --- a/=Maketools +++ b/=Maketools @@ -18,7 +18,11 @@ ifndef HOST_CC export HOST_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. +ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom +else +MIGCOM=/usr/local/lib/migcom +endif CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp export CPP # I put a /usr/local/bin/mig on the hp300s that will run $CPP locally and -- cgit v1.2.3 From f30d3c118288b26086af0c53294751864d182036 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 5 Apr 1994 03:27:50 +0000 Subject: Formerly Maketools.~7~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 8e3995da..0091ee41 100644 --- a/=Maketools +++ b/=Maketools @@ -29,4 +29,4 @@ export CPP # rsh to ernst to run migcom. --roland MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar -RANLIB=$(tooldir)/ranlib +RANLIB=@echo NOT RUNNING BUGGY $(tooldir)/ranlib -- cgit v1.2.3 From 542a6daceb6c4177eff3877f37cda66af5a12484 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Apr 1994 19:02:45 +0000 Subject: Formerly Makefile.~17~ --- ufs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index 9ec865b3..3698b7bd 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -36,6 +36,8 @@ LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) all: ufs +LDFLAGS=--no-keep-memory + ufs: $(OBJS) $(LIBS) $(link) -- cgit v1.2.3 From dbba26f827e34f3bd6edcf348251aa8f86823671 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Apr 1994 19:07:04 +0000 Subject: Formerly Maketools.~8~ --- =Maketools | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 0091ee41..a7b22318 100644 --- a/=Maketools +++ b/=Maketools @@ -29,4 +29,5 @@ export CPP # rsh to ernst to run migcom. --roland MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar -RANLIB=@echo NOT RUNNING BUGGY $(tooldir)/ranlib +RANLIB=$(tooldir)/ranlib +LD=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/ld -- cgit v1.2.3 From f4fc5fcda4fc24a31aef39ab8de44c441d41d342 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Apr 1994 19:24:20 +0000 Subject: Formerly hyper.c.~4~ --- ufs/hyper.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index dfe76bcf..bd58b7e4 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -18,6 +18,7 @@ #include "ufs.h" #include "fs.h" #include +#include void get_hypermetadata (void) @@ -26,7 +27,26 @@ get_hypermetadata (void) err = dev_read_sync (SBLOCK, (vm_address_t *)&sblock, SBSIZE); assert (!err); - + + if (sblock->fs_magic != FS_MAGIC) + { + fprintf (stderr, "Bad magic number %#lx (should be %#x)\n", + sblock->fs_magic, FS_MAGIC); + exit (1); + } + if (sblock->fs_bsize > 8192) + { + fprintf (stderr, "Block size %ld is too big (max is 8192 bytes)\n", + sblock->fs_bsize); + exit (1); + } + if (sblock->fs_bsize < sizeof (struct fs)) + { + fprintf (stderr, "Block size %ld is too small (min is %ld bytes)\n", + sblock->fs_bsize, sizeof (struct fs)); + exit (1); + } + /* If this is an old filesystem, then we have some more work to do; some crucial constants might not be set; we are therefore forced to set them here. */ -- cgit v1.2.3 From 30da4357f58c1115904cbf79037aa930178fc416 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 7 Apr 1994 18:41:57 +0000 Subject: Formerly Makefile.~5~ --- mkbootfs/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index ba6ab062..cd969010 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -24,3 +24,8 @@ mkbootfs: mkbootfs.c clean: rm -f mkbootfs *.o + +# Relink should do nothing here because this program does not use +# the Hurd libraries. +relink: + -- cgit v1.2.3 From 528f76fbf80b0d3561057748e72f0de60c158583 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 7 Apr 1994 18:42:53 +0000 Subject: Formerly Makefile.~18~ --- ufs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index 3698b7bd..a0ce7c7b 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -47,6 +47,8 @@ exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs clean: rm -f *.o ufs +relink: + rm -f ufs $(OBJS): ufs.h $(OBJS): $(addprefix $(headers)/hurd/,diskfs.h pager.h ioserver.h \ -- cgit v1.2.3 From 9e48841058d912535a84a9c8787f454dcf3bb89a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 7 Apr 1994 19:00:57 +0000 Subject: Formerly Makefile.~19~ --- ufs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index a0ce7c7b..f671d906 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -45,6 +45,8 @@ exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs rsh $(mighost) cd `pwd` \; \ ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o +install: + clean: rm -f *.o ufs relink: -- cgit v1.2.3 From 0a936e7568bf2a955845e9e19cb2ce19ebc787bd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 7 Apr 1994 19:01:11 +0000 Subject: Formerly Makefile.~6~ --- mkbootfs/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index cd969010..4b066d8f 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -29,3 +29,4 @@ clean: # the Hurd libraries. relink: +install: -- cgit v1.2.3 From cc7a844ccaa9657225550bd9ac18bcda2d73f862 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 8 Apr 1994 23:47:02 +0000 Subject: Formerly Maketools.~9~ --- =Maketools | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index a7b22318..60ff7d93 100644 --- a/=Maketools +++ b/=Maketools @@ -10,9 +10,11 @@ mighost := ernst # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). -CCTARGET=i386-mach -CCVERSION=2.5.8 +CCTARGET=i386-gnu +CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.5.8) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) +CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 +CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 ifndef HOST_CC export HOST_CC := $(CC) -- cgit v1.2.3 From b30e98edfba0f2392f28a23ccbc6a2efd68fef7a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 11 Apr 1994 22:46:32 +0000 Subject: Formerly Maketools.~10~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 60ff7d93..b80a11a4 100644 --- a/=Maketools +++ b/=Maketools @@ -10,7 +10,7 @@ mighost := ernst # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). -CCTARGET=i386-gnu +CCTARGET=i386-mach CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.5.8) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 -- cgit v1.2.3 From ed15887cd9516f6a43417adcf1f3569ba64d0583 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 21 Apr 1994 19:27:40 +0000 Subject: entered into RCS --- mkbootfs/mkbootfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c index 19dd8c11..e3ad7137 100644 --- a/mkbootfs/mkbootfs.c +++ b/mkbootfs/mkbootfs.c @@ -55,6 +55,8 @@ main (int argc, char **argv) void *buf; struct nlist n; + signal (0, 0); + if (argc != 3) { fprintf (stderr, "Usage: %s execserver newdoto\n", argv[0]); -- cgit v1.2.3 From ec29aa9cbb4c30f3bcb26bf3e3d439525bf55d64 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 21 Apr 1994 21:52:16 +0000 Subject: Formerly Maketools.~11~ --- =Maketools | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index b80a11a4..4e08148d 100644 --- a/=Maketools +++ b/=Maketools @@ -16,6 +16,8 @@ CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 +ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) + ifndef HOST_CC export HOST_CC := $(CC) endif @@ -25,11 +27,11 @@ MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom else MIGCOM=/usr/local/lib/migcom endif -CPP=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/cpp +CPP=$(ccdir)/cpp export CPP # I put a /usr/local/bin/mig on the hp300s that will run $CPP locally and # rsh to ernst to run migcom. --roland MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib -LD=/usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION)/ld +LD=$(ccdir)/ld -L$(ccdir) -- cgit v1.2.3 From 1d3ae7b05e59ec9cdaabc8fb5c25bd79dad69d7d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 2 May 1994 20:47:41 +0000 Subject: Formerly Makefile.~7~ --- mkbootfs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index 4b066d8f..77de2bf0 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -17,7 +17,7 @@ dir := mkbootfs include ../Makeconf -DIST_FILES = mkbootfs.c Makefile +DIST_FILES = mkbootfs.c Makefile ChangeLog all: mkbootfs mkbootfs: mkbootfs.c rsh $(mighost) cd `pwd` \; $(CC) mkbootfs.c -o mkbootfs -- cgit v1.2.3 From e1d9f34e9e60cc1beb2aa8cf350b281e6e087522 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 2 May 1994 20:49:32 +0000 Subject: Formerly Makefile.~20~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index f671d906..7f673092 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -24,7 +24,7 @@ VPATH=.:../machine SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c -DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h +DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h ChangeLog OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -- cgit v1.2.3 From 61f43260ce1825abdcbdc49c6c9328eb74cfa026 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 4 May 1994 11:07:26 +0000 Subject: Formerly Maketools.~12~ --- =Maketools | 2 ++ 1 file changed, 2 insertions(+) diff --git a/=Maketools b/=Maketools index 4e08148d..29ceab40 100644 --- a/=Maketools +++ b/=Maketools @@ -35,3 +35,5 @@ MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(ccdir)/ld -L$(ccdir) + +machine := i386 -- cgit v1.2.3 From 9f5ef8cf555806912ef24062f4a34b19c08b0cbb Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 5 May 1994 11:39:59 +0000 Subject: Formerly Makefile.~21~ --- ufs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 7f673092..98e6391f 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -53,8 +53,8 @@ relink: rm -f ufs $(OBJS): ufs.h -$(OBJS): $(addprefix $(headers)/hurd/,diskfs.h pager.h ioserver.h \ - fshelp.h ports.h) +$(OBJS): $(addprefix $(includedir)/hurd/,diskfs.h pager.h ioserver.h \ + fshelp.h ports.h) alloc.o: fs.h dinode.h consts.o: dinode.h dir.o: dir.h -- cgit v1.2.3 From a6bccd7faf6c6922547434bd7d9dd1b711590717 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 5 May 1994 23:06:15 +0000 Subject: Formerly Makefile.~8~ --- mkbootfs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index 77de2bf0..d0f0bf31 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -20,7 +20,7 @@ include ../Makeconf DIST_FILES = mkbootfs.c Makefile ChangeLog all: mkbootfs mkbootfs: mkbootfs.c - rsh $(mighost) cd `pwd` \; $(CC) mkbootfs.c -o mkbootfs + rsh -n $(mighost) cd `pwd` \; $(CC) mkbootfs.c -o mkbootfs clean: rm -f mkbootfs *.o -- cgit v1.2.3 From 1837dae205818d8546f54d2b43817cc4295db155 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 5 May 1994 23:06:48 +0000 Subject: Formerly Makefile.~22~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 98e6391f..67ac3b16 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -42,7 +42,7 @@ ufs: $(OBJS) $(LIBS) $(link) exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs - rsh $(mighost) cd `pwd` \; \ + rsh -n $(mighost) cd `pwd` \; \ ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o install: -- cgit v1.2.3 From ec7dbc045ecbd4fab29b9095aa804546e26f7ff5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 5 May 1994 23:16:46 +0000 Subject: Formerly Maketools.~13~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 29ceab40..086424c6 100644 --- a/=Maketools +++ b/=Maketools @@ -23,7 +23,7 @@ export HOST_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom +MIGCOM=rsh -n $(mighost) cd `pwd` \; /usr/local/lib/migcom else MIGCOM=/usr/local/lib/migcom endif -- cgit v1.2.3 From e4a1067abaed55bf6ee2d709f080073e157020c5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 5 May 1994 23:26:07 +0000 Subject: Formerly Maketools.~14~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 086424c6..29ceab40 100644 --- a/=Maketools +++ b/=Maketools @@ -23,7 +23,7 @@ export HOST_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=rsh -n $(mighost) cd `pwd` \; /usr/local/lib/migcom +MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom else MIGCOM=/usr/local/lib/migcom endif -- cgit v1.2.3 From d90b0ae96a3a22d21c46e56bc4ee6e0816235027 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 6 May 1994 17:26:56 +0000 Subject: Formerly Makefile.~9~ --- mkbootfs/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index d0f0bf31..a65cd722 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -17,10 +17,11 @@ dir := mkbootfs include ../Makeconf + DIST_FILES = mkbootfs.c Makefile ChangeLog all: mkbootfs mkbootfs: mkbootfs.c - rsh -n $(mighost) cd `pwd` \; $(CC) mkbootfs.c -o mkbootfs + rsh -n $(mighost) cd `pwd` \; $(MIGHOSTCC) mkbootfs.c -o mkbootfs clean: rm -f mkbootfs *.o -- cgit v1.2.3 From 78eacd9a3aac87801d3958e99b11ff6fe6ff9b7c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 6 May 1994 17:30:39 +0000 Subject: Formerly Maketools.~15~ --- =Maketools | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 29ceab40..400f39aa 100644 --- a/=Maketools +++ b/=Maketools @@ -6,7 +6,10 @@ tooldir := /usr/local/i386-mach/bin # run the eventual code.) If you are not doing cross-compilation, then # you need to set MIGCOM and MIG below to the plain pathnames of those # two programs respectively. -mighost := ernst +# If the version of GCC on this version is not the same as CCVERSION, +# then you must set CCVERSION-$(mighost) in the same fashion as is +# done below for ernst.gnu.ai.mit.edu and douglas.gnu.ai.mit.edu. +mighost := ernst.gnu.ai.mit.edu # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). @@ -15,6 +18,8 @@ CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.5.8) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 +MIGHOSTCCVERSION=$(firstword $(CCVERSION-$(mighost)) $(CCVERSION)) +MIGHOSTCCTYPE= -b $(CCTARGET) -V $(MIGHOSTCCVERSION) ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) @@ -22,6 +27,7 @@ ifndef HOST_CC export HOST_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. +MIGHOSTCC= gcc $(MIGHOSTCCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom else -- cgit v1.2.3 From f30e0393f2b8efd5cec170fe1749af81b2c27822 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 24 May 1994 02:31:52 +0000 Subject: Formerly Makefile.~23~ --- ufs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 67ac3b16..7c3c6ca7 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -42,10 +42,10 @@ ufs: $(OBJS) $(LIBS) $(link) exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs - rsh -n $(mighost) cd `pwd` \; \ + rsh $(mighost) -n cd `pwd` \; \ ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o -install: +install: clean: rm -f *.o ufs -- cgit v1.2.3 From 0642add6bb9711abe8d30bf01f6663b73b3c9b79 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 24 May 1994 20:15:17 +0000 Subject: Formerly Maketools.~16~ --- =Maketools | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index 400f39aa..6e06d76a 100644 --- a/=Maketools +++ b/=Maketools @@ -26,8 +26,8 @@ ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) ifndef HOST_CC export HOST_CC := $(CC) endif -CC=gcc $(CCTYPE) -O2 -pipe # Ceci n'est pas une pipe. -MIGHOSTCC= gcc $(MIGHOSTCCTYPE) -O2 -pipe +CC=gcc $(CCTYPE) -O2 +MIGHOSTCC= gcc $(MIGHOSTCCTYPE) -O2 ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom else -- cgit v1.2.3 From 2b40767b8a493e25f0d7214f6fc72f5ecdc57732 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 26 May 1994 18:10:27 +0000 Subject: Initial revision --- ufs/alloc.c | 1053 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1053 insertions(+) create mode 100644 ufs/alloc.c diff --git a/ufs/alloc.c b/ufs/alloc.c new file mode 100644 index 00000000..161edcb8 --- /dev/null +++ b/ufs/alloc.c @@ -0,0 +1,1053 @@ +/* Disk allocation routines + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Modified from UCB by Michael I. Bushnell. */ + +/* + * Copyright (c) 1982, 1986, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)ufs_alloc.c 7.20 (Berkeley) 6/28/90 + */ + +#include "ufs.h" +#include "fs.h" +#include "dinode.h" + +#include + +static u_long alloccg (int, daddr_t, int); +static u_long ialloccg (int, daddr_t, int); +static u_long hashalloc (int, long, int, u_long(*)(int, daddr_t, int)); +static daddr_t fragextend (int, long, int, int); +static daddr_t alloccgblk (struct cg *, daddr_t); +static daddr_t mapsearch (struct cg *, daddr_t, int); +static ino_t dirpref (); + +/* These are in tables.c. */ +extern int inside[], around[]; +extern unsigned char *fragtbl[]; + +static spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; + +/* + * Allocate a block in the file system. + * + * The size of the requested block is given, which must be some + * multiple of fs_fsize and <= fs_bsize. + * A preference may be optionally specified. If a preference is given + * the following hierarchy is used to allocate a block: + * 1) allocate the requested block. + * 2) allocate a rotationally optimal block in the same cylinder. + * 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 + * to allocate a block: + * 1) allocate a block in the cylinder group that contains the + * inode for the file. + * 2) quadradically rehash into other cylinder groups, until an + * available block is located. + */ +error_t +alloc(struct node *np, + daddr_t lbn, + daddr_t bpref, + int size, + daddr_t *bnp, + struct protid *cred) +{ + int cg; + daddr_t bno; + + *bnp = 0; + assert ("Alloc of bad sized block" && (unsigned) size <= sblock->fs_bsize + && !fragoff(size)); + + spin_lock (&alloclock); + + if (size == sblock->fs_bsize && sblock->fs_cstotal.cs_nbfree == 0) + goto nospace; + if (cred && !diskfs_isuid (0, cred) && freespace(sblock->fs_minfree) <= 0) + goto nospace; + + if (bpref >= sblock->fs_size) + bpref = 0; + if (bpref == 0) + cg = itog(np->dn->number); + else + cg = dtog(bpref); + bno = (daddr_t)hashalloc(cg, (long)bpref, size, alloccg); + + spin_unlock (&alloclock); + + if (bno > 0) + { + np->dn_stat.st_blocks += btodb(size); + np->dn_set_mtime = 1; + np->dn_set_ctime = 1; + *bnp = bno; + return 0; + } + + nospace: + spin_unlock (&alloclock); + printf("file system full\n"); + return (ENOSPC); +} + +/* + * Reallocate a fragment to a bigger size + * + * The number and size of the old block is given, and a preference + * and new size is also specified. The allocator attempts to extend + * the original block. Failing that, the regular block allocator is + * invoked to get an appropriate block. + */ +error_t +realloccg(struct node *np, + daddr_t lbprev, + volatile daddr_t bpref, + int osize, + int nsize, + daddr_t *pbn, + struct protid *cred) +{ + volatile int cg, request; + daddr_t bprev, bno; + error_t error; + + *pbn = 0; + assert ("bad old size" && (unsigned) osize <= sblock->fs_bsize + && !fragoff (osize)); + assert ("bad new size" && (unsigned) nsize <= sblock->fs_bsize + && !fragoff (nsize)); + + spin_lock (&alloclock); + + if (cred && !diskfs_isuid (0, cred) && freespace(sblock->fs_minfree) <= 0) + { + spin_unlock (&alloclock); + goto nospace; + } + + if (error = diskfs_catch_exception ()) + return error; + bprev = dinodes[np->dn->number].di_db[lbprev]; + diskfs_end_catch_exception (); + assert ("old block not allocated" && bprev); + + /* + * Check for extension in the existing location. + */ + cg = dtog(bprev); + if (bno = fragextend(cg, (long)bprev, osize, nsize)) + { + spin_unlock (&alloclock); + assert ("fragextend behaved incorrectly" && bprev == bno); + np->dn_stat.st_blocks += btodb(nsize - osize); + np->dn_set_mtime = 1; + np->dn_set_ctime = 1; + *pbn = bno; + return (0); + } + /* + * Allocate a new disk location. + */ + if (bpref >= sblock->fs_size) + bpref = 0; + switch ((int)sblock->fs_optim) + { + case FS_OPTSPACE: + /* + * Allocate an exact sized fragment. Although this makes + * best use of space, we will waste time relocating it if + * the file continues to grow. If the fragmentation is + * less than half of the minimum free reserve, we choose + * to begin optimizing for time. + */ + request = nsize; + if (sblock->fs_minfree < 5 || + sblock->fs_cstotal.cs_nffree > + sblock->fs_dsize * sblock->fs_minfree / (2 * 100)) + break; + printf("optimization changed from SPACE to TIME\n"); + sblock->fs_optim = FS_OPTTIME; + break; + case FS_OPTTIME: + /* + * At this point we have discovered a file that is trying + * to grow a small fragment to a larger fragment. To save + * time, we allocate a full sized block, then free the + * unused portion. If the file continues to grow, the + * `fragextend' call above will be able to grow it in place + * without further copying. If aberrant programs cause + * disk fragmentation to grow within 2% of the free reserve, + * we choose to begin optimizing for space. + */ + request = sblock->fs_bsize; + if (sblock->fs_cstotal.cs_nffree < + sblock->fs_dsize * (sblock->fs_minfree - 2) / 100) + break; + printf("%s: optimization changed from TIME to SPACE\n", + sblock->fs_fsmnt); + sblock->fs_optim = FS_OPTSPACE; + break; + default: + assert ("filesystem opitimazation bad value" && 0); + } + + bno = (daddr_t)hashalloc(cg, (long)bpref, request, + (u_long (*)())alloccg); + + spin_unlock (&alloclock); + + if (bno > 0) + { + blkfree(bprev, (off_t)osize); + if (nsize < request) + blkfree(bno + numfrags(nsize), (off_t)(request - nsize)); + np->dn_stat.st_blocks += btodb (nsize - osize); + np->dn_set_mtime = 1; + np->dn_set_ctime = 1; + *pbn = bno; + return (0); + } + nospace: + /* + * no space available + */ + printf("file system full\n"); + return (ENOSPC); +} + + +/* Implement the diskfs_alloc_node callback from the diskfs library. + See for the interface description. */ +error_t +diskfs_alloc_node(struct node *dir, + mode_t mode, + struct node **npp) +{ + int ino; + struct node *np; + int cg; + error_t error; + int ipref; + + if (S_ISDIR (mode)) + ipref = dirpref (); + else + ipref = dir->dn->number; + + *npp = 0; + + if (sblock->fs_cstotal.cs_nifree == 0) + goto noinodes; + if (ipref >= sblock->fs_ncg * sblock->fs_ipg) + ipref = 0; + cg = itog(ipref); + spin_lock (&alloclock); + ino = (int)hashalloc(cg, (long)ipref, mode, ialloccg); + spin_unlock (&alloclock); + if (ino == 0) + goto noinodes; + if (error = iget(ino, &np)) + return error; + *npp = np; + assert ("duplicate allocation" && !np->dn_stat.st_mode); + if (np->dn_stat.st_blocks) + { + printf("free inode %d had %d blocks\n", ino, np->dn_stat.st_blocks); + np->dn_stat.st_blocks = 0; + np->dn_set_ctime = 1; + } + /* + * Set up a new generation number for this inode. + */ + spin_lock (&gennumberlock); + if (++nextgennumber < (u_long)diskfs_mtime->seconds) + nextgennumber = diskfs_mtime->seconds; + np->dn_stat.st_gen = nextgennumber; + spin_unlock (&gennumberlock); + return (0); + noinodes: + printf("out of inodes\n"); + return (ENOSPC); +} + +/* + * Find a cylinder to place a directory. + * + * The policy implemented by this algorithm is to select from + * among those cylinder groups with above the average number of + * free inodes, the one with the smallest number of directories. + */ +static ino_t +dirpref() +{ + int cg, minndir, mincg, avgifree; + + spin_lock (&alloclock); + avgifree = sblock->fs_cstotal.cs_nifree / sblock->fs_ncg; + minndir = sblock->fs_ipg; + mincg = 0; + for (cg = 0; cg < sblock->fs_ncg; cg++) + if (csum[cg].cs_ndir < minndir && csum[cg].cs_nifree >= avgifree) + { + mincg = cg; + minndir = csum[cg].cs_ndir; + } + spin_unlock (&alloclock); + return ((int)(sblock->fs_ipg * mincg)); +} + +/* + * Select the desired position for the next block in a file. The file is + * logically divided into sections. The first section is composed of the + * direct blocks. Each additional section contains fs_maxbpg blocks. + * + * If no blocks have been allocated in the first section, the policy is to + * request a block in the same cylinder group as the inode that describes + * the file. If no blocks have been allocated in any other section, the + * policy is to place the section in a cylinder group with a greater than + * average number of free blocks. An appropriate cylinder group is found + * by using a rotor that sweeps the cylinder groups. When a new group of + * blocks is needed, the sweep begins in the cylinder group following the + * cylinder group from which the previous allocation was made. The sweep + * continues until a cylinder group with greater than the average number + * of free blocks is found. If the allocation is for the first block in an + * indirect block, the information on the previous allocation is unavailable; + * here a best guess is made based upon the logical block number being + * allocated. + * + * If a section is already partially allocated, the policy is to + * contiguously allocate fs_maxcontig blocks. The end of one of these + * contiguous blocks and the beginning of the next is physically separated + * so that the disk head will be in transit between them for at least + * fs_rotdelay milliseconds. This is to allow time for the processor to + * schedule another I/O transfer. + */ +daddr_t +blkpref(struct node *np, + daddr_t lbn, + int indx, + daddr_t *bap) +{ + int cg; + int avgbfree, startcg; + daddr_t nextblk; + + spin_lock (&alloclock); + if (indx % sblock->fs_maxbpg == 0 || bap[indx - 1] == 0) + { + if (lbn < NDADDR) + { + spin_unlock (&alloclock); + cg = itog(np->dn->number); + return (sblock->fs_fpg * cg + sblock->fs_frag); + } + /* + * Find a cylinder with greater than average number of + * unused data blocks. + */ + if (indx == 0 || bap[indx - 1] == 0) + startcg = itog(np->dn->number) + lbn / sblock->fs_maxbpg; + else + startcg = dtog(bap[indx - 1]) + 1; + startcg %= sblock->fs_ncg; + avgbfree = sblock->fs_cstotal.cs_nbfree / sblock->fs_ncg; + for (cg = startcg; cg < sblock->fs_ncg; cg++) + if (csum[cg].cs_nbfree >= avgbfree) + { + spin_unlock (&alloclock); + sblock->fs_cgrotor = cg; + return (sblock->fs_fpg * cg + sblock->fs_frag); + } + for (cg = 0; cg <= startcg; cg++) + if (csum[cg].cs_nbfree >= avgbfree) + { + spin_unlock (&alloclock); + sblock->fs_cgrotor = cg; + return (sblock->fs_fpg * cg + sblock->fs_frag); + } + spin_unlock (&alloclock); + return 0; + } + + spin_unlock (&alloclock); + + /* + * One or more previous blocks have been laid out. If less + * than fs_maxcontig previous blocks are contiguous, the + * next block is requested contiguously, otherwise it is + * requested rotationally delayed by fs_rotdelay milliseconds. + */ + nextblk = bap[indx - 1] + sblock->fs_frag; + if (indx > sblock->fs_maxcontig && + bap[indx - sblock->fs_maxcontig] + blkstofrags(sblock->fs_maxcontig) + != nextblk) + return (nextblk); + if (sblock->fs_rotdelay != 0) + /* + * Here we convert ms of delay to frags as: + * (frags) = (ms) * (rev/sec) * (sect/rev) / + * ((sect/frag) * (ms/sec)) + * then round up to the next block. + */ + nextblk += roundup(sblock->fs_rotdelay * sblock->fs_rps + * sblock->fs_nsect / (NSPF * 1000), sblock->fs_frag); + return (nextblk); +} + +/* + * Implement the cylinder overflow algorithm. + * + * The policy implemented by this algorithm is: + * 1) allocate the block in its requested cylinder group. + * 2) quadradically rehash on the cylinder group number. + * 3) brute force search for a free block. + */ +/*VARARGS5*/ +static u_long +hashalloc(int cg, + long pref, + int size, /* size for data blocks, mode for inodes */ + u_long (*allocator)(int, daddr_t, int)) +{ + long result; + int i, icg = cg; + + /* + * 1: preferred cylinder group + */ + result = (*allocator)(cg, pref, size); + if (result) + return (result); + /* + * 2: quadratic rehash + */ + for (i = 1; i < sblock->fs_ncg; i *= 2) + { + cg += i; + if (cg >= sblock->fs_ncg) + cg -= sblock->fs_ncg; + result = (*allocator)(cg, 0, size); + if (result) + return (result); + } + /* + * 3: brute force search + * Note that we start at i == 2, since 0 was checked initially, + * and 1 is always checked in the quadratic rehash. + */ + cg = (icg + 2) % sblock->fs_ncg; + for (i = 2; i < sblock->fs_ncg; i++) + { + result = (*allocator)(cg, 0, size); + if (result) + return (result); + cg++; + if (cg == sblock->fs_ncg) + cg = 0; + } + return 0; +} + +/* + * Determine whether a fragment can be extended. + * + * Check to see if the necessary fragments are available, and + * if they are, allocate them. + */ +static daddr_t +fragextend(int cg, + long bprev, + int osize, + int nsize) +{ + struct cg *cgp; + long bno; + int frags, bbase; + int i; + + if (csum[cg].cs_nffree < numfrags(nsize - osize)) + return 0; + frags = numfrags(nsize); + bbase = fragnum(bprev); + if (bbase > fragnum((bprev + frags - 1))) + /* cannot extend across a block boundary */ + return 0; + + cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); + + if (diskfs_catch_exception ()) + return 0; /* bogus, but that's what BSD does... */ + + if (!cg_chkmagic(cgp)) + { + printf ("Cylinder group %d bad magic number: %ld/%ld\n", + cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); + diskfs_end_catch_exception (); + return 0; + } + cgp->cg_time = diskfs_mtime->seconds; + bno = dtogd(bprev); + for (i = numfrags(osize); i < frags; i++) + if (isclr(cg_blksfree(cgp), bno + i)) + { + diskfs_end_catch_exception (); + return 0; + } + + /* + * the current fragment can be extended + * deduct the count on fragment being extended into + * increase the count on the remaining fragment (if any) + * allocate the extended piece + */ + for (i = frags; i < sblock->fs_frag - bbase; i++) + if (isclr(cg_blksfree(cgp), bno + i)) + break; + cgp->cg_frsum[i - numfrags(osize)]--; + if (i != frags) + cgp->cg_frsum[i - frags]++; + for (i = numfrags(osize); i < frags; i++) + { + clrbit(cg_blksfree(cgp), bno + i); + cgp->cg_cs.cs_nffree--; + sblock->fs_cstotal.cs_nffree--; + csum[cg].cs_nffree--; + } + diskfs_end_catch_exception (); + return (bprev); +} + +/* + * Determine whether a block can be allocated. + * + * Check to see if a block of the apprpriate size is available, + * and if it is, allocate it. + */ +static u_long +alloccg(int cg, + volatile daddr_t bpref, + int size) +{ + struct cg *cgp; + int i; + int bno, frags, allocsiz; + + if (csum[cg].cs_nbfree == 0 && size == sblock->fs_bsize) + return 0; + cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); + + if (diskfs_catch_exception ()) + return 0; + + if (!cg_chkmagic(cgp) || + (cgp->cg_cs.cs_nbfree == 0 && size == sblock->fs_bsize)) + { + printf ("Cylinder group %d bad magic number: %ld/%ld\n", + cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); + diskfs_end_catch_exception (); + return 0; + } + cgp->cg_time = diskfs_mtime->seconds; + if (size == sblock->fs_bsize) + { + bno = alloccgblk(cgp, bpref); + diskfs_end_catch_exception (); + return (u_long) (bno); + } + /* + * check to see if any fragments are already available + * allocsiz is the size which will be allocated, hacking + * it down to a smaller size if necessary + */ + frags = numfrags(size); + for (allocsiz = frags; allocsiz < sblock->fs_frag; allocsiz++) + if (cgp->cg_frsum[allocsiz] != 0) + break; + if (allocsiz == sblock->fs_frag) + { + /* + * no fragments were available, so a block will be + * allocated, and hacked up + */ + if (cgp->cg_cs.cs_nbfree == 0) + { + diskfs_end_catch_exception (); + return 0; + } + + bno = alloccgblk(cgp, bpref); + bpref = dtogd(bno); + for (i = frags; i < sblock->fs_frag; i++) + setbit(cg_blksfree(cgp), bpref + i); + i = sblock->fs_frag - frags; + cgp->cg_cs.cs_nffree += i; + sblock->fs_cstotal.cs_nffree += i; + csum[cg].cs_nffree += i; + cgp->cg_frsum[i]++; + return (u_long)(bno); + } + bno = mapsearch(cgp, bpref, allocsiz); + if (bno < 0) + { + diskfs_end_catch_exception (); + return 0; + } + + for (i = 0; i < frags; i++) + clrbit(cg_blksfree(cgp), bno + i); + cgp->cg_cs.cs_nffree -= frags; + sblock->fs_cstotal.cs_nffree -= frags; + csum[cg].cs_nffree -= frags; + cgp->cg_frsum[allocsiz]--; + if (frags != allocsiz) + cgp->cg_frsum[allocsiz - frags]++; + diskfs_end_catch_exception (); + return (u_long) (cg * sblock->fs_fpg + bno); +} + +/* + * Allocate a block in a cylinder group. + * + * This algorithm implements the following policy: + * 1) allocate the requested block. + * 2) allocate a rotationally optimal block in the same cylinder. + * 3) allocate the next available block on the block rotor for the + * specified cylinder group. + * Note that this routine only allocates fs_bsize blocks; these + * blocks may be fragmented by the routine that allocates them. + */ +static daddr_t +alloccgblk(struct cg *cgp, + volatile daddr_t bpref) +{ + daddr_t bno; + int cylno, pos, delta; + short *cylbp; + int i; + daddr_t ret; + + if (diskfs_catch_exception ()) + return 0; + + if (bpref == 0) + { + bpref = cgp->cg_rotor; + goto norot; + } + bpref = blknum(bpref); + bpref = dtogd(bpref); + /* + * if the requested block is available, use it + */ + if (isblock(cg_blksfree(cgp), fragstoblks(bpref))) + { + bno = bpref; + goto gotit; + } + /* + * check for a block available on the same cylinder + */ + cylno = cbtocylno(bpref); + if (cg_blktot(cgp)[cylno] == 0) + goto norot; + if (sblock->fs_cpc == 0) + { + /* + * block layout info is not available, so just have + * to take any block in this cylinder. + */ + bpref = howmany(sblock->fs_spc * cylno, NSPF); + goto norot; + } + /* + * check the summary information to see if a block is + * available in the requested cylinder starting at the + * requested rotational position and proceeding around. + */ + cylbp = cg_blks(cgp, cylno); + pos = cbtorpos(bpref); + for (i = pos; i < sblock->fs_nrpos; i++) + if (cylbp[i] > 0) + break; + if (i == sblock->fs_nrpos) + for (i = 0; i < pos; i++) + if (cylbp[i] > 0) + break; + if (cylbp[i] > 0) + { + /* + * found a rotational position, now find the actual + * block. A panic if none is actually there. + */ + pos = cylno % sblock->fs_cpc; + bno = (cylno - pos) * sblock->fs_spc / NSPB; + assert ("postbl table bad" &&fs_postbl(pos)[i] != -1); + for (i = fs_postbl(pos)[i];; ) + { + if (isblock(cg_blksfree(cgp), bno + i)) + { + bno = blkstofrags(bno + i); + goto gotit; + } + delta = fs_rotbl[i]; + if (delta <= 0 || + delta + i > fragstoblks(sblock->fs_fpg)) + break; + i += delta; + } + assert ("Inconsistent rotbl table" && 0); + } + norot: + /* + * no blocks in the requested cylinder, so take next + * available one in this cylinder group. + */ + bno = mapsearch(cgp, bpref, (int)sblock->fs_frag); + if (bno < 0) + { + diskfs_end_catch_exception (); + return 0; + } + cgp->cg_rotor = bno; + gotit: + clrblock(cg_blksfree(cgp), (long)fragstoblks(bno)); + cgp->cg_cs.cs_nbfree--; + sblock->fs_cstotal.cs_nbfree--; + csum[cgp->cg_cgx].cs_nbfree--; + cylno = cbtocylno(bno); + cg_blks(cgp, cylno)[cbtorpos(bno)]--; + cg_blktot(cgp)[cylno]--; + ret = cgp->cg_cgx * sblock->fs_fpg + bno; + diskfs_end_catch_exception (); + return ret; +} + +/* + * Determine whether an inode can be allocated. + * + * Check to see if an inode is available, and if it is, + * allocate it using the following policy: + * 1) allocate the requested inode. + * 2) allocate the next available inode after the requested + * inode in the specified cylinder group. + */ +static u_long +ialloccg(int cg, + volatile daddr_t ipref, + int modein) +{ + struct cg *cgp; + int start, len, loc, map, i; + mode_t mode = (mode_t) modein; + + if (csum[cg].cs_nifree == 0) + return 0; + + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + + if (diskfs_catch_exception ()) + return 0; + + if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) + { + printf ("Cylinder group %d bad magic number: %ld/%ld\n", + cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); + diskfs_end_catch_exception (); + return 0; + } + cgp->cg_time = diskfs_mtime->seconds; + if (ipref) + { + ipref %= sblock->fs_ipg; + if (isclr(cg_inosused(cgp), ipref)) + goto gotit; + } + start = cgp->cg_irotor / NBBY; + len = howmany(sblock->fs_ipg - cgp->cg_irotor, NBBY); + loc = skpc(0xff, len, (u_char *) &cg_inosused(cgp)[start]); + if (loc == 0) + { + len = start + 1; + start = 0; + loc = skpc(0xff, len, (u_char *) &cg_inosused(cgp)[0]); + assert ("inconsistent cg_inosused table" && loc); + } + i = start + len - loc; + map = cg_inosused(cgp)[i]; + ipref = i * NBBY; + for (i = 1; i < (1 << NBBY); i <<= 1, ipref++) + { + if ((map & i) == 0) + { + cgp->cg_irotor = ipref; + goto gotit; + } + } + assert ("inconsistent cg_inosused table" && 0); + gotit: + setbit(cg_inosused(cgp), ipref); + cgp->cg_cs.cs_nifree--; + sblock->fs_cstotal.cs_nifree--; + csum[cg].cs_nifree--; + if ((mode & IFMT) == IFDIR) + { + cgp->cg_cs.cs_ndir++; + sblock->fs_cstotal.cs_ndir++; + csum[cg].cs_ndir++; + } + diskfs_end_catch_exception (); + return (u_long)(cg * sblock->fs_ipg + ipref); +} + +/* + * Free a block or fragment. + * + * The specified block or fragment is placed back in the + * free map. If a fragment is deallocated, a possible + * block reassembly is checked. + */ +void +blkfree(volatile daddr_t bno, + int size) +{ + struct cg *cgp; + int cg, blk, frags, bbase; + int i; + + assert ("free of bad sized block" &&(unsigned) size <= sblock->fs_bsize + && !fragoff (size)); + cg = dtog(bno); + if ((unsigned)bno >= sblock->fs_size) + { + printf("bad block %ld\n", bno); + return; + } + + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + + spin_lock (&alloclock); + + if (diskfs_catch_exception ()) + { + spin_unlock (&alloclock); + return; + } + + if (!cg_chkmagic(cgp)) + { + spin_unlock (&alloclock); + printf ("Cylinder group %d bad magic number: %ld/%ld\n", + cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); + diskfs_end_catch_exception (); + return; + } + cgp->cg_time = diskfs_mtime->seconds; + bno = dtogd(bno); + if (size == sblock->fs_bsize) + { + assert ("inconsistent cg_blskfree table" + && !isblock (cg_blksfree (cgp), fragstoblks (bno))); + setblock(cg_blksfree(cgp), fragstoblks(bno)); + cgp->cg_cs.cs_nbfree++; + sblock->fs_cstotal.cs_nbfree++; + csum[cg].cs_nbfree++; + i = cbtocylno(bno); + cg_blks(cgp, i)[cbtorpos(bno)]++; + cg_blktot(cgp)[i]++; + } + else + { + bbase = bno - fragnum(bno); + /* + * decrement the counts associated with the old frags + */ + blk = blkmap(cg_blksfree(cgp), bbase); + fragacct(blk, cgp->cg_frsum, -1); + /* + * deallocate the fragment + */ + frags = numfrags(size); + for (i = 0; i < frags; i++) + { + assert ("inconsistent cg_blksfree table" + && !isset (cg_blksfree (cgp), bno + i)); + setbit(cg_blksfree(cgp), bno + i); + } + cgp->cg_cs.cs_nffree += i; + sblock->fs_cstotal.cs_nffree += i; + csum[cg].cs_nffree += i; + /* + * add back in counts associated with the new frags + */ + blk = blkmap(cg_blksfree(cgp), bbase); + fragacct(blk, cgp->cg_frsum, 1); + /* + * if a complete block has been reassembled, account for it + */ + if (isblock(cg_blksfree(cgp), (daddr_t)fragstoblks(bbase))) + { + cgp->cg_cs.cs_nffree -= sblock->fs_frag; + sblock->fs_cstotal.cs_nffree -= sblock->fs_frag; + csum[cg].cs_nffree -= sblock->fs_frag; + cgp->cg_cs.cs_nbfree++; + sblock->fs_cstotal.cs_nbfree++; + csum[cg].cs_nbfree++; + i = cbtocylno(bbase); + cg_blks(cgp, i)[cbtorpos(bbase)]++; + cg_blktot(cgp)[i]++; + } + } + spin_unlock (&alloclock); + diskfs_end_catch_exception (); +} + +/* + * Free an inode. + * + * The specified inode is placed back in the free map. + */ +void +diskfs_free_node(struct node *np, mode_t mode) +{ + struct cg *cgp; + int cg; + volatile int ino = np->dn->number; + + assert ("invalid inode number" && ino < sblock->fs_ipg * sblock->fs_ncg); + + cg = itog(ino); + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + + spin_lock (&alloclock); + if (diskfs_catch_exception ()) + { + spin_unlock (&alloclock); + return; + } + + if (!cg_chkmagic(cgp)) + { + spin_unlock (&alloclock); + printf ("Cylinder group %d bad magic number: %ld/%ld\n", + cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); + diskfs_end_catch_exception (); + return; + } + cgp->cg_time = diskfs_mtime->seconds; + ino %= sblock->fs_ipg; + assert ("inconsistent cg_inosused table" && !isclr (cg_inosused (cgp), ino)); + clrbit(cg_inosused(cgp), ino); + if (ino < cgp->cg_irotor) + cgp->cg_irotor = ino; + cgp->cg_cs.cs_nifree++; + sblock->fs_cstotal.cs_nifree++; + csum[cg].cs_nifree++; + if ((mode & IFMT) == IFDIR) + { + cgp->cg_cs.cs_ndir--; + sblock->fs_cstotal.cs_ndir--; + csum[cg].cs_ndir--; + } + spin_unlock (&alloclock); + diskfs_end_catch_exception (); +} + + +/* + * Find a block of the specified size in the specified cylinder group. + * + * It is a panic if a request is made to find a block if none are + * available. + */ +/* This routine expects to be called from inside a diskfs_catch_exception */ +static daddr_t +mapsearch(struct cg *cgp, + daddr_t bpref, + int allocsiz) +{ + daddr_t bno; + int start, len, loc, i; + int blk, field, subfield, pos; + + /* + * find the fragment by searching through the free block + * map for an appropriate bit pattern + */ + if (bpref) + start = dtogd(bpref) / NBBY; + else + start = cgp->cg_frotor / NBBY; + len = howmany(sblock->fs_fpg, NBBY) - start; + loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[start], + (u_char *)fragtbl[sblock->fs_frag], + (u_char)(1 << (allocsiz - 1 + (sblock->fs_frag % NBBY)))); + if (loc == 0) + { + len = start + 1; + start = 0; + loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[0], + (u_char *)fragtbl[sblock->fs_frag], + (u_char)(1 << (allocsiz - 1 + (sblock->fs_frag % NBBY)))); + assert ("incosistent cg_blksfree table" && loc); + } + bno = (start + len - loc) * NBBY; + cgp->cg_frotor = bno; + /* + * found the byte in the map + * sift through the bits to find the selected frag + */ + for (i = bno + NBBY; bno < i; bno += sblock->fs_frag) + { + blk = blkmap(cg_blksfree(cgp), bno); + blk <<= 1; + field = around[allocsiz]; + subfield = inside[allocsiz]; + for (pos = 0; pos <= sblock->fs_frag - allocsiz; pos++) + { + if ((blk & field) == subfield) + return (bno + pos); + field <<= 1; + subfield <<= 1; + } + } + assert ("inconsistent cg_blksfree table" && 0); +} + + -- cgit v1.2.3 From 8017cc8bfda4b6e5735db0cd2f1c260e4a84e182 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 31 May 1994 15:53:29 +0000 Subject: Formerly Makefile.~24~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 7c3c6ca7..44ae79b6 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -36,7 +36,7 @@ LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) all: ufs -LDFLAGS=--no-keep-memory +LDFLAGS=--no-keep-memory -y_hurd_rlimits -y__hurd_rlimits ufs: $(OBJS) $(LIBS) $(link) -- cgit v1.2.3 From 890a81fa732f4c1e654ca492ef1fdae170c7bdf3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 1 Jun 1994 18:02:51 +0000 Subject: Formerly alloc.c.~10~ --- ufs/alloc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 161edcb8..193e0f31 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -93,7 +93,7 @@ alloc(struct node *np, *bnp = 0; assert ("Alloc of bad sized block" && (unsigned) size <= sblock->fs_bsize - && !fragoff(size)); + && !fragoff(size) && size != 0); spin_lock (&alloclock); @@ -150,9 +150,9 @@ realloccg(struct node *np, *pbn = 0; assert ("bad old size" && (unsigned) osize <= sblock->fs_bsize - && !fragoff (osize)); + && !fragoff (osize) && osize != 0 ); assert ("bad new size" && (unsigned) nsize <= sblock->fs_bsize - && !fragoff (nsize)); + && !fragoff (nsize) && nsize != 0); spin_lock (&alloclock); @@ -273,12 +273,15 @@ diskfs_alloc_node(struct node *dir, *npp = 0; + spin_lock (&alloclock); if (sblock->fs_cstotal.cs_nifree == 0) - goto noinodes; + { + spin_unlock (&alloclock); + goto noinodes; + } if (ipref >= sblock->fs_ncg * sblock->fs_ipg) ipref = 0; cg = itog(ipref); - spin_lock (&alloclock); ino = (int)hashalloc(cg, (long)ipref, mode, ialloccg); spin_unlock (&alloclock); if (ino == 0) @@ -852,7 +855,7 @@ blkfree(volatile daddr_t bno, int i; assert ("free of bad sized block" &&(unsigned) size <= sblock->fs_bsize - && !fragoff (size)); + && !fragoff (size) && size != 0); cg = dtog(bno); if ((unsigned)bno >= sblock->fs_size) { -- cgit v1.2.3 From d3e07ca3f3efa6afef110b527993bf28cfe48a89 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 2 Jun 1994 17:21:37 +0000 Subject: Initial revision --- ufs/main.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 ufs/main.c diff --git a/ufs/main.c b/ufs/main.c new file mode 100644 index 00000000..8c6114ed --- /dev/null +++ b/ufs/main.c @@ -0,0 +1,181 @@ +/* + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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 "ufs.h" +#include "fs.h" +#include +#include +#include +#include + +char *ufs_version = "0.0 pre-alpha"; + +mach_port_t diskfs_dotdot_file; +static char **save_argv; + +/* Parse the arguments for ufs when started as a translator. */ +char * +trans_parse_args (int argc, char **arg) +{ + #ifdef notyet + /* When started as a translator, we are called with + the device name and an optional argument -r, which + signifies read-only. */ + if (argc < 2 || argc > 3) + usage_trans (); + if (argc == 2) + devname = argv[1]; + else if (argc == 3) + { + if (argv[1][0] == '-' && argv[1][1] == 'r') + { + diskfs_readonly = 1; + devname = argv[2]; + } + else if (argv[2][0] == '-' && argv[2][1] == 'r') + { + diskfs_readonly = 1; + devname = argv[1]; + } + else + usage_trans (); + } + + get_privileged_ports (&host_priv_port, &master_device_port); + if (!master_device_port) + { + fprintf (stderr, "%s: Cannot get master device port\n", + argv[0]); + exit (1); + } + /* We only need the host port if we are a bootstrap filesystem. */ + if (host_priv_port) + mach_port_deallocate (mach_task_self (), host_priv_port); + + mach_port_insert_right (mach_task_self (), ufs_control_port, + ufs_control_port, MACH_MSG_TYPE_MAKE_SEND); + fsys_startup (bootstrap, ufs_control_port, &ufs_realnode, + &diskfs_dotdot_file); + mach_port_deallocate (mach_task_self (), ufs_control_port); +#else + task_terminate (mach_task_self ()); + for (;;); +#endif +} + +struct node *diskfs_root_node; + +/* Set diskfs_root_node to the root inode. */ +static void +warp_root (void) +{ + error_t err; + err = iget (2, &diskfs_root_node); + assert (!err); + mutex_unlock (&diskfs_root_node->lock); +} + +/* XXX */ +struct mutex printf_lock; +int printf (const char *fmt, ...) +{ + va_list arg; + int done; + va_start (arg, fmt); + mutex_lock (&printf_lock); + done = vprintf (fmt, arg); + mutex_unlock (&printf_lock); + va_end (arg); + return done; +} + +int diskfs_readonly; + +void +main (int argc, char **argv) +{ + char *devname; + mach_port_t bootstrap; + error_t err; + + save_argv = argv; + + mutex_init (&printf_lock); /* XXX */ + + task_get_bootstrap_port (mach_task_self (), &bootstrap); + + if (bootstrap) + devname = trans_parse_args (argc, argv); + else + { + devname = diskfs_parse_bootargs (argc, argv); + diskfs_dotdot_file = MACH_PORT_NULL; + } + + diskfs_init_diskfs (); + + err = device_open (diskfs_master_device, + (diskfs_readonly ? 0 : D_WRITE) | D_READ, + devname, &ufs_device); + assert (!err); + + get_hypermetadata (); + + if (!diskfs_readonly) + { + sblock->fs_clean = 0; + strcpy (sblock->fs_fsmnt, "Hurd /"); + sblock_dirty = 1; + diskfs_set_hypermetadata (1, 0); + } + + inode_init (); + pager_init (); + + diskfs_spawn_first_thread (); + + warp_root (); + + if (!bootstrap) + diskfs_start_bootstrap (); + + diskfs_main_request_loop (); +} + + +void +diskfs_init_completed () +{ + mach_port_t proc, startup; + error_t err; + + _hurd_proc_init (save_argv); + proc = getproc(); + proc_register_version (proc, diskfs_host_priv, "ufs", HURD_RELEASE, + ufs_version); + err = proc_getmsgport (proc, 1, &startup); + if (!err) + { + startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL, + "ufs", diskfs_host_priv); + mach_port_deallocate (mach_task_self (), startup); + } + mach_port_deallocate (mach_task_self (), proc); +} + + -- cgit v1.2.3 From 423954be7b659e3f2b8cf6fde12dbd8947875161 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 2 Jun 1994 17:31:45 +0000 Subject: Formerly hyper.c.~5~ --- ufs/hyper.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index bd58b7e4..7bb8d7c8 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -72,22 +72,42 @@ diskfs_set_hypermetadata (int wait, int clean) error_t (*writefn) (daddr_t, vm_address_t, long); writefn = (wait ? dev_write_sync : dev_write); - (*writefn)(fsbtodb (sblock->fs_csaddr), (vm_address_t) csum, - sblock->fs_fsize * howmany (sblock->fs_cssize, - sblock->fs_fsize)); + spin_lock (&alloclock); + if (csum_dirty) + { + (*writefn)(fsbtodb (sblock->fs_csaddr), (vm_address_t) csum, + sblock->fs_fsize * howmany (sblock->fs_cssize, + sblock->fs_fsize)); + csum_dirty = 0; + } if (clean) - sblock->fs_clean = 1; - if (sblock->fs_postblformat == FS_42POSTBLFMT) { - char sblockcopy[SBSIZE]; - bcopy (sblock, sblockcopy, SBSIZE); - ((struct fs *)sblockcopy)->fs_nrpos = -1; - (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); + sblock->fs_clean = 1; + sblock_dirty = 1; + } + + if (sblock_dirty) + { + if (sblock->fs_postblformat == FS_42POSTBLFMT) + { + char sblockcopy[SBSIZE]; + bcopy (sblock, sblockcopy, SBSIZE); + ((struct fs *)sblockcopy)->fs_nrpos = -1; + (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); + } + else + (*writefn) (SBLOCK, (vm_address_t) sblock, SBSIZE); + sblock_dirty = 0; } - else - (*writefn) (SBLOCK, (vm_address_t) sblock, SBSIZE); - sblock->fs_clean = 0; + + if (clean) + { + sblock->fs_clean = 0; + sblock_dirty = 1; + } + + spin_unlock (&alloclock); } -- cgit v1.2.3 From 0325d858a8b0d685250ee224ac2283eedbff0e6f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 Jun 1994 16:59:49 +0000 Subject: Formerly Makefile.~25~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 44ae79b6..7c3c6ca7 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -36,7 +36,7 @@ LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) all: ufs -LDFLAGS=--no-keep-memory -y_hurd_rlimits -y__hurd_rlimits +LDFLAGS=--no-keep-memory ufs: $(OBJS) $(LIBS) $(link) -- cgit v1.2.3 From fd3e546dd6c0c41553f0073fb877e06921d2cdfa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 Jun 1994 17:18:08 +0000 Subject: Initial revision --- ufs/sizes.c | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+) create mode 100644 ufs/sizes.c diff --git a/ufs/sizes.c b/ufs/sizes.c new file mode 100644 index 00000000..d8429fcc --- /dev/null +++ b/ufs/sizes.c @@ -0,0 +1,474 @@ +/* File growth and truncation + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "ufs.h" +#include "fs.h" +#include "dinode.h" + +#ifdef DONT_CACHE_MEMORY_OBJECTS +#define MAY_CACHE 0 +#else +#define MAY_CACHE 1 +#endif + +static void dindir_drop (struct node *); +static void sindir_drop (struct node *, int, int); +static void poke_pages (memory_object_t, vm_offset_t, vm_offset_t); + +/* Truncate node NP to be at most LENGTH bytes. */ +/* The inode must be locked, and we must have the conch. */ +/* This is a pain. Sigh. */ +error_t +diskfs_truncate (struct node *np, + off_t length) +{ + daddr_t lastblock, olastblock, bn; + off_t osize; + int bsize, idx; + mach_port_t obj; + + osize = np->dn_stat.st_size; + if (length >= osize) + return 0; + + /* Calculate block number of last block */ + lastblock = lblkno (length + sblock->fs_bsize - 1) - 1; + olastblock = lblkno (osize + sblock->fs_bsize - 1) - 1; + + /* If the prune is not to a block boundary, zero the bit upto the + next block boundary. */ + if (blkoff (length)) + diskfs_node_rdwr (np, (void *) zeroblock, length, + blksize (np, lastblock) - blkoff (length), 1, 0, 0); + + /* We are going to throw away the block pointers for the blocks + olastblock+1 through lastblock. This will cause the underlying + data to become zeroes, because of the behavior of pager_read_page + (in ufs/pager.c). Consequently, we have to take action to force + the kernel to immediately undertake any delayed copies that + implicitly depend on the data we are flushing. We also have to + prevent any new delayed copies from being undertaken until we + have finished the flush. */ + if (np->dn->fileinfo) + { + pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, + MEMORY_OBJECT_COPY_NONE, 1); + obj = diskfs_get_filemap (np); + mach_port_insert_right (mach_task_self (), obj, obj, + MACH_MSG_TYPE_MAKE_SEND); + poke_pages (obj, round_page (length), round_page (osize)); + mach_port_deallocate (mach_task_self (), obj); + } + + mutex_lock (&np->dn->datalock); + + /* Update the size now. If we crash, fsck can finish freeing the + blocks. */ + np->dn_stat.st_size = length; + np->dn_stat_dirty = 1; + + /* Flush the old data. */ + if (np->dn->fileinfo) + pager_flush_some (np->dn->fileinfo->p, + (lastblock == -1 ? 0 : lastblock) * sblock->fs_bsize, + (olastblock - lastblock) * sblock->fs_bsize, 1); + + /* Drop data blocks mapped by indirect blocks */ + if (olastblock >= NDADDR) + { + daddr_t first2free; + + if (!np->dn->sinloc) + sin_map (np); + + if (lastblock + 1 > NDADDR) + first2free = lastblock + 1; + else + first2free = NDADDR; + + for (idx = first2free; idx <= olastblock; idx ++) + { + if (np->dn->sinloc[idx - NDADDR]) + { + blkfree (np->dn->sinloc[idx - NDADDR], sblock->fs_bsize); + np->dn->sinloc[idx - NDADDR] = 0; + np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; + np->dn_stat_dirty = 1; + } + } + + /* Prune the block pointers handled by the sindir pager. This will + free all the indirect blocks and such as necessary. */ + sindir_drop (np, lblkno((first2free - NDADDR) * sizeof (daddr_t)), + lblkno ((olastblock - NDADDR) * sizeof (daddr_t))); + + if (!np->dn->fileinfo) + sin_unmap (np); + } + + /* Prune the blocks mapped directly from the inode */ + for (idx = lastblock + 1; idx < NDADDR; idx++) + { + bn = dinodes[np->dn->number].di_db[idx]; + if (bn) + { + dinodes[np->dn->number].di_db[idx] = 0; + assert (idx <= olastblock); + if (idx == olastblock) + bsize = blksize (np, idx); + else + bsize = sblock->fs_bsize; + blkfree (bn, bsize); + np->dn_stat.st_blocks -= bsize / DEV_BSIZE; + np->dn_stat_dirty = 1; + } + } + + if (lastblock >= 0 && lastblock < NDADDR) + { + /* Look for a change in the size of the last direct block */ + bn = dinodes[np->dn->number].di_db[lastblock]; + if (bn) + { + off_t oldspace, newspace; + + oldspace = blksize (np, lastblock); + newspace = fragroundup (blkoff (length));; + assert (newspace); + if (oldspace - newspace) + { + bn += numfrags (newspace); + blkfree (bn, oldspace - newspace); + np->dn_stat.st_blocks -= (oldspace - newspace) / DEV_BSIZE; + np->dn_stat_dirty = 1; + } + } + } + + if (lastblock < NDADDR) + np->allocsize = fragroundup (length); + else + np->allocsize = blkroundup (length); + + mutex_unlock (&np->dn->datalock); + + /* Now we can allow delayed copies again */ + if (np->dn->fileinfo) + pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, + MEMORY_OBJECT_COPY_DELAY, 0); + + diskfs_file_update (np, 1); + return 0; +} + +/* Deallocate the double indirect block of the file NP. */ +static void +dindir_drop (struct node *np) +{ + mutex_lock (&np->dn->dinlock); + + pager_flush_some (dinpager->p, np->dn->number * sblock->fs_bsize, + sblock->fs_bsize, 1); + + if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE]) + { + blkfree (dinodes[np->dn->number].di_ib[INDIR_DOUBLE], sblock->fs_bsize); + dinodes[np->dn->number].di_ib[INDIR_DOUBLE] = 0; + np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; + } + + mutex_unlock (&np->dn->dinlock); +} + + +/* Deallocate the single indirect blocks of file IP from + FIRST through LAST inclusive. */ +static void +sindir_drop (struct node *np, + int first, + int last) +{ + int idx; + + mutex_lock (&np->dn->sinlock); + + pager_flush_some (np->dn->sininfo->p, first * sblock->fs_bsize, + (last - first + 1) * sblock->fs_bsize, 1); + + /* Drop indirect blocks found in the double indirect block */ + if (last > 1) + { + if (!np->dn->dinloc) + din_map (np); + for (idx = first; idx = last; idx++) + { + if (np->dn->dinloc[idx - 1]) + { + blkfree (np->dn->dinloc[idx - 1], sblock->fs_bsize); + np->dn->dinloc[idx - 1] = 0; + np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; + } + } + + /* If we no longer need the double indirect block, drop it. */ + if (first <= 1) + dindir_drop (np); + if (!np->dn->sininfo) + din_unmap (np); + } + + /* Drop the block from the inode if we don't need it any more */ + if (first == 0 && dinodes[np->dn->number].di_ib[INDIR_SINGLE]) + { + blkfree (dinodes[np->dn->number].di_ib[INDIR_SINGLE], sblock->fs_bsize); + dinodes[np->dn->number].di_ib[INDIR_SINGLE] = 0; + np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; + } + mutex_unlock (&np->dn->sinlock); +} + +/* Write something to each page from START to END inclusive of memory + object OBJ, but make sure the data doesns't actually change. */ +static void +poke_pages (memory_object_t obj, + vm_offset_t start, + vm_offset_t end) +{ + vm_address_t addr, poke; + vm_size_t len; + error_t err; + + while (start < end) + { + len = 8 * vm_page_size; + if (len > end - start) + len = end - start; + addr = 0; + err = vm_map (mach_task_self (), &addr, len, 0, 1, obj, start, 0, + VM_PROT_WRITE|VM_PROT_READ, VM_PROT_READ|VM_PROT_WRITE, 0); + if (!err) + { + for (poke = addr; poke < addr + len; poke += vm_page_size) + *(volatile int *)poke = *(volatile int *)poke; + vm_deallocate (mach_task_self (), addr, len); + } + start += len; + } +} + + +/* Implement the diskfs_grow callback; see for the + interface description. */ +error_t +diskfs_grow (struct node *np, + off_t end, + struct protid *cred) +{ + daddr_t lbn, pbn, nb; + int osize, size; + int err; + volatile daddr_t dealloc_on_error = 0; + volatile int dealloc_size = 0; + volatile off_t zero_off1 = 0, zero_off2 = 0; + volatile int zero_len1 = 0, zero_len2 = 0; + volatile off_t poke_off1 = 0, poke_off2 = 0; + volatile off_t poke_len1 = 0, poke_len2 = 0; + vm_address_t zerobuf; + + if (end <= np->allocsize) + return 0; + + mutex_lock (&np->dn->datalock); + + /* This deallocation works for the calls to alloc, but not for + realloccg. I'm not sure how to prune the fragment down, especially if + we grew a fragment and then couldn't allocate the piece later. + freeing it all up is a royal pain, largely punted right now... -mib. + */ + if (err = diskfs_catch_exception()) + { + if (dealloc_on_error) + blkfree (dealloc_on_error, dealloc_size); + goto out; + } + + /* This is the logical block number of what will be the last block. */ + lbn = lblkno (end + sblock->fs_bsize - 1) - 1; + + /* This is the size to be of that block if it is in the NDADDR array. */ + size = fragroundup (blkoff (end)); + if (size == 0) + size = sblock->fs_bsize; + + /* if we are writing a new block, then an old one may need to be + reallocated into a full block. */ + + nb = lblkno (np->allocsize + sblock->fs_bsize - 1) - 1; + if (np->allocsize && nb < NDADDR && nb < lbn) + { + osize = blksize (np, nb); + if (osize < sblock->fs_bsize && osize > 0) + { + daddr_t old_pbn; + err = realloccg (np, nb, + blkpref (np, nb, (int)nb, + dinodes[np->dn->number].di_db), + osize, sblock->fs_bsize, &pbn, cred); + if (err) + goto out; + np->allocsize = (nb + 1) * sblock->fs_bsize; + old_pbn = dinodes[np->dn->number].di_db[nb]; + dinodes[np->dn->number].di_db[nb] = pbn; + + /* The new disk blocks should be zeros but might not be. + This is a sanity measure that I'm not sure is necessary. */ + zero_off1 = nb * sblock->fs_bsize + osize; + zero_len1 = nb * sblock->fs_bsize + sblock->fs_bsize - zero_off1; + + if (pbn != old_pbn) + { + /* Make sure that the old contents get written out by + poking the pages. */ + poke_off1 = nb * sblock->fs_bsize; + poke_len1 = osize; + } + } + } + + /* allocate this block */ + if (lbn < NDADDR) + { + nb = dinodes[np->dn->number].di_db[lbn]; + + if (nb != 0) + { + /* consider need to reallocate a fragment. */ + osize = blkoff (np->allocsize); + if (osize == 0) + osize = sblock->fs_bsize; + if (size > osize) + { + err = realloccg (np, lbn, + blkpref (np, lbn, lbn, + dinodes[np->dn->number].di_db), + osize, size, &pbn, cred); + if (err) + goto out; + dinodes[np->dn->number].di_db[lbn] = pbn; + + /* The new disk blocks should be zeros but might not be. + This is a sanity measure that I'm not sure is necessary. */ + zero_off2 = lbn * sblock->fs_bsize + osize; + zero_len2 = lbn * sblock->fs_bsize + size - zero_off2; + + if (pbn != nb) + { + /* Make sure that the old contents get written out by + poking the pages. */ + poke_off2 = lbn * sblock->fs_bsize; + poke_len2 = osize; + } + } + } + else + { + err = alloc (np, lbn, + blkpref (np, lbn, lbn, dinodes[np->dn->number].di_db), + size, &pbn, cred); + if (err) + goto out; + dealloc_on_error = pbn; + dealloc_size = size; + dinodes[np->dn->number].di_db[lbn] = pbn; + } + np->allocsize = fragroundup (end); + } + else + { + /* Make user the sindir area is mapped at the right size. */ + if (np->dn->sinloc) + { + sin_remap (np, end); + np->allocsize = blkroundup (end); + } + else + { + np->allocsize = blkroundup (end); + sin_map (np); + } + + lbn -= NDADDR; + if (!np->dn->sinloc[lbn]) + { + err = alloc (np, lbn, blkpref (np, lbn + NDADDR, lbn, + np->dn->sinloc), + sblock->fs_bsize, &pbn, cred); + if (err) + goto out; + dealloc_on_error = pbn; + dealloc_size = sblock->fs_bsize; + np->dn->sinloc[lbn] = pbn; + } + if (!np->dn->fileinfo) + sin_unmap (np); + } + + if (np->conch.holder) + ioserver_put_shared_data (np->conch.holder); + + out: + diskfs_end_catch_exception (); + mutex_unlock (&np->dn->datalock); + + /* Do the pokes and zeros that we requested before; they have to be + done here because we can't cause a page while holding datalock. */ + if (zero_len1 || zero_len2) + { + vm_allocate (mach_task_self (), &zerobuf, + zero_len1 > zero_len2 ? zero_len1 : zero_len2, 1); + if (zero_len1) + diskfs_node_rdwr (np, (char *) zerobuf, zero_off1, + zero_len1, 1, cred, 0); + if (zero_len2) + diskfs_node_rdwr (np, (char *) zerobuf, zero_off2, + zero_len2, 1, cred, 0); + vm_deallocate (mach_task_self (), zerobuf, + zero_len1 > zero_len2 ? zero_len1 : zero_len2); + } + if (poke_len1 || poke_len2) + { + mach_port_t obj; + obj = diskfs_get_filemap (np); + mach_port_insert_right (mach_task_self (), obj, obj, + MACH_MSG_TYPE_MAKE_SEND); + if (poke_len1) + poke_pages (obj, trunc_page (poke_off1), + round_page (poke_off1 + poke_len1)); + if (poke_len2) + poke_pages (obj, trunc_page (poke_off2), + round_page (poke_off2 + poke_len2)); + mach_port_deallocate (mach_task_self (), obj); + } + + diskfs_file_update (np, 0); + + return err; +} -- cgit v1.2.3 From d299e41b9211411f4e9d8a9c1f258752ecd55887 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 13 Jun 1994 19:30:36 +0000 Subject: Formerly sizes.c.~14~ --- ufs/sizes.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index d8429fcc..423c13bb 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -78,7 +78,7 @@ diskfs_truncate (struct node *np, mach_port_deallocate (mach_task_self (), obj); } - mutex_lock (&np->dn->datalock); + rwlock_writer_lock (&np->dn->datalock, np->dn); /* Update the size now. If we crash, fsck can finish freeing the blocks. */ @@ -96,6 +96,7 @@ diskfs_truncate (struct node *np, { daddr_t first2free; + mutex_lock (&sinmaplock); if (!np->dn->sinloc) sin_map (np); @@ -122,6 +123,7 @@ diskfs_truncate (struct node *np, if (!np->dn->fileinfo) sin_unmap (np); + mutex_unlock (&sinmaplock); } /* Prune the blocks mapped directly from the inode */ @@ -168,7 +170,7 @@ diskfs_truncate (struct node *np, else np->allocsize = blkroundup (length); - mutex_unlock (&np->dn->datalock); + rwlock_writer_unlock (&np->dn->datalock, np->dn); /* Now we can allow delayed copies again */ if (np->dn->fileinfo) @@ -183,7 +185,7 @@ diskfs_truncate (struct node *np, static void dindir_drop (struct node *np) { - mutex_lock (&np->dn->dinlock); + rwlock_writer_lock (&np->dn->dinlock, np->dn); pager_flush_some (dinpager->p, np->dn->number * sblock->fs_bsize, sblock->fs_bsize, 1); @@ -195,7 +197,7 @@ dindir_drop (struct node *np) np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; } - mutex_unlock (&np->dn->dinlock); + rwlock_writer_unlock (&np->dn->dinlock, np->dn); } @@ -208,7 +210,7 @@ sindir_drop (struct node *np, { int idx; - mutex_lock (&np->dn->sinlock); + rwlock_writer_lock (&np->dn->sinlock, np->dn); pager_flush_some (np->dn->sininfo->p, first * sblock->fs_bsize, (last - first + 1) * sblock->fs_bsize, 1); @@ -216,6 +218,7 @@ sindir_drop (struct node *np, /* Drop indirect blocks found in the double indirect block */ if (last > 1) { + mutex_lock (&dinmaplock); if (!np->dn->dinloc) din_map (np); for (idx = first; idx = last; idx++) @@ -231,8 +234,11 @@ sindir_drop (struct node *np, /* If we no longer need the double indirect block, drop it. */ if (first <= 1) dindir_drop (np); + + mutex_lock (&dinmaplock); if (!np->dn->sininfo) din_unmap (np); + mutex_unlock (&dinmaplock); } /* Drop the block from the inode if we don't need it any more */ @@ -242,7 +248,7 @@ sindir_drop (struct node *np, dinodes[np->dn->number].di_ib[INDIR_SINGLE] = 0; np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; } - mutex_unlock (&np->dn->sinlock); + rwlock_writer_unlock (&np->dn->sinlock, np->dn); } /* Write something to each page from START to END inclusive of memory @@ -296,7 +302,7 @@ diskfs_grow (struct node *np, if (end <= np->allocsize) return 0; - mutex_lock (&np->dn->datalock); + rwlock_writer_lock (&np->dn->datalock, np->dn); /* This deallocation works for the calls to alloc, but not for realloccg. I'm not sure how to prune the fragment down, especially if @@ -404,6 +410,7 @@ diskfs_grow (struct node *np, else { /* Make user the sindir area is mapped at the right size. */ + mutex_lock (&sinmaplock); if (np->dn->sinloc) { sin_remap (np, end); @@ -429,6 +436,7 @@ diskfs_grow (struct node *np, } if (!np->dn->fileinfo) sin_unmap (np); + mutex_unlock (&sinmaplock); } if (np->conch.holder) @@ -436,7 +444,7 @@ diskfs_grow (struct node *np, out: diskfs_end_catch_exception (); - mutex_unlock (&np->dn->datalock); + rwlock_writer_unlock (&np->dn->datalock, np->dn); /* Do the pokes and zeros that we requested before; they have to be done here because we can't cause a page while holding datalock. */ -- cgit v1.2.3 From db845bd31c563c05c718392a4de0d0900308a77c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 14 Jun 1994 18:41:03 +0000 Subject: Initial revision --- ufs/ufs.h | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 ufs/ufs.h diff --git a/ufs/ufs.h b/ufs/ufs.h new file mode 100644 index 00000000..920134ef --- /dev/null +++ b/ufs/ufs.h @@ -0,0 +1,231 @@ +/* + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include +#include +#include +#include +#include + +/* 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. */ + +/* #undef DONT_CACHE_MEMORY_OBJECTS */ + + +/* Simple reader/writer lock. */ +struct rwlock +{ + int readers; + int writers_waiting; + int readers_waiting; +}; + +struct disknode +{ + ino_t number; + + /* For a directory, this array holds the number of directory entries in + each DIRBLKSIZE piece of the directory. */ + int *dirents; + + /* Links on hash list. */ + struct node *hnext, **hprevp; + + struct mutex rwlock_master; + struct condition rwlock_wakeup; + + struct rwlock dinlock; /* locks INDIR_DOUBLE pointer */ + + /* sinlock locks INDIR_SINGLE pointer and all the pointers in + the double indir block. */ + struct rwlock sinlock; + + /* datalock locks all the direct block pointers and all the pointers + in all the single indir blocks */ + struct rwlock datalock; + + /* These pointers are locked by sinmaplock and dinmaplock for all nodes. */ + daddr_t *dinloc; + daddr_t *sinloc; + + /* These two pointers are locked by pagernplock in pager.c for + all nodes. */ + struct user_pager_info *sininfo; + struct user_pager_info *fileinfo; +}; + +/* Get a reader lock on reader-writer lock LOCK for disknode DN */ +extern inline void +rwlock_reader_lock (struct rwlock *lock, + struct disknode *dn) +{ + mutex_lock (&dn->rwlock_master); + if (lock->readers == -1 || lock->writers_waiting) + { + lock->readers_waiting++; + do + condition_wait (&dn->rwlock_wakeup, &dn->rwlock_master); + while (lock->readers == -1 || lock->writers_waiting); + lock->readers_waiting--; + } + lock->readers++; + mutex_unlock (&dn->rwlock_master); +} + +/* Get a writer lock on reader-writer lock LOCK for disknode DN */ +extern inline void +rwlock_writer_lock (struct rwlock *lock, + struct disknode *dn) +{ + mutex_lock (&dn->rwlock_master); + if (lock->readers) + { + lock->writers_waiting++; + do + condition_wait (&dn->rwlock_wakeup, &dn->rwlock_master); + while (lock->readers); + lock->writers_waiting--; + } + lock->readers = -1; + mutex_unlock (&dn->rwlock_master); +} + +/* Release a reader lock on reader-writer lock LOCK for disknode DN */ +extern inline void +rwlock_reader_unlock (struct rwlock *lock, + struct disknode *dn) +{ + mutex_lock (&dn->rwlock_master); + assert (lock->readers); + lock->readers--; + if (lock->readers_waiting || lock->writers_waiting) + condition_broadcast (&dn->rwlock_wakeup); + mutex_unlock (&dn->rwlock_master); +} + +/* Release a writer lock on reader-writer lock LOCK for disknode DN */ +extern inline void +rwlock_writer_unlock (struct rwlock *lock, + struct disknode *dn) +{ + mutex_lock (&dn->rwlock_master); + assert (lock->readers == -1); + lock->readers = 0; + if (lock->readers_waiting || lock->writers_waiting) + condition_broadcast (&dn->rwlock_wakeup); + mutex_unlock (&dn->rwlock_master); +} + +/* Initialize reader-writer lock LOCK */ +extern inline void +rwlock_init (struct rwlock *lock) +{ + lock->readers = 0; + lock->readers_waiting = 0; + lock->writers_waiting = 0; +} + +struct user_pager_info +{ + struct node *np; + enum pager_type + { + DINODE, + CG, + SINDIR, + DINDIR, + FILE_DATA, + } type; + struct pager *p; + struct user_pager_info *next, **prevp; +}; + +struct user_pager_info *dinpager, *dinodepager, *cgpager; + +vm_address_t zeroblock; + +struct fs *sblock; +struct dinode *dinodes; +vm_address_t cgs; +struct csum *csum; +int sblock_dirty; +int csum_dirty; +spin_lock_t alloclock; + +struct mutex dinmaplock; +struct mutex sinmaplock; + +spin_lock_t gennumberlock; +int nextgennumber; + +mach_port_t ufs_device; + +#define DEV_BSIZE 512 +#define NBBY 8 +#define btodb(n) ((n) / DEV_BSIZE) +#define howmany(x,y) (((x)+((y)-1))/(y)) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define isclr(a, i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +#define isset(a, i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<(i)%NBBY)) + +/* From alloc.c: */ +error_t alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, + struct protid *); +void blkfree(volatile daddr_t bno, int size); +daddr_t blkpref (struct node *, daddr_t, int, daddr_t *); +error_t realloccg(struct node *, daddr_t, daddr_t, + int, int, daddr_t *, struct protid *); + +/* From devio.c: */ +error_t dev_write_sync (daddr_t addr, vm_address_t data, long len); +error_t dev_write (daddr_t addr, vm_address_t data, long len); +error_t dev_read_sync (daddr_t addr, vm_address_t *data, long len); + +/* From hyper.c: */ +void get_hypermetadata (void); + +/* From inode.c: */ +error_t iget (ino_t ino, struct node **NP); +struct node *ifind (ino_t ino); +void inode_init (void); +void write_all_disknodes (void); + +/* From pager.c: */ +void sync_dinode (struct node *, int); +void pager_init (void); +void din_map (struct node *); +void sin_map (struct node *); +void sin_remap (struct node *, int); +void sin_unmap (struct node *); +void din_unmap (struct node *); +void drop_pager_softrefs (struct node *); +void allow_pager_softrefs (struct node *); + +/* From subr.c: */ +void fragacct (int, long [], int); +int isblock(u_char *, daddr_t); +void clrblock(u_char *, daddr_t); +void setblock (u_char *, daddr_t); +int skpc (u_char, u_int, u_char *); +int scanc (u_int, u_char *, u_char [], u_char); -- cgit v1.2.3 From 4d7139cd7fc0425f9bd6fe11bf1e695ad39f04d4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 15 Jun 1994 20:52:03 +0000 Subject: Formerly main.c.~11~ --- ufs/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index 8c6114ed..e47586e7 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -112,6 +112,9 @@ main (int argc, char **argv) char *devname; mach_port_t bootstrap; error_t err; + int sizes[DEV_GET_SIZE_COUNT]; + u_int sizescnt = 2; + save_argv = argv; @@ -133,9 +136,31 @@ main (int argc, char **argv) (diskfs_readonly ? 0 : D_WRITE) | D_READ, devname, &ufs_device); assert (!err); + + /* Check to make sure device sector size is reasonable. */ + err = device_get_status (ufs_device, DEV_GET_SIZE, sizes, &sizescnt); + assert (sizescnt == DEV_GET_SIZE_COUNT); + if (sizes[DEV_GET_SIZE_RECORD_SIZE] != DEV_BSIZE) + { + fprintf (stderr, "Bad device record size %d (should be %d)\n", + sizes[DEV_GET_SIZE_RECORD_SIZE], DEV_BSIZE); + exit (1); + } get_hypermetadata (); + /* Check to make sure device size is big enough. */ + if (sizes[DEV_GET_SIZE_DEVICE_SIZE] != 0) + if (sizes[DEV_GET_SIZE_DEVICE_SIZE] < sblock->fs_size * sblock->fs_fsize) + { + fprintf (stderr, + "Disk size %d less than necessary " + "(superblock says we need %ld)\n", + sizes[DEV_GET_SIZE_DEVICE_SIZE], + sblock->fs_size * sblock->fs_fsize); + exit (1); + } + if (!diskfs_readonly) { sblock->fs_clean = 0; -- cgit v1.2.3 From 735ed03306704d983307ab206b5debbe048821c1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 Jun 1994 16:34:45 +0000 Subject: Formerly Maketools.~17~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 6e06d76a..21fb722b 100644 --- a/=Maketools +++ b/=Maketools @@ -29,7 +29,7 @@ endif CC=gcc $(CCTYPE) -O2 MIGHOSTCC= gcc $(MIGHOSTCCTYPE) -O2 ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=rsh $(mighost) cd `pwd` \; /usr/local/lib/migcom +MIGCOM=rsh $(mighost) cd `pwd` \; umask `umask` \; /usr/local/lib/migcom else MIGCOM=/usr/local/lib/migcom endif -- cgit v1.2.3 From 587914c286702cf49c920a60cfc06c7bdbbe7baf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 20 Jun 1994 19:03:09 +0000 Subject: Formerly Maketools.~18~ --- =Maketools | 1 + 1 file changed, 1 insertion(+) diff --git a/=Maketools b/=Maketools index 21fb722b..0e28d4c5 100644 --- a/=Maketools +++ b/=Maketools @@ -41,5 +41,6 @@ MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(ccdir)/ld -L$(ccdir) +INSTALL_BIN=$(tooldir)/objcopy -S machine := i386 -- cgit v1.2.3 From d848579f1211898689ea6925b771ee0903d91183 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 20 Jun 1994 22:07:14 +0000 Subject: Formerly Maketools.~19~ --- =Maketools | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 0e28d4c5..77243782 100644 --- a/=Maketools +++ b/=Maketools @@ -41,6 +41,9 @@ MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(ccdir)/ld -L$(ccdir) -INSTALL_BIN=$(tooldir)/objcopy -S + +# objcopy zeroes the exec header, so we can't do this. +#INSTALL_BIN=$(tooldir)/objcopy -S +INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From 7efd71c161dd5fd099ec65db51c4b6fe972ffe90 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 21 Jun 1994 17:44:54 +0000 Subject: Initial revision --- ufs/dir.c | 861 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 861 insertions(+) create mode 100644 ufs/dir.c diff --git a/ufs/dir.c b/ufs/dir.c new file mode 100644 index 00000000..d088778e --- /dev/null +++ b/ufs/dir.c @@ -0,0 +1,861 @@ +/* Directory management routines + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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 "ufs.h" +#include "dir.h" + +#include +#include + +enum slot_status +{ + /* This means we haven't yet found room for a new entry. */ + LOOKING, + + /* This means that the specified entry is free and should be used. */ + TAKE, + + /* This means that the specified entry has enough room at the end + to hold the new entry. */ + SHRINK, + + /* This means that there is enough space in the block, but not in + any one single entry, so they all have to be shifted to make + room. */ + COMPRESS, + + /* This means that the directory will have to be grown to hold the + entry. */ + EXTEND, + + /* For removal and rename, this means that this is the location + of the entry found. */ + HERE_TIS, +}; + +struct dirstat +{ + /* Type of followp operation expected */ + enum lookup_type type; + + /* One of the statuses above */ + enum slot_status stat; + + /* Mapped address and length of directory */ + vm_address_t mapbuf; + vm_size_t mapextent; + + /* Index of this directory block. */ + int idx; + + /* For stat COMPRESS, this is the address (inside mapbuf) + of the first direct in the directory block to be compressed. */ + /* For stat HERE_TIS, SHRINK, and TAKE, this is the entry referenced. */ + struct direct *entry; + + /* For stat HERE_TIS, type REMOVE, this is the address of the immediately + previous direct in this directory block, or zero if this is the first. */ + struct direct *preventry; +}; + +size_t diskfs_dirstat_size = sizeof (struct dirstat); + +static error_t +dirscanblock (vm_address_t blockoff, struct node *dp, int idx, char *name, + int namelen, enum lookup_type type, struct dirstat *ds, + ino_t *inum); + +/* Implement the diskfs_lookup from the diskfs library. See + for the interface specification. */ +error_t +diskfs_lookup (struct node *dp, char *name, enum lookup_type type, + struct node **npp, struct dirstat *ds, struct protid *cred) +{ + error_t err; + ino_t inum; + int namelen; + int spec_dotdot; + struct node *np = 0; + int retry_dotdot = 0; + memory_object_t memobj; + vm_address_t buf; + vm_size_t buflen; + int blockaddr; + int idx; + + if (npp) + *npp = 0; + + spec_dotdot = type & SPEC_DOTDOT; + type &= ~SPEC_DOTDOT; + + namelen = strlen (name); + + if (!S_ISDIR (dp->dn_stat.st_mode)) + return ENOTDIR; + err = diskfs_access (dp, S_IEXEC, cred); + if (err) + return err; + + try_again: + if (ds) + { + ds->type = LOOKUP; + ds->mapbuf = 0; + ds->mapextent = 0; + } + if (ds && (type == CREATE || type == RENAME)) + ds->stat = LOOKING; + + /* Map in the directory contents. */ + memobj = diskfs_get_filemap (dp); + mach_port_insert_right (mach_task_self (), memobj, memobj, + MACH_MSG_TYPE_MAKE_SEND); + buf = 0; + /* We allow extra space in case we have to do an EXTEND. */ + buflen = round_page (dp->dn_stat.st_size + DIRBLKSIZ); + if (type == LOOKUP) + /* Map read-only; we won't be writing */ + err = vm_map (mach_task_self (), &buf, buflen, 0, 1, memobj, 0, 0, + VM_PROT_READ, VM_PROT_READ, 0); + else + err = vm_map (mach_task_self (), &buf, buflen, 0, 1, memobj, 0, 0, + VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, 0); + mach_port_deallocate (mach_task_self (), memobj); + + inum = 0; + + for (blockaddr = buf, idx = 0; + blockaddr - buf < dp->dn_stat.st_size; + blockaddr += DIRBLKSIZ, idx++) + { + err = dirscanblock (blockaddr, dp, idx, name, namelen, type, ds, &inum); + if (!err) + break; + if (err != ENOENT) + { + vm_deallocate (mach_task_self (), buf, buflen); + return err; + } + } + + /* If err is set here, it's ENOENT, and we don't want to + think about that as an error yet. */ + err = 0; + + if (inum) + { + if (namelen != 2 || name[0] != '.' || name[1] != '.') + { + if (inum == dp->dn->number) + { + np = dp; + diskfs_nref (np); + } + else + { + err = iget (inum, &np); + if (err) + goto out; + } + } + + /* We are looking up .. */ + /* Check to see if this is the root of the filesystem. */ + else if (dp->dn->number == 2) + { + err = EAGAIN; + goto out; + } + + /* We can't just do iget, because we would then deadlock. + So we do this. Ick. */ + else if (retry_dotdot) + { + /* Check to see that we got the same answer as last time. */ + if (inum != retry_dotdot) + { + /* Drop what we *thought* was .. (but isn't any more) and + try *again*. */ + diskfs_nput (np); + mutex_unlock (&dp->lock); + err = iget (inum, &np); + mutex_lock (&dp->lock); + if (err) + goto out; + retry_dotdot = inum; + goto try_again; + } + /* Otherwise, we got it fine and np is already set properly. */ + } + else if (!spec_dotdot) + { + /* Lock them in the proper order, and then + repeat the directory scan to see if this is still + right. */ + mutex_unlock (&dp->lock); + err = iget (inum, &np); + mutex_lock (&dp->lock); + if (err) + goto out; + retry_dotdot = inum; + goto try_again; + } + + /* Here below are the spec dotdot cases. */ + else if (type == RENAME || type == REMOVE) + np = ifind (inum); + + else if (type == LOOKUP) + { + diskfs_nput (dp); + err = iget (inum, &np); + if (err) + goto out; + } + else + assert (0); + } + + /* If we will be modifying the directory, make sure it's allowed. */ + if (type == RENAME + || (type == REMOVE && np) + || (type == CREATE && !np)) + { + err = diskfs_checkdirmod (dp, np, cred); + if (err) + goto out; + } + + if ((type == CREATE || type == RENAME) && !np && ds && ds->type == LOOKING) + { + /* We didn't find any room, so mark ds to extend the dir */ + ds->type = CREATE; + ds->stat = EXTEND; + ds->idx = idx; + } + + /* Return to the user; if we can't, release the reference + (and lock) we acquired above. */ + out: + /* Deallocate or save the mapping. */ + if ((err && err != ENOENT) + || !ds + || ds->type == LOOKUP) + vm_deallocate (mach_task_self (), buf, buflen); + else + { + ds->mapbuf = buf; + ds->mapextent = buflen; + } + + if (np) + { + if (err || !npp) + { + if (!spec_dotdot) + { + /* Normal case */ + if (np == dp) + diskfs_nrele (np); + else + diskfs_nput (np); + } + else if (type == RENAME || type == REMOVE) + /* We just did ifind to get np; that allocates + no new references, so we don't have anything to do */ + ; + else if (type == LOOKUP) + /* We did iget */ + diskfs_nput (np); + } + else if (npp) + *npp = np; + } + + return err ? : np ? 0 : ENOENT; +} + +/* Scan block at address BLKADDR (of node DP; block index IDX), for + name NAME of length NAMELEN. Args TYPE, DS are as for + diskfs_lookup. If found, set *INUM to the inode number, else + return ENOENT. */ +static error_t +dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, + int namelen, enum lookup_type type, + struct dirstat *ds, ino_t *inum) +{ + int nfree = 0; + int needed = 0; + int countup = 0; + vm_address_t currentoff, prevoff; + struct direct *entry; + int nentries = 0; + + if (ds && ds->stat == LOOKING) + { + countup = 1; + needed = DIRSIZ (namelen); + } + + for (currentoff = blockaddr, prevoff = blockaddr; + currentoff < blockaddr + DIRBLKSIZ; + prevoff = currentoff, currentoff += entry->d_reclen) + { + entry = (struct direct *)currentoff; + + if (!entry->d_reclen + || entry->d_reclen % 4 + || entry->d_namlen > MAXNAMLEN + || currentoff + entry->d_reclen > blockaddr + DIRBLKSIZ + || entry->d_name[entry->d_namlen] + || DIRSIZ (entry->d_namlen) > entry->d_reclen + || memchr (entry->d_name, '\0', entry->d_namlen)) + { + fprintf (stderr, "Bad directory entry: inode: %ld offset: %d\n", + dp->dn->number, currentoff - blockaddr); + return ENOENT; + } + + if (countup) + { + int thisfree; + + if (entry->d_ino == 0) + thisfree = entry->d_reclen; + else + thisfree = entry->d_reclen - DIRSIZ (entry->d_namlen); + + if (thisfree >= needed) + { + ds->type = CREATE; + ds->stat = entry->d_ino == 0 ? TAKE : SHRINK; + ds->entry = entry; + ds->idx = idx; + countup = 0; + } + else + { + nfree += thisfree; + if (nfree >= needed) + { + ds->type = CREATE; + ds->stat = COMPRESS; + ds->entry = (struct direct *) blockaddr; + ds->idx = idx; + countup = 0; + } + } + } + + if (entry->d_ino) + nentries++; + + if (entry->d_namlen == namelen + && entry->d_name[0] == name[0] + && entry->d_ino + && !bcmp (entry->d_name, name, namelen)) + break; + } + + if (currentoff >= blockaddr + DIRBLKSIZ) + { + int i; + /* The name is not in this block. */ + + /* Because we scanned the entire block, we should write + down how many entries there were. */ + if (!dp->dn->dirents) + { + dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ + 1) + * sizeof (int)); + for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++) + dp->dn->dirents[i] = -1; + } + /* Make sure the count is correct if there is one now. */ + assert (dp->dn->dirents[idx] == -1 + || dp->dn->dirents[idx] == nentries); + dp->dn->dirents[idx] = nentries; + + return ENOENT; + } + + /* We have found the required name. */ + + if (ds && type == CREATE) + ds->type = LOOKUP; /* it's invalid now */ + else if (ds && (type == REMOVE || type == RENAME)) + { + ds->type = type; + ds->stat = HERE_TIS; + ds->entry = entry; + ds->idx = idx; + ds->preventry = (struct direct *) prevoff; + } + + *inum = entry->d_ino; + return 0; +} + +/* Following a lookup call for CREATE, this adds a node to a directory. + DP is the directory to be modified; NAME is the name to be entered; + NP is the node being linked in; DS is the cached information returned + by lookup; CRED describes the user making the call. This call may + only be made if the directory has been held locked continuously since + the preceding lookup call, and only if that call returned ENOENT. */ +error_t +diskfs_direnter(struct node *dp, + char *name, + struct node *np, + struct dirstat *ds, + struct protid *cred) +{ + struct direct *new; + int namelen = strlen (name); + int needed = DIRSIZ (namelen); + int oldneeded; + vm_address_t fromoff, tooff; + int totfreed; + error_t err; + + assert (ds->type == CREATE); + + switch (ds->stat) + { + case TAKE: + /* We are supposed to consume this slot. */ + assert (ds->entry->d_ino == 0 && ds->entry->d_reclen >= needed); + + ds->entry->d_ino = np->dn->number; + ds->entry->d_namlen = namelen; + bcopy (name, ds->entry->d_name, namelen + 1); + + break; + + case SHRINK: + /* We are supposed to take the extra space at the end + of this slot. */ + oldneeded = DIRSIZ (ds->entry->d_namlen); + assert (ds->entry->d_reclen - oldneeded >= needed); + + new = (struct direct *) ((vm_address_t) ds->entry + oldneeded); + + new->d_ino = np->dn->number; + new->d_reclen = ds->entry->d_reclen - oldneeded; + new->d_namlen = namelen; + bcopy (name, new->d_name, namelen + 1); + + ds->entry->d_reclen = oldneeded; + + break; + + case COMPRESS: + /* We are supposed to move all the entries to the + front of the block, giving each the minimum + necessary room. This should free up enough space + for the new entry. */ + fromoff = tooff = (vm_address_t) ds->entry; + + while (fromoff < (vm_address_t) ds->entry + DIRBLKSIZ) + { + struct direct *from = (struct direct *)fromoff; + struct direct *to = (struct direct *) tooff; + int fromreclen = from->d_reclen; + + if (from->d_ino != 0) + { + assert (fromoff >= tooff); + + bcopy (from, to, fromreclen); + to->d_reclen = DIRSIZ (to->d_namlen); + + tooff += to->d_reclen; + } + fromoff += fromreclen; + } + + totfreed = (vm_address_t) ds->entry + DIRBLKSIZ - tooff; + assert (totfreed >= needed); + + new = (struct direct *) tooff; + new->d_ino = np->dn->number; + new->d_reclen = totfreed; + new->d_namlen = namelen; + bcopy (name, new->d_name, namelen + 1); + break; + + case EXTEND: + /* Extend the file. */ + while (dp->dn_stat.st_size + DIRBLKSIZ > dp->allocsize) + if (err = diskfs_grow (dp, dp->dn_stat.st_size + DIRBLKSIZ, cred)) + { + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + return err; + } + + new = (struct direct *) (ds->mapbuf + dp->dn_stat.st_size); + + dp->dn_stat.st_size += DIRBLKSIZ; + dp->dn_set_ctime = 1; + + new->d_ino = np->dn->number; + new->d_reclen = DIRBLKSIZ; + new->d_namlen = namelen; + bcopy (name, new->d_name, namelen + 1); + break; + + default: + assert (0); + } + + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + + if (ds->stat != EXTEND) + { + /* If we are keeping count of this block, then keep the count up + to date. */ + if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1) + dp->dn->dirents[ds->idx]++; + } + else + { + /* It's cheap, so start a count here even if we aren't counting + anything at all. */ + if (dp->dn->dirents) + { + dp->dn->dirents = realloc (dp->dn->dirents, + (ds->idx + 1) * sizeof (int)); + dp->dn->dirents[ds->idx] = 1; + } + else + { + int i; + dp->dn->dirents = malloc ((ds->idx + 1) * sizeof (int)); + for (i = 0; i < ds->idx; i++) + dp->dn->dirents[i] = -1; + dp->dn->dirents[ds->idx] = 1; + } + } + + diskfs_file_update (dp, 1); + + if (dp->dirmod_reqs) + diskfs_notice_dirchange (dp, DIR_CHANGED_NEW, name); + + return 0; +} + +/* 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 + only if that call succeeded. */ +error_t +diskfs_dirremove(struct node *dp, + struct dirstat *ds) +{ + assert (ds->type == REMOVE); + assert (ds->stat == HERE_TIS); + + if (ds->preventry == 0) + ds->entry->d_ino = 0; + else + { + assert ((vm_address_t )ds->entry - (vm_address_t)ds->preventry + == ds->preventry->d_reclen); + ds->preventry->d_reclen += ds->entry->d_reclen; + } + + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + + /* If we are keeping count of this block, then keep the count up + to date. */ + if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1) + dp->dn->dirents[ds->idx]--; + + diskfs_file_update (dp, 1); + + if (dp->dirmod_reqs) + diskfs_notice_dirchange (dp, DIR_CHANGED_UNLINK, ds->entry->d_name); + + return 0; +} + + +/* Following a lookup call for RENAME, this changes the inode number + on a directory entry. DP is the directory being changed; NP is + the new node being linked in; DP is the cached information returned + by lookup. This call is only valid if the directory has been locked + continuously since the call to lookup, and only if that call + succeeded. */ +error_t +diskfs_dirrewrite(struct node *dp, + struct node *np, + struct dirstat *ds) +{ + assert (ds->type == RENAME); + assert (ds->stat == HERE_TIS); + + ds->entry->d_ino = np->dn->number; + + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + + diskfs_file_update (dp, 1); + + if (dp->dirmod_reqs) + diskfs_notice_dirchange (dp, DIR_CHANGED_RENUMBER, ds->entry->d_name); + + return 0; +} + +/* Tell if DP is an empty directory (has only "." and ".." entries). */ +/* This routine must be called from inside a catch_exception (). */ +int +diskfs_dirempty(struct node *dp, + struct protid *cred) +{ + struct direct *entry; + int curoff; + vm_address_t buf; + memory_object_t memobj; + error_t err; + + memobj = diskfs_get_filemap (dp); + mach_port_insert_right (mach_task_self (), memobj, memobj, + MACH_MSG_TYPE_MAKE_SEND); + buf = 0; + + err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, + 1, memobj, 0, 0, VM_PROT_READ, VM_PROT_READ, 0); + mach_port_deallocate (mach_task_self (), memobj); + assert (!err); + + for (curoff = buf; + curoff < buf + dp->dn_stat.st_size; + curoff += entry->d_reclen) + { + entry = (struct direct *) curoff; + + if (entry->d_ino != 0 + && (entry->d_namlen > 2 + || entry->d_name[0] != '.' + || (entry->d_name[1] != '.' + && entry->d_name[1] != '\0'))) + { + vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); + return 0; + } + } + vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); + return 1; +} + +/* Make DS an invalid dirstat. */ +error_t +diskfs_drop_dirstat (struct node *dp, struct dirstat *ds) +{ + if (ds->type != LOOKUP) + { + assert (ds->mapbuf); + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + ds->type = LOOKUP; + } + return 0; +} + + +/* Count the entries in directory block NB for directory DP and + write the answer down in its dirents array. As a side affect + fill BUF with the block. */ +static error_t +count_dirents (struct node *dp, int nb, char *buf) +{ + int amt; + char *offinblk; + struct direct *entry; + int count = 0; + error_t err; + + assert (dp->dn->dirents); + assert ((nb + 1) * DIRBLKSIZ <= dp->dn_stat.st_size); + + err = diskfs_node_rdwr (dp, buf, nb * DIRBLKSIZ, DIRBLKSIZ, 0, 0, &amt); + if (err) + return err; + assert (amt == DIRBLKSIZ); + + for (offinblk = buf; + offinblk < buf + DIRBLKSIZ; + offinblk += entry->d_reclen) + { + entry = (struct direct *) offinblk; + if (entry->d_ino) + count++; + } + + assert (dp->dn->dirents[nb] == -1 || dp->dn->dirents[nb] == count); + dp->dn->dirents[nb] = count; + return 0; +} + +/* Implement the disikfs_get_directs callback as described in + . */ +error_t +diskfs_get_directs (struct node *dp, + int entry, + int nentries, + char **data, + u_int *datacnt, + vm_size_t bufsiz, + int *amt) +{ + int blkno; + int nblks; + int curentry; + char buf[DIRBLKSIZ]; + char *bufp; + int bufvalid; + error_t err; + int i; + char *datap; + struct direct *entryp; + int allocsize; + int checklen; + + nblks = dp->dn_stat.st_size/DIRBLKSIZ; + + if (!dp->dn->dirents) + { + dp->dn->dirents = malloc (nblks * sizeof (int)); + for (i = 0; i < nblks; i++) + dp->dn->dirents[i] = -1; + } + + /* Allocate enough space to hold the maximum we might return */ + if (!bufsiz || bufsiz > dp->dn_stat.st_size) + allocsize = round_page (dp->dn_stat.st_size); + else + allocsize = round_page (bufsiz); + + if (allocsize > *datacnt) + vm_allocate (mach_task_self (), (vm_address_t *) data, allocsize, 1); + + /* Scan through the entries to find ENTRY. If we encounter + a -1 in the process then stop to fill it. When we run + off the end, ENTRY is too big. */ + curentry = 0; + bufvalid = 0; + for (blkno = 0; blkno < nblks; blkno++) + { + if (dp->dn->dirents[blkno] == -1) + { + err = count_dirents (dp, blkno, buf); + if (err) + return err; + bufvalid = 1; + } + + if (curentry + dp->dn->dirents[blkno] > entry) + /* ENTRY starts in this block. */ + break; + + curentry += dp->dn->dirents[blkno]; + + bufvalid = 0; + } + + if (blkno == nblks) + { + *datacnt = 0; + *amt = 0; + return 0; + } + + /* Set bufp appropriately */ + bufp = buf; + if (curentry != entry) + { + /* Look through the block to find out where to start, + setting bufp appropriately. */ + if (!bufvalid) + { + err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ, + 0, 0, &checklen); + if (err) + return err; + assert (checklen == DIRBLKSIZ); + bufvalid = 1; + } + for (i = 0, bufp = buf; + i < entry - curentry && bufp - buf < DIRBLKSIZ; + bufp += ((struct direct *)bufp)->d_reclen, i++) + ; + /* Make sure we didn't run off the end. */ + assert (bufp - buf < DIRBLKSIZ); + } + + i = 0; + datap = *data; + + /* Copy the entries, one at a time. */ + while (((nentries == -1) || (i < nentries)) + && (!bufsiz || (datap - *data < bufsiz) ) + && blkno < nblks) + { + if (!bufvalid) + { + err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ, + 0, 0, &checklen); + if (err) + return err; + assert (checklen == DIRBLKSIZ); + bufvalid = 1; + bufp = buf; + } + + entryp = (struct direct *)bufp; + + if (entryp->d_ino) + { + bcopy (bufp, datap, DIRSIZ (entryp->d_namlen)); + i++; + datap += DIRSIZ (entryp->d_namlen); + } + + bufp += entryp->d_reclen; + if (bufp - buf == DIRBLKSIZ) + { + blkno++; + bufvalid = 0; + } + } + + /* We've copied all we can. If we allocated our own array + but didn't fill all of it, then free whatever memory we didn't use. */ + if (allocsize > *datacnt) + { + if (round_page (datap - *data) < allocsize) + vm_deallocate (mach_task_self (), + (vm_address_t) (*data + round_page (datap - *data)), + allocsize - round_page (datap - *data)); + } + + /* Set variables for return */ + *datacnt = datap - *data; + *amt = i; + return 0; +} -- cgit v1.2.3 From b1dfa8a8ab7adcfa953bd6cccff63bd224159471 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Jul 1994 18:07:34 +0000 Subject: Formerly Makefile.~26~ --- ufs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index 7c3c6ca7..14a1260c 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -24,6 +24,8 @@ VPATH=.:../machine SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c +TAGSLIBS=libdiskfs libports libpager libioserver libfshelp libthreads + DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h ChangeLog OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o -- cgit v1.2.3 From e2d8fdfce10f7a48ce92d244064a02ab3fe023d0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Jul 1994 18:21:56 +0000 Subject: Formerly Makefile.~10~ --- mkbootfs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index a65cd722..95fcd542 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -19,6 +19,8 @@ dir := mkbootfs include ../Makeconf DIST_FILES = mkbootfs.c Makefile ChangeLog +SRCS = mkbootfs.c + all: mkbootfs mkbootfs: mkbootfs.c rsh -n $(mighost) cd `pwd` \; $(MIGHOSTCC) mkbootfs.c -o mkbootfs -- cgit v1.2.3 From 0188170d4e1ab74f3f0d1bb439de263beed1df2e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 6 Jul 1994 18:47:34 +0000 Subject: Formerly dir.c.~20~ --- ufs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index d088778e..62bf3302 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -312,7 +312,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, needed = DIRSIZ (namelen); } - for (currentoff = blockaddr, prevoff = blockaddr; + for (currentoff = blockaddr, prevoff = 0; currentoff < blockaddr + DIRBLKSIZ; prevoff = currentoff, currentoff += entry->d_reclen) { @@ -575,7 +575,7 @@ diskfs_dirremove(struct node *dp, ds->entry->d_ino = 0; else { - assert ((vm_address_t )ds->entry - (vm_address_t)ds->preventry + assert ((vm_address_t) ds->entry - (vm_address_t) ds->preventry == ds->preventry->d_reclen); ds->preventry->d_reclen += ds->entry->d_reclen; } -- cgit v1.2.3 From b98b3ceaa0eb2636ae351c69eaafece9d51ac6fa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 11 Jul 1994 22:14:23 +0000 Subject: Formerly dir.c.~21~ --- ufs/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/dir.c b/ufs/dir.c index 62bf3302..c67d2ee1 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -832,6 +832,7 @@ diskfs_get_directs (struct node *dp, if (entryp->d_ino) { bcopy (bufp, datap, DIRSIZ (entryp->d_namlen)); + ((struct direct *)bufp)->d_reclen = DIRSIZ (entryp->d_namlen); i++; datap += DIRSIZ (entryp->d_namlen); } -- cgit v1.2.3 From 3aae8b86527ca8e2937d17827f0114087e8d250e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 16:35:21 +0000 Subject: Initial revision --- ufs/dir.h | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 ufs/dir.h diff --git a/ufs/dir.h b/ufs/dir.h new file mode 100644 index 00000000..c51bd1cf --- /dev/null +++ b/ufs/dir.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)dir.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _DIR_H_ +#define _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(fmt, 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(fmt, 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_long d_ino; /* inode number of entry */ + u_short d_reclen; /* length of this record */ + u_char d_type; /* file type, see below */ + u_char d_namlen; /* length of string in d_name */ + char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */ +}; + +/* + * File types + */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 + +/* + * Convert between stat structure types and directory types. + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) + +/* + * 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. + */ +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRSIZ(oldfmt, dp) \ + ((oldfmt) ? \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) +#else +#define DIRSIZ(oldfmt, dp) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) +#endif +#define OLDDIRFMT 1 +#define NEWDIRFMT 0 + +/* + * 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_long dot_ino; + short dot_reclen; + u_char dot_type; + u_char dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_long dotdot_ino; + short dotdot_reclen; + u_char dotdot_type; + u_char dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + +/* + * This is the old format of directories, sanz type element. + */ +struct odirtemplate { + u_long dot_ino; + short dot_reclen; + u_short dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_long dotdot_ino; + short dotdot_reclen; + u_short dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; +#endif /* !_DIR_H_ */ -- cgit v1.2.3 From 6894fbf72d3a6dd1bcd7eb86a1c7dbf9cdfb053a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 16:56:24 +0000 Subject: Formerly dir.h.~2~ --- ufs/dir.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ufs/dir.h b/ufs/dir.h index c51bd1cf..3fbb511a 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -1,3 +1,4 @@ +/* Modified from BSD by Michael I. Bushnell for GNU Hurd ufs server. */ /* * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -41,6 +42,8 @@ #ifndef _DIR_H_ #define _DIR_H_ +#include + /* * A directory consists of some number of blocks of DIRBLKSIZ * bytes, where DIRBLKSIZ is chosen such that it can be transferred @@ -95,12 +98,31 @@ struct direct { #define IFTODT(mode) (((mode) & 0170000) >> 12) #define DTTOIF(dirtype) ((dirtype) << 12) +/* Return the type from a struct direct, paying attention to whether + this filesystem supports the type extension */ +#define DIRECT_TYPE(dp) (direct_symlink_extension ? (dp)->d_type : DT_UNKNOWN) + +/* Return the namlen from a struct direct, paying attention to whether + this filesystem supports the type extension */ +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRECT_NAMLEN(dp) (direct_symlink_extension ? (dp)->d_namlen : \ + (dp)->d_type) +#else +#define DIRECT_NAMLEN(dp) ((dp)->d_namlen) +#endif + /* * 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. */ +/* In BSD this macro takes a struct direct. Modified by MIB here to + take the namelen (as computed by strlen). */ +#define DIRSIZ(namelen) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((namelen)+1 + 3) &~ 3)) + +#if 0 /* This is the BSD definition */ #if (BYTE_ORDER == LITTLE_ENDIAN) #define DIRSIZ(oldfmt, dp) \ ((oldfmt) ? \ @@ -110,9 +132,12 @@ struct direct { #define DIRSIZ(oldfmt, dp) \ ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) #endif +#endif /* 0 */ + #define OLDDIRFMT 1 #define NEWDIRFMT 0 +#if 0 /* Not used in GNU */ /* * Template for manipulating directories. * Should use struct direct's, but the name field @@ -144,4 +169,6 @@ struct odirtemplate { u_short dotdot_namlen; char dotdot_name[4]; /* ditto */ }; +#endif /* 0 */ + #endif /* !_DIR_H_ */ -- cgit v1.2.3 From 260c89b51118b7f7e8d0119bd86c38e5fb9462de Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 17:05:43 +0000 Subject: Formerly dir.c.~22~ --- ufs/dir.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index c67d2ee1..9cbb42d5 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -320,11 +320,11 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, if (!entry->d_reclen || entry->d_reclen % 4 - || entry->d_namlen > MAXNAMLEN + || DIRECT_NAMLEN (entry) > MAXNAMLEN || currentoff + entry->d_reclen > blockaddr + DIRBLKSIZ - || entry->d_name[entry->d_namlen] - || DIRSIZ (entry->d_namlen) > entry->d_reclen - || memchr (entry->d_name, '\0', entry->d_namlen)) + || entry->d_name[DIRECT_NAMLEN (entry)] + || DIRSIZ (DIRECT_NAMLEN (entry)) > entry->d_reclen + || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { fprintf (stderr, "Bad directory entry: inode: %ld offset: %d\n", dp->dn->number, currentoff - blockaddr); @@ -338,7 +338,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, if (entry->d_ino == 0) thisfree = entry->d_reclen; else - thisfree = entry->d_reclen - DIRSIZ (entry->d_namlen); + thisfree = entry->d_reclen - DIRSIZ (DIRECT_NAMLEN (entry)); if (thisfree >= needed) { @@ -365,7 +365,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, if (entry->d_ino) nentries++; - if (entry->d_namlen == namelen + if (DIRECT_NAMLEN (entry) == namelen && entry->d_name[0] == name[0] && entry->d_ino && !bcmp (entry->d_name, name, namelen)) @@ -441,7 +441,9 @@ diskfs_direnter(struct node *dp, assert (ds->entry->d_ino == 0 && ds->entry->d_reclen >= needed); ds->entry->d_ino = np->dn->number; - ds->entry->d_namlen = namelen; + DIRECT_NAMLEN (ds->entry) = namelen; + if (direct_symlink_extension) + ds->d_type = IFTODT (np->dn->dn_stat.st_mode); bcopy (name, ds->entry->d_name, namelen + 1); break; @@ -449,14 +451,16 @@ diskfs_direnter(struct node *dp, case SHRINK: /* We are supposed to take the extra space at the end of this slot. */ - oldneeded = DIRSIZ (ds->entry->d_namlen); + oldneeded = DIRSIZ (DIRECT_NAMLEN (ds->entry)); assert (ds->entry->d_reclen - oldneeded >= needed); new = (struct direct *) ((vm_address_t) ds->entry + oldneeded); new->d_ino = np->dn->number; new->d_reclen = ds->entry->d_reclen - oldneeded; - new->d_namlen = namelen; + DIRECT_NAMLEN (new) = namelen; + if (direct_symlink_extension) + ds->d_type = IFTODT (np->dn->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); ds->entry->d_reclen = oldneeded; @@ -481,7 +485,7 @@ diskfs_direnter(struct node *dp, assert (fromoff >= tooff); bcopy (from, to, fromreclen); - to->d_reclen = DIRSIZ (to->d_namlen); + to->d_reclen = DIRSIZ (DIRECT_NAMLEN (to)); tooff += to->d_reclen; } @@ -494,7 +498,9 @@ diskfs_direnter(struct node *dp, new = (struct direct *) tooff; new->d_ino = np->dn->number; new->d_reclen = totfreed; - new->d_namlen = namelen; + DIRECT_NAMLEN (new) = namelen; + if (direct_symlink_extension) + new->d_type = IFTODT (np->dn->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); break; @@ -514,7 +520,9 @@ diskfs_direnter(struct node *dp, new->d_ino = np->dn->number; new->d_reclen = DIRBLKSIZ; - new->d_namlen = namelen; + DIRECT_NAMLEN (new) = namelen; + if (direct_symlink_extension) + new->d_type = IFTODT (np->dn->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); break; @@ -611,6 +619,8 @@ diskfs_dirrewrite(struct node *dp, assert (ds->stat == HERE_TIS); ds->entry->d_ino = np->dn->number; + if (direct_symlink_extension) + ds->entry->d_type = IFTODT (np->dn->dn_stat.st_mode); vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); @@ -651,7 +661,7 @@ diskfs_dirempty(struct node *dp, entry = (struct direct *) curoff; if (entry->d_ino != 0 - && (entry->d_namlen > 2 + && (DIRECT_NAMLEN (entry) > 2 || entry->d_name[0] != '.' || (entry->d_name[1] != '.' && entry->d_name[1] != '\0'))) @@ -831,10 +841,10 @@ diskfs_get_directs (struct node *dp, if (entryp->d_ino) { - bcopy (bufp, datap, DIRSIZ (entryp->d_namlen)); - ((struct direct *)bufp)->d_reclen = DIRSIZ (entryp->d_namlen); + bcopy (bufp, datap, DIRSIZ (DIRECT_NAMLEN (entryp))); + ((struct direct *)bufp)->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); i++; - datap += DIRSIZ (entryp->d_namlen); + datap += DIRSIZ (DIRECT_NAMLEN (entryp)); } bufp += entryp->d_reclen; -- cgit v1.2.3 From 73612522ff8f67265361821d7ec757ad8b9bf5a8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 17:06:33 +0000 Subject: Formerly dinode.h.~2~ --- ufs/dinode.h | 202 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 94 insertions(+), 108 deletions(-) diff --git a/ufs/dinode.h b/ufs/dinode.h index dfde2050..5b9915d9 100644 --- a/ufs/dinode.h +++ b/ufs/dinode.h @@ -1,122 +1,108 @@ -/* Format of an inode on disk - Copyright (C) 1991, 1993 Free Software Foundation - -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. */ - -/* Modified from UCB by Michael I. Bushnell. */ - /* - * Copyright (c) 1982, 1989 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Redistribution is only permitted until one year after the first shipment - * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and - * binary forms are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * - * @(#)dinode.h 7.9 (Berkeley) 6/28/90 + * @(#)dinode.h 8.3 (Berkeley) 1/21/94 */ /* - * This structure defines the on-disk format of an inode. + * 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) -#define NDADDR 12 /* direct addresses in inode */ -#define NIADDR 3 /* indirect addresses in inode */ +/* + * A dinode contains all the meta-data associated with a UFS file. + * This structure defines the on-disk format of a dinode. + */ -/* Indexes into di_ib */ -#define INDIR_SINGLE 0 -#define INDIR_DOUBLE 1 -#define INDIR_TRIPLE 2 /* NOT SUPPORTED */ +#define NDADDR 12 /* Direct addresses in inode. */ +#define NIADDR 3 /* Indirect addresses in inode. */ struct dinode { - u_short di_model; /* 0: mode and type of file (low bits) */ - nlink_t di_nlink; /* 2: number of links to file */ - u_short di_uidl; /* 4: owner's user id (low bits) */ - u_short di_gidl; /* 6: owner's group id (low bits) */ - u_quad di_qsize; /* 8: number of bytes in file */ - time_t di_atime; /* 16: time last accessed */ - long di_atusec; - time_t di_mtime; /* 24: time last modified */ - long di_mtusec; - time_t di_ctime; /* 32: last time inode changed */ - long di_ctusec; - daddr_t di_db[NDADDR]; /* 40: disk block addresses */ - daddr_t di_ib[NIADDR]; /* 88: indirect blocks */ - long di_flags; /* 100: status, currently unused */ - long di_blocks; /* 104: blocks actually held */ - long di_gen; /* 108: generation number */ - long di_trans; /* 112: filesystem tranlator */ - uid_t di_author; /* 116: author id */ - u_short di_uidh; /* 120: user id (high bits) */ - u_short di_gidh; /* 122: group id (high bits) */ - u_short di_modeh; /* 124: mode (high bits) */ - short di_spare; /* 126: reserved, currently unused */ + u_short di_mode; /* 0: IFMT and permissions. */ + short di_nlink; /* 2: File link count. */ + union { + u_short oldids[2]; /* 4: Ffs: old user and group ids. */ + ino_t inumber; /* 4: Lfs: inode number. */ + } di_u; + u_quad_t di_size; /* 8: File byte count. */ + struct timespec di_atime; /* 16: Last access time. */ + struct timespec di_mtime; /* 24: Last modified time. */ + struct timespec di_ctime; /* 32: Last inode change time. */ + daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ + daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ + u_long di_flags; /* 100: Status flags (chflags). */ + long di_blocks; /* 104: Blocks actually held. */ + long di_gen; /* 108: Generation number. */ + u_long di_uid; /* 112: File owner. */ + u_long di_gid; /* 116: File group. */ + long di_spare[2]; /* 120: Reserved; currently unused */ }; -#define DI_UID(di) ((di)->di_uidl | ((int)(di)->di_uidh << 16)) -#define DI_GID(di) ((di)->di_gidl | ((int)(di)->di_gidh << 16)) -#define DI_MODE(di) ((di)->di_model | ((int)(di)->di_modeh << 16)) - -#define LINK_MAX 32767 /* limited by width of nlink_t == 16 bits */ - -#if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */ -#define di_size di_qsize.val[0] -#else /* BYTE_ORDER == BIG_ENDIAN */ -#define di_size di_qsize.val[1] -#endif +/* + * The di_db fields may be overlaid with other information for + * file types that do not have associated disk storage. Block + * and character devices overlay the first data block with their + * dev_t value. Short symbolic links place their path in the + * di_db area. + */ +#define di_inumber di_u.inumber +#define di_ogid di_u.oldids[1] +#define di_ouid di_u.oldids[0] #define di_rdev di_db[0] - -/* file modes -- these are known to match appropriate values in gnu/stat.h */ -#define IFMT 000000170000 /* type of file */ -#define IFIFO 000000010000 /* named pipe (fifo) */ -#define IFCHR 000000020000 /* character special */ -#define IFDIR 000000040000 /* directory */ -#define IFBLK 000000060000 /* block special */ -#define IFREG 000000100000 /* regular */ -#define IFLNK 000000120000 /* symbolic link */ -#define IFSOCK 000000140000 /* socket */ - -#define ISPEC 000000607000 /* special user-changeable bits */ -#define INOCACHE 000000400000 /* don't cache contents */ -#define IUSEUNK 000000200000 /* use IUNK in pref to IKNOWN */ -#define ISUID 000000004000 /* set user id on execution */ -#define ISGID 000000002000 /* set group id on execution */ -#define ISVTX 000000001000 /* caching preference / append only dir */ - -/* masks for various sets of permissions: */ -#define IOWNER 000000000700 /* owner of file */ -#define IGROUP 000000000070 /* group of file */ -#define IKNOWN 000000000007 /* anyone who possesses a uid */ -#define IUNKNOWN 000007000000 /* anyone who doesn't possess a uid */ - -#define ISPARE 037770000000 /* unused (yet) */ - -#define IREAD 0400 /* read, write, execute permissions */ -#define IWRITE 0200 -#define IEXEC 0100 - +#define di_shortlink di_db +#define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t)) + +/* File modes. */ +#define IEXEC 0000100 /* Executable. */ +#define IWRITE 0000200 /* Writeable. */ +#define IREAD 0000400 /* Readable. */ +#define ISVTX 0001000 /* Sticky bit. */ +#define ISGID 0002000 /* Set-gid. */ +#define ISUID 0004000 /* Set-uid. */ + +/* File types. */ +#define IFMT 0170000 /* Mask of file type. */ +#define IFIFO 0010000 /* Named pipe (fifo). */ +#define IFCHR 0020000 /* Character device. */ +#define IFDIR 0040000 /* Directory file. */ +#define IFBLK 0060000 /* Block device. */ +#define IFREG 0100000 /* Regular file. */ +#define IFLNK 0120000 /* Symbolic link. */ +#define IFSOCK 0140000 /* UNIX domain socket. */ -- cgit v1.2.3 From f51bc401c3c327cd0548fdcbcd246b1e7c61e3c3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 19:06:35 +0000 Subject: Formerly main.c.~13~ --- ufs/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index e47586e7..de90cea8 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -33,6 +33,8 @@ char * trans_parse_args (int argc, char **arg) { #ifdef notyet + /* Option to set compat_mode should be provided here. */ + /* When started as a translator, we are called with the device name and an optional argument -r, which signifies read-only. */ @@ -128,6 +130,7 @@ main (int argc, char **argv) { devname = diskfs_parse_bootargs (argc, argv); diskfs_dotdot_file = MACH_PORT_NULL; + compat_mode = COMPAT_GNU; } diskfs_init_diskfs (); @@ -161,6 +164,13 @@ main (int argc, char **argv) exit (1); } + /* If the filesystem has new features in it, don't pay attention to + the user's request not to use them. */ + if ((sblock->fs_inodefmt == FS_44INODEFMT + || direct_symlink_extension) + && compat_mode == COMPAT_BSD42) + compat_mode = COMPAT_BSD44; + if (!diskfs_readonly) { sblock->fs_clean = 0; -- cgit v1.2.3 From 3de0751576921a5a92e23a6918ec4dcb3db3c670 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 19:50:21 +0000 Subject: Formerly hyper.c.~6~ --- ufs/hyper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ufs/hyper.c b/ufs/hyper.c index 7bb8d7c8..c9ffcc63 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -47,6 +47,13 @@ get_hypermetadata (void) exit (1); } + if (sblock->fs_maxsymlinklen > MAXSYMLINKLEN) + { + fprintf (stderr, "Max shortcut symlinklen %d is too big (max is %d)\n", + sblock->fs_maxsymlinklen, MAXSYMLINKLEN); + exit (1); + } + /* If this is an old filesystem, then we have some more work to do; some crucial constants might not be set; we are therefore forced to set them here. */ @@ -57,6 +64,12 @@ get_hypermetadata (void) if (sblock->fs_postblformat == FS_42POSTBLFMT) sblock->fs_nrpos = 8; + /* Find out if we support the 4.4 symlink/dirtype extension */ + if (sblock->fs_maxsymlinklen > 0) + direct_symlink_extension = 1; + else + direct_symlink_extension = 0; + err = dev_read_sync (fsbtodb (sblock->fs_csaddr), (vm_address_t *) &csum, sblock->fs_fsize * howmany (sblock->fs_cssize, sblock->fs_fsize)); -- cgit v1.2.3 From f786431d22c1a23eee19cd95a5e11400d21b5972 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 19:57:04 +0000 Subject: Formerly tables.c.~2~ --- ufs/tables.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/ufs/tables.c b/ufs/tables.c index 42badaed..8cf46b01 100644 --- a/ufs/tables.c +++ b/ufs/tables.c @@ -1,26 +1,40 @@ -/* Tables for fast computation */ /* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. * - * Redistribution is only permitted until one year after the first shipment - * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and - * binary forms are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * @(#)ufs_tables.c 7.4 (Berkeley) 6/28/90 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93 */ +#include + /* * Bit patterns for identifying fragments in the block map * used as ((map & around) == inside) -- cgit v1.2.3 From 402cdd294459937e6c5d17778321930f3d0f971f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 19:59:03 +0000 Subject: Formerly subr.c.~3~ --- ufs/subr.c | 230 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 140 insertions(+), 90 deletions(-) diff --git a/ufs/subr.c b/ufs/subr.c index 25990835..c251b16e 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -1,75 +1,109 @@ -/* Miscellaneous map manipulation routines - Copyright (C) 1991, 1992, 1994 Free Software Foundation - -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. */ - -/* Slightly modified from UCB by Michael I. Bushnell. */ - /* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Redistribution is only permitted until one year after the first shipment - * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and - * binary forms are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * - * @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 + * @(#)ffs_subr.c 8.2 (Berkeley) 9/21/93 */ -#include "ufs.h" -#include "fs.h" +#include +#include +#ifdef KERNEL +#include +#include +#include +#include +#include +#include -extern int around[9]; -extern int inside[9]; -extern u_char *fragtbl[]; +/* + * Return buffer with the contents of block "offset" from the beginning of + * directory "ip". If "res" is non-zero, fill it in with a pointer to the + * remaining space in the directory. + */ +int +ffs_blkatoff(ap) + struct vop_blkatoff_args /* { + struct vnode *a_vp; + off_t a_offset; + char **a_res; + struct buf **a_bpp; + } */ *ap; +{ + struct inode *ip; + register struct fs *fs; + struct buf *bp; + daddr_t lbn; + int bsize, error; + + ip = VTOI(ap->a_vp); + fs = ip->i_fs; + lbn = lblkno(fs, ap->a_offset); + bsize = blksize(fs, ip, lbn); + + *ap->a_bpp = NULL; + if (error = bread(ap->a_vp, lbn, bsize, NOCRED, &bp)) { + brelse(bp); + return (error); + } + if (ap->a_res) + *ap->a_res = (char *)bp->b_data + blkoff(fs, ap->a_offset); + *ap->a_bpp = bp; + return (0); +} +#endif /* * Update the frsum fields to reflect addition or deletion * of some frags. */ void -fragacct(int fragmap, - long fraglist[], - int cnt) +ffs_fragacct(fs, fragmap, fraglist, cnt) + struct fs *fs; + int fragmap; + long fraglist[]; + int cnt; { int inblk; - int field, subfield; - int siz, pos; + register int field, subfield; + register int siz, pos; - inblk = (int)(fragtbl[sblock->fs_frag][fragmap]) << 1; + inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1; fragmap <<= 1; - for (siz = 1; siz < sblock->fs_frag; siz++) { - if ((inblk & (1 << (siz + (sblock->fs_frag % NBBY)))) == 0) + for (siz = 1; siz < fs->fs_frag; siz++) { + if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0) continue; field = around[siz]; subfield = inside[siz]; - for (pos = siz; pos <= sblock->fs_frag; pos++) { + for (pos = siz; pos <= fs->fs_frag; pos++) { if ((fragmap & field) == subfield) { fraglist[siz] += cnt; pos += siz; @@ -82,18 +116,54 @@ fragacct(int fragmap, } } +#if defined(KERNEL) && defined(DIAGNOSTIC) +void +ffs_checkoverlap(bp, ip) + struct buf *bp; + struct inode *ip; +{ + register struct buf *ebp, *ep; + register daddr_t start, last; + struct vnode *vp; + + ebp = &buf[nbuf]; + start = bp->b_blkno; + last = start + btodb(bp->b_bcount) - 1; + for (ep = buf; ep < ebp; ep++) { + if (ep == bp || (ep->b_flags & B_INVAL) || + ep->b_vp == NULLVP) + continue; + if (VOP_BMAP(ep->b_vp, (daddr_t)0, &vp, (daddr_t)0, NULL)) + continue; + if (vp != ip->i_devvp) + continue; + /* look for overlap */ + if (ep->b_bcount == 0 || ep->b_blkno > last || + ep->b_blkno + btodb(ep->b_bcount) <= start) + continue; + vprint("Disk overlap", vp); + (void)printf("\tstart %d, end %d overlap start %d, end %d\n", + start, last, ep->b_blkno, + ep->b_blkno + btodb(ep->b_bcount) - 1); + panic("Disk buffer overlap"); + } +} +#endif /* DIAGNOSTIC */ + /* * block operations * * check if a block is available */ int -isblock(u_char *cp, - daddr_t h) +ffs_isblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + daddr_t h; { - u_char mask; + unsigned char mask; - switch ((int)sblock->fs_frag) { + switch ((int)fs->fs_frag) { case 8: return (cp[h] == 0xff); case 4: @@ -106,7 +176,7 @@ isblock(u_char *cp, mask = 0x01 << (h & 0x7); return ((cp[h >> 3] & mask) == mask); default: - assert (0); + panic("ffs_isblock"); } } @@ -114,11 +184,13 @@ isblock(u_char *cp, * take a block out of the map */ void -clrblock(u_char *cp, - daddr_t h) +ffs_clrblock(fs, cp, h) + struct fs *fs; + u_char *cp; + daddr_t h; { - switch ((int)sblock->fs_frag) { + switch ((int)fs->fs_frag) { case 8: cp[h] = 0; return; @@ -132,7 +204,7 @@ clrblock(u_char *cp, cp[h >> 3] &= ~(0x01 << (h & 0x7)); return; default: - assert (0); + panic("ffs_clrblock"); } } @@ -140,10 +212,13 @@ clrblock(u_char *cp, * put a block into the map */ void -setblock(u_char *cp, - daddr_t h) +ffs_setblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + daddr_t h; { - switch ((int)sblock->fs_frag) { + + switch ((int)fs->fs_frag) { case 8: cp[h] = 0xff; @@ -158,31 +233,6 @@ setblock(u_char *cp, cp[h >> 3] |= (0x01 << (h & 0x7)); return; default: - assert (0); + panic("ffs_setblock"); } } - -int -skpc(u_char mask, - u_int size, - u_char *cp) -{ - u_char *end = &cp[size]; - - while (cp < end && *cp == mask) - cp++; - return (end - cp); -} - -int -scanc(u_int size, - u_char *cp, - u_char table[], - u_char mask) -{ - register u_char *end = &cp[size]; - - while (cp < end && (table[*cp] & mask) == 0) - cp++; - return (end - cp); -} -- cgit v1.2.3 From c47254e1358967fbaeb572f1c9ee1b8f9aae0250 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 19:59:56 +0000 Subject: Formerly tables.c.~3~ --- ufs/tables.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/tables.c b/ufs/tables.c index 8cf46b01..81e3c25c 100644 --- a/ufs/tables.c +++ b/ufs/tables.c @@ -1,3 +1,4 @@ +/* Modified from BSD for GNU Hurd ufs server by Michael I. Bushnell. */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,8 @@ * @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93 */ -#include +#include "ufs.h" +#include "fs.h" /* * Bit patterns for identifying fragments in the block map -- cgit v1.2.3 From aa2749bf3335097364c7ff4e607bb5d544646b18 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 20:00:26 +0000 Subject: Formerly dinode.h.~3~ --- ufs/dinode.h | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/ufs/dinode.h b/ufs/dinode.h index 5b9915d9..8f9dae0e 100644 --- a/ufs/dinode.h +++ b/ufs/dinode.h @@ -1,3 +1,20 @@ +/* + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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. */ + /* * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -55,12 +72,13 @@ #define NIADDR 3 /* Indirect addresses in inode. */ struct dinode { - u_short di_mode; /* 0: IFMT and permissions. */ + u_short di_model; /* 0: IFMT and permissions. */ short di_nlink; /* 2: File link count. */ - union { - u_short oldids[2]; /* 4: Ffs: old user and group ids. */ - ino_t inumber; /* 4: Lfs: inode number. */ - } di_u; + union + { + u_long diu_author; /* 4: File author */ + u_short diu_oldids[2]; /* Old format uid and gid */ + } di_u; u_quad_t di_size; /* 8: File byte count. */ struct timespec di_atime; /* 16: Last access time. */ struct timespec di_mtime; /* 24: Last modified time. */ @@ -72,9 +90,15 @@ struct dinode { long di_gen; /* 108: Generation number. */ u_long di_uid; /* 112: File owner. */ u_long di_gid; /* 116: File group. */ - long di_spare[2]; /* 120: Reserved; currently unused */ + u_short di_modeh; /* 120: Mode high bits */ + u_short di_spare; /* 122: unused */ + long di_trans; /* 124: filesystem translator */ }; +#define di_author di_u.diu_author /* GNU extension */ +#define di_ouid di_u.diu_oldids[0] +#define di_ogid di_u.diu_oldids[1] + /* * The di_db fields may be overlaid with other information for * file types that do not have associated disk storage. Block @@ -82,9 +106,6 @@ struct dinode { * dev_t value. Short symbolic links place their path in the * di_db area. */ -#define di_inumber di_u.inumber -#define di_ogid di_u.oldids[1] -#define di_ouid di_u.oldids[0] #define di_rdev di_db[0] #define di_shortlink di_db #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t)) -- cgit v1.2.3 From 8f9cbf53b9c8da56e2ea60b638627597f08cc175 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 20:06:40 +0000 Subject: Formerly fs.h.~3~ --- ufs/fs.h | 317 +++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 176 insertions(+), 141 deletions(-) diff --git a/ufs/fs.h b/ufs/fs.h index 2efc6910..bef052fe 100644 --- a/ufs/fs.h +++ b/ufs/fs.h @@ -1,44 +1,36 @@ -/* Format of a filesystem on disk (superblock and cylinder groups) - Copyright (C) 1991, 1993, 1994 Free Software Foundation - -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. */ - -/* Modified from UCB by Michael I. Bushnell. */ - /* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Redistribution is only permitted until one year after the first shipment - * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and - * binary forms are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * - * @(#)fs.h 7.10 (Berkeley) 6/28/90 + * @(#)fs.h 8.7 (Berkeley) 4/19/94 */ /* @@ -89,15 +81,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ * * 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. @@ -120,7 +104,29 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #define MAXMNTLEN 512 #define MAXCSBUFS 32 -#define MAXFRAG 8 + +/* + * A summary of contiguous blocks of various sizes is maintained + * in each cylinder group. Normally this is set by the initial + * value of fs_maxcontig. To conserve space, a maximum summary size + * is set by FS_MAXCONTIG. + */ +#define FS_MAXCONTIG 16 + +/* + * MINFREE gives the minimum acceptable percentage of file system + * blocks which may be free. If the freelist drops below this level + * only the superuser may continue to allocate blocks. This may + * be set to 0 if no reserve of free blocks is deemed necessary, + * however throughput drops by fifty percent if the file system + * is run at between 95% and 100% full; thus the minimum default + * value of fs_minfree is 5%. However, to get good clustering + * performance, 10% is a better choice. hence we use 10% as our + * default value. With 10% free space, fragmentation is not a + * problem, so we choose to optimize for time. + */ +#define MINFREE 5 +#define DEFAULTOPT FS_OPTTIME /* * Per cylinder group information; summarized in blocks allocated @@ -141,10 +147,7 @@ struct csum { /* * Super block for a file system. */ -#define FS_MAGIC 0x011954 -#define FSOKAY 0x7c269d38 -struct fs -{ +struct fs { struct fs *fs_link; /* linked list of file systems */ struct fs *fs_rlink; /* used for incore super blocks */ daddr_t fs_sblkno; /* addr of super-block in filesys */ @@ -153,7 +156,7 @@ struct fs daddr_t fs_dblkno; /* offset of first data after cg */ long fs_cgoffset; /* cylinder group offset in cylinder */ long fs_cgmask; /* used to calc mod fs_ntrak */ - long fs_time; /* last time written */ + time_t fs_time; /* last time written */ long fs_size; /* number of blocks in fs */ long fs_dsize; /* number of data blocks in fs */ long fs_ncg; /* number of cylinder groups */ @@ -216,18 +219,29 @@ struct fs struct csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */ long fs_cpc; /* cyl per cycle in postbl */ short fs_opostbl[16][8]; /* old rotation block list head */ - long fs_sparecon[55]; /* reserved for future constants */ + 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 */ + u_quad_t fs_maxfilesize; /* maximum representable file size */ + quad_t fs_qbmask; /* ~fs_bmask - for use with quad size */ + quad_t fs_qfmask; /* ~fs_fmask - for use with quad size */ long fs_state; /* validate fs_clean field */ - quad fs_qbmask; /* ~fs_bmask - for use with quad size */ - quad fs_qfmask; /* ~fs_fmask - for use with quad size */ long fs_postblformat; /* format of positional layout tables */ - long fs_nrpos; /* number of rotaional positions */ + long fs_nrpos; /* number of rotational positions */ long fs_postbloff; /* (short) rotation block list head */ long fs_rotbloff; /* (u_char) blocks for each rotation */ long fs_magic; /* magic number */ - unsigned char fs_space[1]; /* list of blocks for each rotation */ + u_char fs_space[1]; /* list of blocks for each rotation */ /* actually longer */ }; +/* + * Filesystem idetification + */ +#define FS_MAGIC 0x011954 /* the fast filesystem magic number */ +#define FS_OKAY 0x7c269d38 /* superblock checksum */ +#define FS_42INODEFMT -1 /* 4.2BSD inode format */ +#define FS_44INODEFMT 2 /* 4.4BSD inode format */ /* * Preference for optimization. */ @@ -242,23 +256,38 @@ struct fs /* * Macros for access to superblock array structures */ -#define fs_postbl(cylno) \ - ((sblock->fs_postblformat == FS_42POSTBLFMT) \ - ? (sblock->fs_opostbl[cylno]) \ - : ((short *)((char *)sblock + sblock->fs_postbloff) \ - + (cylno) * sblock->fs_nrpos)) -#define fs_rotbl \ - ((sblock->fs_postblformat == FS_42POSTBLFMT) \ - ? (sblock->fs_space) \ - : ((unsigned char *)((char *)sblock + sblock->fs_rotbloff))) +#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))) + +/* + * The size of a cylinder group is calculated by CGSIZE. The maximum size + * is limited by the fact that cylinder groups are at most one block. + * Its size is derived from the size of the maps maintained in the + * cylinder group and the (struct cg) size. + */ +#define CGSIZE(fs) \ + /* base cg */ (sizeof(struct cg) + sizeof(long) + \ + /* blktot size */ (fs)->fs_cpg * sizeof(long) + \ + /* blks size */ (fs)->fs_cpg * (fs)->fs_nrpos * sizeof(short) + \ + /* inode map */ howmany((fs)->fs_ipg, NBBY) + \ + /* block map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY) +\ + /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ + /* cluster sum */ (fs)->fs_contigsumsize * sizeof(long) + \ + /* cluster map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPB(fs), NBBY))) /* * 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(indx) \ - fs_csp[(indx) >> sblock->fs_csshift][(indx) & ~sblock->fs_csmask] +#define fs_cs(fs, indx) \ + fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask] /* * Cylinder group block for a file system. @@ -267,7 +296,7 @@ struct fs struct cg { struct cg *cg_link; /* linked list of cyl groups */ long cg_magic; /* magic number */ - long cg_time; /* time last written */ + time_t cg_time; /* time last written */ long 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 */ @@ -282,8 +311,11 @@ struct cg { long cg_iusedoff; /* (char) used inode map */ long cg_freeoff; /* (u_char) free block map */ long cg_nextfreeoff; /* (u_char) next available space */ - long cg_sparecon[16]; /* reserved for future use */ - unsigned char cg_space[1]; /* space for cylinder group maps */ + long cg_clustersumoff; /* (long) counts of avail clusters */ + long cg_clusteroff; /* (char) free cluster map */ + long cg_nclusterblks; /* number of clusters this cg */ + long cg_sparecon[13]; /* reserved for future use */ + u_char cg_space[1]; /* space for cylinder group maps */ /* actually longer */ }; /* @@ -293,10 +325,10 @@ struct cg { (((cgp)->cg_magic != CG_MAGIC) \ ? (((struct ocg *)(cgp))->cg_btot) \ : ((long *)((char *)(cgp) + (cgp)->cg_btotoff))) -#define cg_blks(cgp, cylno) \ +#define cg_blks(fs, cgp, cylno) \ (((cgp)->cg_magic != CG_MAGIC) \ ? (((struct ocg *)(cgp))->cg_b[cylno]) \ - : ((short *)((char *)(cgp) + (cgp)->cg_boff) + (cylno) * sblock->fs_nrpos)) + : ((short *)((char *)(cgp) + (cgp)->cg_boff) + (cylno) * (fs)->fs_nrpos)) #define cg_inosused(cgp) \ (((cgp)->cg_magic != CG_MAGIC) \ ? (((struct ocg *)(cgp))->cg_iused) \ @@ -304,9 +336,13 @@ struct cg { #define cg_blksfree(cgp) \ (((cgp)->cg_magic != CG_MAGIC) \ ? (((struct ocg *)(cgp))->cg_free) \ - : ((unsigned char *)((char *)(cgp) + (cgp)->cg_freeoff))) + : ((u_char *)((char *)(cgp) + (cgp)->cg_freeoff))) #define cg_chkmagic(cgp) \ ((cgp)->cg_magic == CG_MAGIC || ((struct ocg *)(cgp))->cg_magic == CG_MAGIC) +#define cg_clustersfree(cgp) \ + ((u_char *)((char *)(cgp) + (cgp)->cg_clusteroff)) +#define cg_clustersum(cgp) \ + ((long *)((char *)(cgp) + (cgp)->cg_clustersumoff)) /* * The following structure is defined @@ -315,7 +351,7 @@ struct cg { struct ocg { struct ocg *cg_link; /* linked list of cyl groups */ struct ocg *cg_rlink; /* used for incore cyl groups */ - long cg_time; /* time last written */ + time_t cg_time; /* time last written */ long 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 */ @@ -329,7 +365,7 @@ struct ocg { short cg_b[32][8]; /* positions of free blocks */ char cg_iused[256]; /* used inode map */ long cg_magic; /* magic number */ - unsigned char cg_free[1]; /* free block map */ + u_char cg_free[1]; /* free block map */ /* actually longer */ }; @@ -337,20 +373,20 @@ struct ocg { * Turn file system block numbers into disk block addresses. * This maps file system blocks to device size blocks. */ -#define fsbtodb(b) ((b) << sblock->fs_fsbtodb) -#define dbtofsb(b) ((b) >> sblock->fs_fsbtodb) +#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(c) ((daddr_t)(sblock->fs_fpg * (c))) -#define cgstart(c) \ - (cgbase(c) + sblock->fs_cgoffset * ((c) & ~(sblock->fs_cgmask))) -#define cgsblock(c) (cgstart(c) + sblock->fs_sblkno) /* super blk */ -#define cgtod(c) (cgstart(c) + sblock->fs_cblkno) /* cg block */ -#define cgimin(c) (cgstart(c) + sblock->fs_iblkno) /* inode blk */ -#define cgdmin(c) (cgstart(c) + sblock->fs_dblkno) /* 1st data */ +#define cgbase(fs, c) ((daddr_t)((fs)->fs_fpg * (c))) +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ +#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 cgstart(fs, c) \ + (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask))) /* * Macros for handling inode numbers: @@ -358,97 +394,96 @@ struct ocg { * inode number to cylinder group number. * inode number to file system block address. */ -#define itoo(x) ((x) % INOPB) -#define itog(x) ((x) / sblock->fs_ipg) -#define itod(x) \ - ((daddr_t)(cgimin(itog(x)) + \ - (blkstofrags((((x) % sblock->fs_ipg) / INOPB))))) +#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg) +#define ino_to_fsba(fs, x) \ + ((daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \ + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs)))))) +#define ino_to_fsbo(fs, x) ((x) % INOPB(fs)) /* * Give cylinder group number for a file system block. * Give cylinder group block number for a file system block. */ -#define dtog(d) ((d) / sblock->fs_fpg) -#define dtogd(d) ((d) % sblock->fs_fpg) +#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(map, loc) \ - (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - sblock->fs_frag))) -#define cbtocylno(bno) \ - ((bno) * NSPF / sblock->fs_spc) -#define cbtorpos(bno) \ - (((bno) * NSPF % sblock->fs_spc / sblock->fs_nsect * sblock->fs_trackskew + \ - (bno) * NSPF % sblock->fs_spc % sblock->fs_nsect * sblock->fs_interleave) % \ - sblock->fs_nsect * sblock->fs_nrpos / sblock->fs_npsect) +#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(loc) /* calculates (loc % fs->fs_bsize) */ \ - ((loc) & ~sblock->fs_bmask) -#define fragoff(loc) /* calculates (loc % fs->fs_fsize) */ \ - ((loc) & ~sblock->fs_fmask) -#define lblktosize(blk) /* calculates (blk * fs->fs_bsize) */ \ - ((blk) << sblock->fs_bshift) -#define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \ - ((loc) >> sblock->fs_bshift) -#define numfrags(loc) /* calculates (loc / fs->fs_fsize) */ \ - ((loc) >> sblock->fs_fshift) -#define blkroundup(size) /* calculates roundup(size, fs->fs_bsize) */ \ - (((size) + sblock->fs_bsize - 1) & sblock->fs_bmask) -#define fragroundup(size) /* calculates roundup(size, fs->fs_fsize) */ \ - (((size) + sblock->fs_fsize - 1) & sblock->fs_fmask) -#define fragstoblks(frags) /* calculates (frags / fs->fs_frag) */ \ - ((frags) >> sblock->fs_fragshift) -#define blkstofrags(blks) /* calculates (blks * fs->fs_frag) */ \ - ((blks) << sblock->fs_fragshift) -#define fragnum(fsb) /* calculates (fsb % fs->fs_frag) */ \ - ((fsb) & (sblock->fs_frag - 1)) -#define blknum(fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ - ((fsb) &~ (sblock->fs_frag - 1)) +#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ + ((loc) & (fs)->fs_qbmask) +#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ + ((loc) & (fs)->fs_qfmask) +#define lblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \ + ((blk) << (fs)->fs_bshift) +#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_qbmask) & (fs)->fs_bmask) +#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + (fs)->fs_qfmask) & (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(percentreserved) \ - (blkstofrags(sblock->fs_cstotal.cs_nbfree) + \ - sblock->fs_cstotal.cs_nffree - (sblock->fs_dsize * (percentreserved) / 100)) +#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(np, lbn) \ - (((lbn) >= NDADDR || (np)->allocsize >= ((lbn) + 1) << sblock->fs_bshift) \ - ? sblock->fs_bsize \ - : (fragroundup(blkoff((np)->allocsize)))) -#define dblksize(dip, lbn) \ - (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << sblock->fs_bshift) \ - ? sblock->fs_bsize \ - : (fragroundup(blkoff((dip)->di_size)))) +#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 (sblock->fs_nspf << sblock->fs_fragshift) -#define NSPF (sblock->fs_nspf) +#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 (sblock->fs_inopb) -#define INOPF (sblock->fs_inopb >> sblock->fs_fragshift) +#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 (sblock->fs_nindir) +#define NINDIR(fs) ((fs)->fs_nindir) -#ifdef KERNEL -struct fs *getfs(); -#endif +extern int inside[], around[]; +extern u_char *fragtbl[]; -- cgit v1.2.3 From 749a832c68edbd3c83505e8c255249cc4aa21689 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 20:08:55 +0000 Subject: Formerly subr.c.~4~ --- ufs/subr.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/ufs/subr.c b/ufs/subr.c index c251b16e..1730e737 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -33,17 +33,10 @@ * @(#)ffs_subr.c 8.2 (Berkeley) 9/21/93 */ -#include -#include - -#ifdef KERNEL -#include -#include -#include -#include -#include -#include +#include "ufs.h" +#include "fs.h" +#if 0 /* Not needed in GNU Hurd ufs. */ /* * Return buffer with the contents of block "offset" from the beginning of * directory "ip". If "res" is non-zero, fill it in with a pointer to the @@ -79,7 +72,7 @@ ffs_blkatoff(ap) *ap->a_bpp = bp; return (0); } -#endif +#endif /* 0 */ /* * Update the frsum fields to reflect addition or deletion @@ -87,7 +80,7 @@ ffs_blkatoff(ap) */ void ffs_fragacct(fs, fragmap, fraglist, cnt) - struct fs *fs; + struct fs *fs; int fragmap; long fraglist[]; int cnt; @@ -116,7 +109,7 @@ ffs_fragacct(fs, fragmap, fraglist, cnt) } } -#if defined(KERNEL) && defined(DIAGNOSTIC) +#if 0 /* Not needed in GNU Hurd ufs. */ void ffs_checkoverlap(bp, ip) struct buf *bp; @@ -148,7 +141,7 @@ ffs_checkoverlap(bp, ip) panic("Disk buffer overlap"); } } -#endif /* DIAGNOSTIC */ +#endif /* 0 */ /* * block operations -- cgit v1.2.3 From 021e49868b745d1c0d20bca96fab3b5ed3decfc2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 20:09:50 +0000 Subject: Formerly alloc.c.~11~ --- ufs/alloc.c | 2150 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 1284 insertions(+), 866 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 193e0f31..cdd2e4b2 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,65 +1,67 @@ -/* Disk allocation routines - Copyright (C) 1993, 1994 Free Software Foundation - -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. */ - -/* Modified from UCB by Michael I. Bushnell. */ - /* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. * - * Redistribution is only permitted until one year after the first shipment - * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and - * binary forms are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * @(#)ufs_alloc.c 7.20 (Berkeley) 6/28/90 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ffs_alloc.c 8.8 (Berkeley) 2/21/94 */ -#include "ufs.h" -#include "fs.h" -#include "dinode.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include -#include +#include +#include -static u_long alloccg (int, daddr_t, int); -static u_long ialloccg (int, daddr_t, int); -static u_long hashalloc (int, long, int, u_long(*)(int, daddr_t, int)); -static daddr_t fragextend (int, long, int, int); -static daddr_t alloccgblk (struct cg *, daddr_t); -static daddr_t mapsearch (struct cg *, daddr_t, int); -static ino_t dirpref (); +#include +#include -/* These are in tables.c. */ -extern int inside[], around[]; -extern unsigned char *fragtbl[]; +extern u_long nextgennumber; -static spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; +static daddr_t ffs_alloccg __P((struct inode *, int, daddr_t, int)); +static daddr_t ffs_alloccgblk __P((struct fs *, struct cg *, daddr_t)); +static daddr_t ffs_clusteralloc __P((struct inode *, int, daddr_t, int)); +static ino_t ffs_dirpref __P((struct fs *)); +static daddr_t ffs_fragextend __P((struct inode *, int, long, int, int)); +static void ffs_fserr __P((struct fs *, u_int, char *)); +static u_long ffs_hashalloc + __P((struct inode *, int, long, int, u_long (*)())); +static ino_t ffs_nodealloccg __P((struct inode *, int, daddr_t, int)); +static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); /* * Allocate a block in the file system. @@ -80,51 +82,60 @@ static spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; * 2) quadradically rehash into other cylinder groups, until an * available block is located. */ -error_t -alloc(struct node *np, - daddr_t lbn, - daddr_t bpref, - int size, - daddr_t *bnp, - struct protid *cred) +ffs_alloc(ip, lbn, bpref, size, cred, bnp) + register struct inode *ip; + daddr_t lbn, bpref; + int size; + struct ucred *cred; + daddr_t *bnp; { - int cg; - daddr_t bno; - - *bnp = 0; - assert ("Alloc of bad sized block" && (unsigned) size <= sblock->fs_bsize - && !fragoff(size) && size != 0); - - spin_lock (&alloclock); - - if (size == sblock->fs_bsize && sblock->fs_cstotal.cs_nbfree == 0) - goto nospace; - if (cred && !diskfs_isuid (0, cred) && freespace(sblock->fs_minfree) <= 0) - goto nospace; - - if (bpref >= sblock->fs_size) - bpref = 0; - if (bpref == 0) - cg = itog(np->dn->number); - else - cg = dtog(bpref); - bno = (daddr_t)hashalloc(cg, (long)bpref, size, alloccg); - - spin_unlock (&alloclock); - - if (bno > 0) - { - np->dn_stat.st_blocks += btodb(size); - np->dn_set_mtime = 1; - np->dn_set_ctime = 1; - *bnp = bno; - return 0; - } - - nospace: - spin_unlock (&alloclock); - printf("file system full\n"); - return (ENOSPC); + register struct fs *fs; + daddr_t bno; + int cg, error; + + *bnp = 0; + fs = ip->i_fs; +#ifdef DIAGNOSTIC + if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { + printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", + ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); + panic("ffs_alloc: bad size"); + } + if (cred == NOCRED) + panic("ffs_alloc: missing credential\n"); +#endif /* DIAGNOSTIC */ + if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) + goto nospace; + if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) + goto nospace; +#ifdef QUOTA + if (error = chkdq(ip, (long)btodb(size), cred, 0)) + return (error); +#endif + if (bpref >= fs->fs_size) + bpref = 0; + if (bpref == 0) + cg = ino_to_cg(fs, ip->i_number); + else + cg = dtog(fs, bpref); + bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size, + (u_long (*)())ffs_alloccg); + if (bno > 0) { + ip->i_blocks += btodb(size); + ip->i_flag |= IN_CHANGE | IN_UPDATE; + *bnp = bno; + return (0); + } +#ifdef QUOTA + /* + * Restore user's disk quota because allocation failed. + */ + (void) chkdq(ip, (long)-btodb(size), cred, FORCE); +#endif +nospace: + ffs_fserr(fs, cred->cr_uid, "file system full"); + uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); + return (ENOSPC); } /* @@ -135,179 +146,386 @@ alloc(struct node *np, * the original block. Failing that, the regular block allocator is * invoked to get an appropriate block. */ -error_t -realloccg(struct node *np, - daddr_t lbprev, - volatile daddr_t bpref, - int osize, - int nsize, - daddr_t *pbn, - struct protid *cred) +ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) + register struct inode *ip; + daddr_t lbprev; + daddr_t bpref; + int osize, nsize; + struct ucred *cred; + struct buf **bpp; { - volatile int cg, request; - daddr_t bprev, bno; - error_t error; - - *pbn = 0; - assert ("bad old size" && (unsigned) osize <= sblock->fs_bsize - && !fragoff (osize) && osize != 0 ); - assert ("bad new size" && (unsigned) nsize <= sblock->fs_bsize - && !fragoff (nsize) && nsize != 0); - - spin_lock (&alloclock); - - if (cred && !diskfs_isuid (0, cred) && freespace(sblock->fs_minfree) <= 0) - { - spin_unlock (&alloclock); - goto nospace; - } - - if (error = diskfs_catch_exception ()) - return error; - bprev = dinodes[np->dn->number].di_db[lbprev]; - diskfs_end_catch_exception (); - assert ("old block not allocated" && bprev); + register struct fs *fs; + struct buf *bp; + int cg, request, error; + daddr_t bprev, bno; + + *bpp = 0; + fs = ip->i_fs; +#ifdef DIAGNOSTIC + if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || + (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { + printf( + "dev = 0x%x, bsize = %d, osize = %d, nsize = %d, fs = %s\n", + ip->i_dev, fs->fs_bsize, osize, nsize, fs->fs_fsmnt); + panic("ffs_realloccg: bad size"); + } + if (cred == NOCRED) + panic("ffs_realloccg: missing credential\n"); +#endif /* DIAGNOSTIC */ + if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) + goto nospace; + if ((bprev = ip->i_db[lbprev]) == 0) { + printf("dev = 0x%x, bsize = %d, bprev = %d, fs = %s\n", + ip->i_dev, fs->fs_bsize, bprev, fs->fs_fsmnt); + panic("ffs_realloccg: bad bprev"); + } + /* + * Allocate the extra space in the buffer. + */ + if (error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp)) { + brelse(bp); + return (error); + } +#ifdef QUOTA + if (error = chkdq(ip, (long)btodb(nsize - osize), cred, 0)) { + brelse(bp); + return (error); + } +#endif + /* + * Check for extension in the existing location. + */ + cg = dtog(fs, bprev); + if (bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) { + if (bp->b_blkno != fsbtodb(fs, bno)) + panic("bad blockno"); + ip->i_blocks += btodb(nsize - osize); + ip->i_flag |= IN_CHANGE | IN_UPDATE; + allocbuf(bp, nsize); + bp->b_flags |= B_DONE; + bzero((char *)bp->b_data + osize, (u_int)nsize - osize); + *bpp = bp; + return (0); + } + /* + * Allocate a new disk location. + */ + if (bpref >= fs->fs_size) + bpref = 0; + switch ((int)fs->fs_optim) { + case FS_OPTSPACE: + /* + * Allocate an exact sized fragment. Although this makes + * best use of space, we will waste time relocating it if + * the file continues to grow. If the fragmentation is + * less than half of the minimum free reserve, we choose + * to begin optimizing for time. + */ + request = nsize; + if (fs->fs_minfree < 5 || + fs->fs_cstotal.cs_nffree > + fs->fs_dsize * fs->fs_minfree / (2 * 100)) + break; + log(LOG_NOTICE, "%s: optimization changed from SPACE to TIME\n", + fs->fs_fsmnt); + fs->fs_optim = FS_OPTTIME; + break; + case FS_OPTTIME: + /* + * At this point we have discovered a file that is trying to + * grow a small fragment to a larger fragment. To save time, + * we allocate a full sized block, then free the unused portion. + * If the file continues to grow, the `ffs_fragextend' call + * above will be able to grow it in place without further + * copying. If aberrant programs cause disk fragmentation to + * grow within 2% of the free reserve, we choose to begin + * optimizing for space. + */ + request = fs->fs_bsize; + if (fs->fs_cstotal.cs_nffree < + fs->fs_dsize * (fs->fs_minfree - 2) / 100) + break; + log(LOG_NOTICE, "%s: optimization changed from TIME to SPACE\n", + fs->fs_fsmnt); + fs->fs_optim = FS_OPTSPACE; + break; + default: + printf("dev = 0x%x, optim = %d, fs = %s\n", + ip->i_dev, fs->fs_optim, fs->fs_fsmnt); + panic("ffs_realloccg: bad optim"); + /* NOTREACHED */ + } + bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request, + (u_long (*)())ffs_alloccg); + if (bno > 0) { + bp->b_blkno = fsbtodb(fs, bno); + (void) vnode_pager_uncache(ITOV(ip)); + ffs_blkfree(ip, bprev, (long)osize); + if (nsize < request) + ffs_blkfree(ip, bno + numfrags(fs, nsize), + (long)(request - nsize)); + ip->i_blocks += btodb(nsize - osize); + ip->i_flag |= IN_CHANGE | IN_UPDATE; + allocbuf(bp, nsize); + bp->b_flags |= B_DONE; + bzero((char *)bp->b_data + osize, (u_int)nsize - osize); + *bpp = bp; + return (0); + } +#ifdef QUOTA + /* + * Restore user's disk quota because allocation failed. + */ + (void) chkdq(ip, (long)-btodb(nsize - osize), cred, FORCE); +#endif + brelse(bp); +nospace: + /* + * no space available + */ + ffs_fserr(fs, cred->cr_uid, "file system full"); + uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); + return (ENOSPC); +} - /* - * Check for extension in the existing location. - */ - cg = dtog(bprev); - if (bno = fragextend(cg, (long)bprev, osize, nsize)) - { - spin_unlock (&alloclock); - assert ("fragextend behaved incorrectly" && bprev == bno); - np->dn_stat.st_blocks += btodb(nsize - osize); - np->dn_set_mtime = 1; - np->dn_set_ctime = 1; - *pbn = bno; - return (0); - } - /* - * Allocate a new disk location. - */ - if (bpref >= sblock->fs_size) - bpref = 0; - switch ((int)sblock->fs_optim) - { - case FS_OPTSPACE: - /* - * Allocate an exact sized fragment. Although this makes - * best use of space, we will waste time relocating it if - * the file continues to grow. If the fragmentation is - * less than half of the minimum free reserve, we choose - * to begin optimizing for time. - */ - request = nsize; - if (sblock->fs_minfree < 5 || - sblock->fs_cstotal.cs_nffree > - sblock->fs_dsize * sblock->fs_minfree / (2 * 100)) - break; - printf("optimization changed from SPACE to TIME\n"); - sblock->fs_optim = FS_OPTTIME; - break; - case FS_OPTTIME: - /* - * At this point we have discovered a file that is trying - * to grow a small fragment to a larger fragment. To save - * time, we allocate a full sized block, then free the - * unused portion. If the file continues to grow, the - * `fragextend' call above will be able to grow it in place - * without further copying. If aberrant programs cause - * disk fragmentation to grow within 2% of the free reserve, - * we choose to begin optimizing for space. - */ - request = sblock->fs_bsize; - if (sblock->fs_cstotal.cs_nffree < - sblock->fs_dsize * (sblock->fs_minfree - 2) / 100) - break; - printf("%s: optimization changed from TIME to SPACE\n", - sblock->fs_fsmnt); - sblock->fs_optim = FS_OPTSPACE; - break; - default: - assert ("filesystem opitimazation bad value" && 0); - } - - bno = (daddr_t)hashalloc(cg, (long)bpref, request, - (u_long (*)())alloccg); +/* + * Reallocate a sequence of blocks into a contiguous sequence of blocks. + * + * The vnode and an array of buffer pointers for a range of sequential + * 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 + * 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. + * Note that the error return is not reflected back to the user. Rather + * the previous block allocation will be used. + */ +#include +int doasyncfree = 1; +struct ctldebug debug14 = { "doasyncfree", &doasyncfree }; +int +ffs_reallocblks(ap) + struct vop_reallocblks_args /* { + struct vnode *a_vp; + struct cluster_save *a_buflist; + } */ *ap; +{ + struct fs *fs; + struct inode *ip; + struct vnode *vp; + struct buf *sbp, *ebp; + daddr_t *bap, *sbap, *ebap; + struct cluster_save *buflist; + daddr_t start_lbn, end_lbn, soff, eoff, newblk, blkno; + struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp; + int i, len, start_lvl, end_lvl, pref, ssize; - spin_unlock (&alloclock); + vp = ap->a_vp; + ip = VTOI(vp); + fs = ip->i_fs; + if (fs->fs_contigsumsize <= 0) + return (ENOSPC); + buflist = ap->a_buflist; + len = buflist->bs_nchildren; + start_lbn = buflist->bs_children[0]->b_lblkno; + end_lbn = start_lbn + len - 1; +#ifdef DIAGNOSTIC + for (i = 1; i < len; i++) + if (buflist->bs_children[i]->b_lblkno != start_lbn + i) + panic("ffs_reallocblks: non-cluster"); +#endif + /* + * If the latest allocation is in a new cylinder group, assume that + * the filesystem has decided to move and do not force it back to + * the previous cylinder group. + */ + if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) != + dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno))) + return (ENOSPC); + if (ufs_getlbns(vp, start_lbn, start_ap, &start_lvl) || + ufs_getlbns(vp, end_lbn, end_ap, &end_lvl)) + return (ENOSPC); + /* + * Get the starting offset and block map for the first block. + */ + if (start_lvl == 0) { + sbap = &ip->i_db[0]; + soff = start_lbn; + } else { + idp = &start_ap[start_lvl - 1]; + if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, NOCRED, &sbp)) { + brelse(sbp); + return (ENOSPC); + } + sbap = (daddr_t *)sbp->b_data; + soff = idp->in_off; + } + /* + * Find the preferred location for the cluster. + */ + pref = ffs_blkpref(ip, start_lbn, soff, sbap); + /* + * If the block range spans two block maps, get the second map. + */ + if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) { + ssize = len; + } else { +#ifdef DIAGNOSTIC + if (start_ap[start_lvl-1].in_lbn == idp->in_lbn) + panic("ffs_reallocblk: start == end"); +#endif + ssize = len - (idp->in_off + 1); + if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, NOCRED, &ebp)) + goto fail; + ebap = (daddr_t *)ebp->b_data; + } + /* + * Search the block map looking for an allocation of the desired size. + */ + if ((newblk = (daddr_t)ffs_hashalloc(ip, dtog(fs, pref), (long)pref, + len, (u_long (*)())ffs_clusteralloc)) == 0) + goto fail; + /* + * We have found a new contiguous block. + * + * First we have to replace the old block pointers with the new + * block pointers in the inode and indirect blocks associated + * with the file. + */ + blkno = newblk; + for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->fs_frag) { + if (i == ssize) + bap = ebap; +#ifdef DIAGNOSTIC + if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) + panic("ffs_reallocblks: alloc mismatch"); +#endif + *bap++ = blkno; + } + /* + * Next we must write out the modified inode and indirect blocks. + * For strict correctness, the writes should be synchronous since + * the old block values may have been written to disk. In practise + * they are almost never written, but if we are concerned about + * strict correctness, the `doasyncfree' flag should be set to zero. + * + * The test on `doasyncfree' should be changed to test a flag + * that shows whether the associated buffers and inodes have + * been written. The flag should be set when the cluster is + * started and cleared whenever the buffer or inode is flushed. + * We can then check below to see if it is set, and do the + * synchronous write only when it has been cleared. + */ + if (sbap != &ip->i_db[0]) { + if (doasyncfree) + bdwrite(sbp); + else + bwrite(sbp); + } else { + ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (!doasyncfree) + VOP_UPDATE(vp, &time, &time, MNT_WAIT); + } + if (ssize < len) + if (doasyncfree) + bdwrite(ebp); + else + bwrite(ebp); + /* + * Last, free the old blocks and assign the new blocks to the buffers. + */ + for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) { + ffs_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno), + fs->fs_bsize); + buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); + } + return (0); - if (bno > 0) - { - blkfree(bprev, (off_t)osize); - if (nsize < request) - blkfree(bno + numfrags(nsize), (off_t)(request - nsize)); - np->dn_stat.st_blocks += btodb (nsize - osize); - np->dn_set_mtime = 1; - np->dn_set_ctime = 1; - *pbn = bno; - return (0); - } - nospace: - /* - * no space available - */ - printf("file system full\n"); - return (ENOSPC); +fail: + if (ssize < len) + brelse(ebp); + if (sbap != &ip->i_db[0]) + brelse(sbp); + return (ENOSPC); } - -/* Implement the diskfs_alloc_node callback from the diskfs library. - See for the interface description. */ -error_t -diskfs_alloc_node(struct node *dir, - mode_t mode, - struct node **npp) +/* + * Allocate an inode in the file system. + * + * If allocating a directory, use ffs_dirpref to select the inode. + * If allocating in a directory, the following hierarchy is followed: + * 1) allocate the preferred inode. + * 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 + * to allocate an inode: + * 1) allocate an inode in cylinder group 0. + * 2) quadradically rehash into other cylinder groups, until an + * available inode is located. + */ +ffs_valloc(ap) + struct vop_valloc_args /* { + struct vnode *a_pvp; + int a_mode; + struct ucred *a_cred; + struct vnode **a_vpp; + } */ *ap; { - int ino; - struct node *np; - int cg; - error_t error; - int ipref; - - if (S_ISDIR (mode)) - ipref = dirpref (); - else - ipref = dir->dn->number; - - *npp = 0; + register struct vnode *pvp = ap->a_pvp; + register struct inode *pip; + register struct fs *fs; + register struct inode *ip; + mode_t mode = ap->a_mode; + ino_t ino, ipref; + int cg, error; + + *ap->a_vpp = NULL; + pip = VTOI(pvp); + fs = pip->i_fs; + if (fs->fs_cstotal.cs_nifree == 0) + goto noinodes; - spin_lock (&alloclock); - if (sblock->fs_cstotal.cs_nifree == 0) - { - spin_unlock (&alloclock); - goto noinodes; - } - if (ipref >= sblock->fs_ncg * sblock->fs_ipg) - ipref = 0; - cg = itog(ipref); - ino = (int)hashalloc(cg, (long)ipref, mode, ialloccg); - spin_unlock (&alloclock); - if (ino == 0) - goto noinodes; - if (error = iget(ino, &np)) - return error; - *npp = np; - assert ("duplicate allocation" && !np->dn_stat.st_mode); - if (np->dn_stat.st_blocks) - { - printf("free inode %d had %d blocks\n", ino, np->dn_stat.st_blocks); - np->dn_stat.st_blocks = 0; - np->dn_set_ctime = 1; - } - /* - * Set up a new generation number for this inode. - */ - spin_lock (&gennumberlock); - if (++nextgennumber < (u_long)diskfs_mtime->seconds) - nextgennumber = diskfs_mtime->seconds; - np->dn_stat.st_gen = nextgennumber; - spin_unlock (&gennumberlock); - return (0); - noinodes: - printf("out of inodes\n"); - return (ENOSPC); + if ((mode & IFMT) == IFDIR) + ipref = ffs_dirpref(fs); + else + ipref = pip->i_number; + if (ipref >= fs->fs_ncg * fs->fs_ipg) + ipref = 0; + cg = ino_to_cg(fs, ipref); + ino = (ino_t)ffs_hashalloc(pip, cg, (long)ipref, mode, ffs_nodealloccg); + if (ino == 0) + goto noinodes; + error = VFS_VGET(pvp->v_mount, ino, ap->a_vpp); + if (error) { + VOP_VFREE(pvp, ino, mode); + return (error); + } + ip = VTOI(*ap->a_vpp); + if (ip->i_mode) { + printf("mode = 0%o, inum = %d, fs = %s\n", + ip->i_mode, ip->i_number, fs->fs_fsmnt); + panic("ffs_valloc: dup alloc"); + } + if (ip->i_blocks) { /* XXX */ + printf("free inode %s/%d had %d blocks\n", + fs->fs_fsmnt, ino, ip->i_blocks); + ip->i_blocks = 0; + } + ip->i_flags = 0; + /* + * Set up a new generation number for this inode. + */ + if (++nextgennumber < (u_long)time.tv_sec) + nextgennumber = time.tv_sec; + ip->i_gen = nextgennumber; + return (0); +noinodes: + ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); + uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); + return (ENOSPC); } /* @@ -318,22 +536,21 @@ diskfs_alloc_node(struct node *dir, * free inodes, the one with the smallest number of directories. */ static ino_t -dirpref() +ffs_dirpref(fs) + register struct fs *fs; { - int cg, minndir, mincg, avgifree; - - spin_lock (&alloclock); - avgifree = sblock->fs_cstotal.cs_nifree / sblock->fs_ncg; - minndir = sblock->fs_ipg; - mincg = 0; - for (cg = 0; cg < sblock->fs_ncg; cg++) - if (csum[cg].cs_ndir < minndir && csum[cg].cs_nifree >= avgifree) - { - mincg = cg; - minndir = csum[cg].cs_ndir; - } - spin_unlock (&alloclock); - return ((int)(sblock->fs_ipg * mincg)); + int cg, minndir, mincg, avgifree; + + avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; + minndir = fs->fs_ipg; + mincg = 0; + for (cg = 0; cg < fs->fs_ncg; cg++) + if (fs->fs_cs(fs, cg).cs_ndir < minndir && + fs->fs_cs(fs, cg).cs_nifree >= avgifree) { + mincg = cg; + minndir = fs->fs_cs(fs, cg).cs_ndir; + } + return ((ino_t)(fs->fs_ipg * mincg)); } /* @@ -363,75 +580,66 @@ dirpref() * schedule another I/O transfer. */ daddr_t -blkpref(struct node *np, - daddr_t lbn, - int indx, - daddr_t *bap) +ffs_blkpref(ip, lbn, indx, bap) + struct inode *ip; + daddr_t lbn; + int indx; + daddr_t *bap; { - int cg; - int avgbfree, startcg; - daddr_t nextblk; - - spin_lock (&alloclock); - if (indx % sblock->fs_maxbpg == 0 || bap[indx - 1] == 0) - { - if (lbn < NDADDR) - { - spin_unlock (&alloclock); - cg = itog(np->dn->number); - return (sblock->fs_fpg * cg + sblock->fs_frag); - } - /* - * Find a cylinder with greater than average number of - * unused data blocks. - */ - if (indx == 0 || bap[indx - 1] == 0) - startcg = itog(np->dn->number) + lbn / sblock->fs_maxbpg; - else - startcg = dtog(bap[indx - 1]) + 1; - startcg %= sblock->fs_ncg; - avgbfree = sblock->fs_cstotal.cs_nbfree / sblock->fs_ncg; - for (cg = startcg; cg < sblock->fs_ncg; cg++) - if (csum[cg].cs_nbfree >= avgbfree) - { - spin_unlock (&alloclock); - sblock->fs_cgrotor = cg; - return (sblock->fs_fpg * cg + sblock->fs_frag); - } - for (cg = 0; cg <= startcg; cg++) - if (csum[cg].cs_nbfree >= avgbfree) - { - spin_unlock (&alloclock); - sblock->fs_cgrotor = cg; - return (sblock->fs_fpg * cg + sblock->fs_frag); - } - spin_unlock (&alloclock); - return 0; - } + register struct fs *fs; + register int cg; + int avgbfree, startcg; + daddr_t nextblk; - spin_unlock (&alloclock); - - /* - * One or more previous blocks have been laid out. If less - * than fs_maxcontig previous blocks are contiguous, the - * next block is requested contiguously, otherwise it is - * requested rotationally delayed by fs_rotdelay milliseconds. - */ - nextblk = bap[indx - 1] + sblock->fs_frag; - if (indx > sblock->fs_maxcontig && - bap[indx - sblock->fs_maxcontig] + blkstofrags(sblock->fs_maxcontig) - != nextblk) - return (nextblk); - if (sblock->fs_rotdelay != 0) - /* - * Here we convert ms of delay to frags as: - * (frags) = (ms) * (rev/sec) * (sect/rev) / - * ((sect/frag) * (ms/sec)) - * then round up to the next block. - */ - nextblk += roundup(sblock->fs_rotdelay * sblock->fs_rps - * sblock->fs_nsect / (NSPF * 1000), sblock->fs_frag); - return (nextblk); + fs = ip->i_fs; + if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { + if (lbn < NDADDR) { + cg = ino_to_cg(fs, ip->i_number); + return (fs->fs_fpg * cg + fs->fs_frag); + } + /* + * Find a cylinder with greater than average number of + * unused data blocks. + */ + if (indx == 0 || bap[indx - 1] == 0) + startcg = + ino_to_cg(fs, ip->i_number) + lbn / fs->fs_maxbpg; + else + startcg = dtog(fs, bap[indx - 1]) + 1; + startcg %= fs->fs_ncg; + avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; + for (cg = startcg; cg < fs->fs_ncg; cg++) + if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { + fs->fs_cgrotor = cg; + return (fs->fs_fpg * cg + fs->fs_frag); + } + for (cg = 0; cg <= startcg; cg++) + if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { + fs->fs_cgrotor = cg; + return (fs->fs_fpg * cg + fs->fs_frag); + } + return (NULL); + } + /* + * One or more previous blocks have been laid out. If less + * than fs_maxcontig previous blocks are contiguous, the + * next block is requested contiguously, otherwise it is + * requested rotationally delayed by fs_rotdelay milliseconds. + */ + nextblk = bap[indx - 1] + fs->fs_frag; + if (indx < fs->fs_maxcontig || bap[indx - fs->fs_maxcontig] + + blkstofrags(fs, fs->fs_maxcontig) != nextblk) + return (nextblk); + if (fs->fs_rotdelay != 0) + /* + * Here we convert ms of delay to frags as: + * (frags) = (ms) * (rev/sec) * (sect/rev) / + * ((sect/frag) * (ms/sec)) + * then round up to the next block. + */ + nextblk += roundup(fs->fs_rotdelay * fs->fs_rps * fs->fs_nsect / + (NSPF(fs) * 1000), fs->fs_frag); + return (nextblk); } /* @@ -444,48 +652,50 @@ blkpref(struct node *np, */ /*VARARGS5*/ static u_long -hashalloc(int cg, - long pref, - int size, /* size for data blocks, mode for inodes */ - u_long (*allocator)(int, daddr_t, int)) +ffs_hashalloc(ip, cg, pref, size, allocator) + struct inode *ip; + int cg; + long pref; + int size; /* size for data blocks, mode for inodes */ + u_long (*allocator)(); { - long result; - int i, icg = cg; - - /* - * 1: preferred cylinder group - */ - result = (*allocator)(cg, pref, size); - if (result) - return (result); - /* - * 2: quadratic rehash - */ - for (i = 1; i < sblock->fs_ncg; i *= 2) - { - cg += i; - if (cg >= sblock->fs_ncg) - cg -= sblock->fs_ncg; - result = (*allocator)(cg, 0, size); - if (result) - return (result); - } - /* - * 3: brute force search - * Note that we start at i == 2, since 0 was checked initially, - * and 1 is always checked in the quadratic rehash. - */ - cg = (icg + 2) % sblock->fs_ncg; - for (i = 2; i < sblock->fs_ncg; i++) - { - result = (*allocator)(cg, 0, size); - if (result) - return (result); - cg++; - if (cg == sblock->fs_ncg) - cg = 0; - } - return 0; + register struct fs *fs; + long result; + int i, icg = cg; + + fs = ip->i_fs; + /* + * 1: preferred cylinder group + */ + result = (*allocator)(ip, cg, pref, size); + if (result) + return (result); + /* + * 2: quadratic rehash + */ + for (i = 1; i < fs->fs_ncg; i *= 2) { + cg += i; + if (cg >= fs->fs_ncg) + cg -= fs->fs_ncg; + result = (*allocator)(ip, cg, 0, size); + if (result) + return (result); + } + /* + * 3: brute force search + * Note that we start at i == 2, since 0 was checked initially, + * and 1 is always checked in the quadratic rehash. + */ + cg = (icg + 2) % fs->fs_ncg; + for (i = 2; i < fs->fs_ncg; i++) { + result = (*allocator)(ip, cg, 0, size); + if (result) + return (result); + cg++; + if (cg == fs->fs_ncg) + cg = 0; + } + return (NULL); } /* @@ -495,154 +705,156 @@ hashalloc(int cg, * if they are, allocate them. */ static daddr_t -fragextend(int cg, - long bprev, - int osize, - int nsize) +ffs_fragextend(ip, cg, bprev, osize, nsize) + struct inode *ip; + int cg; + long bprev; + int osize, nsize; { - struct cg *cgp; - long bno; - int frags, bbase; - int i; - - if (csum[cg].cs_nffree < numfrags(nsize - osize)) - return 0; - frags = numfrags(nsize); - bbase = fragnum(bprev); - if (bbase > fragnum((bprev + frags - 1))) - /* cannot extend across a block boundary */ - return 0; + register struct fs *fs; + register struct cg *cgp; + struct buf *bp; + long bno; + int frags, bbase; + int i, error; - cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); - - if (diskfs_catch_exception ()) - return 0; /* bogus, but that's what BSD does... */ - - if (!cg_chkmagic(cgp)) - { - printf ("Cylinder group %d bad magic number: %ld/%ld\n", - cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); - diskfs_end_catch_exception (); - return 0; - } - cgp->cg_time = diskfs_mtime->seconds; - bno = dtogd(bprev); - for (i = numfrags(osize); i < frags; i++) - if (isclr(cg_blksfree(cgp), bno + i)) - { - diskfs_end_catch_exception (); - return 0; - } - - /* - * the current fragment can be extended - * deduct the count on fragment being extended into - * increase the count on the remaining fragment (if any) - * allocate the extended piece - */ - for (i = frags; i < sblock->fs_frag - bbase; i++) - if (isclr(cg_blksfree(cgp), bno + i)) - break; - cgp->cg_frsum[i - numfrags(osize)]--; - if (i != frags) - cgp->cg_frsum[i - frags]++; - for (i = numfrags(osize); i < frags; i++) - { - clrbit(cg_blksfree(cgp), bno + i); - cgp->cg_cs.cs_nffree--; - sblock->fs_cstotal.cs_nffree--; - csum[cg].cs_nffree--; - } - diskfs_end_catch_exception (); - return (bprev); + fs = ip->i_fs; + if (fs->fs_cs(fs, cg).cs_nffree < numfrags(fs, nsize - osize)) + return (NULL); + frags = numfrags(fs, nsize); + bbase = fragnum(fs, bprev); + if (bbase > fragnum(fs, (bprev + frags - 1))) { + /* cannot extend across a block boundary */ + return (NULL); + } + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (NULL); + } + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp)) { + brelse(bp); + return (NULL); + } + cgp->cg_time = time.tv_sec; + bno = dtogd(fs, bprev); + for (i = numfrags(fs, osize); i < frags; i++) + if (isclr(cg_blksfree(cgp), bno + i)) { + brelse(bp); + return (NULL); + } + /* + * the current fragment can be extended + * deduct the count on fragment being extended into + * increase the count on the remaining fragment (if any) + * allocate the extended piece + */ + for (i = frags; i < fs->fs_frag - bbase; i++) + if (isclr(cg_blksfree(cgp), bno + i)) + break; + cgp->cg_frsum[i - numfrags(fs, osize)]--; + if (i != frags) + cgp->cg_frsum[i - frags]++; + for (i = numfrags(fs, osize); i < frags; i++) { + clrbit(cg_blksfree(cgp), bno + i); + cgp->cg_cs.cs_nffree--; + fs->fs_cstotal.cs_nffree--; + fs->fs_cs(fs, cg).cs_nffree--; + } + fs->fs_fmod = 1; + bdwrite(bp); + return (bprev); } /* * Determine whether a block can be allocated. * - * Check to see if a block of the apprpriate size is available, + * Check to see if a block of the appropriate size is available, * and if it is, allocate it. */ -static u_long -alloccg(int cg, - volatile daddr_t bpref, - int size) +static daddr_t +ffs_alloccg(ip, cg, bpref, size) + struct inode *ip; + int cg; + daddr_t bpref; + int size; { - struct cg *cgp; - int i; - int bno, frags, allocsiz; - - if (csum[cg].cs_nbfree == 0 && size == sblock->fs_bsize) - return 0; - cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); + register struct fs *fs; + register struct cg *cgp; + struct buf *bp; + register int i; + int error, bno, frags, allocsiz; - if (diskfs_catch_exception ()) - return 0; - - if (!cg_chkmagic(cgp) || - (cgp->cg_cs.cs_nbfree == 0 && size == sblock->fs_bsize)) - { - printf ("Cylinder group %d bad magic number: %ld/%ld\n", - cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); - diskfs_end_catch_exception (); - return 0; - } - cgp->cg_time = diskfs_mtime->seconds; - if (size == sblock->fs_bsize) - { - bno = alloccgblk(cgp, bpref); - diskfs_end_catch_exception (); - return (u_long) (bno); - } - /* - * check to see if any fragments are already available - * allocsiz is the size which will be allocated, hacking - * it down to a smaller size if necessary - */ - frags = numfrags(size); - for (allocsiz = frags; allocsiz < sblock->fs_frag; allocsiz++) - if (cgp->cg_frsum[allocsiz] != 0) - break; - if (allocsiz == sblock->fs_frag) - { - /* - * no fragments were available, so a block will be - * allocated, and hacked up - */ - if (cgp->cg_cs.cs_nbfree == 0) - { - diskfs_end_catch_exception (); - return 0; + fs = ip->i_fs; + if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) + return (NULL); + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (NULL); } - - bno = alloccgblk(cgp, bpref); - bpref = dtogd(bno); - for (i = frags; i < sblock->fs_frag; i++) - setbit(cg_blksfree(cgp), bpref + i); - i = sblock->fs_frag - frags; - cgp->cg_cs.cs_nffree += i; - sblock->fs_cstotal.cs_nffree += i; - csum[cg].cs_nffree += i; - cgp->cg_frsum[i]++; - return (u_long)(bno); - } - bno = mapsearch(cgp, bpref, allocsiz); - if (bno < 0) - { - diskfs_end_catch_exception (); - return 0; - } - - for (i = 0; i < frags; i++) - clrbit(cg_blksfree(cgp), bno + i); - cgp->cg_cs.cs_nffree -= frags; - sblock->fs_cstotal.cs_nffree -= frags; - csum[cg].cs_nffree -= frags; - cgp->cg_frsum[allocsiz]--; - if (frags != allocsiz) - cgp->cg_frsum[allocsiz - frags]++; - diskfs_end_catch_exception (); - return (u_long) (cg * sblock->fs_fpg + bno); + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp) || + (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { + brelse(bp); + return (NULL); + } + cgp->cg_time = time.tv_sec; + if (size == fs->fs_bsize) { + bno = ffs_alloccgblk(fs, cgp, bpref); + bdwrite(bp); + return (bno); + } + /* + * check to see if any fragments are already available + * allocsiz is the size which will be allocated, hacking + * it down to a smaller size if necessary + */ + frags = numfrags(fs, size); + for (allocsiz = frags; allocsiz < fs->fs_frag; allocsiz++) + if (cgp->cg_frsum[allocsiz] != 0) + break; + if (allocsiz == fs->fs_frag) { + /* + * no fragments were available, so a block will be + * allocated, and hacked up + */ + if (cgp->cg_cs.cs_nbfree == 0) { + brelse(bp); + return (NULL); + } + bno = ffs_alloccgblk(fs, cgp, bpref); + bpref = dtogd(fs, bno); + for (i = frags; i < fs->fs_frag; i++) + setbit(cg_blksfree(cgp), bpref + i); + i = fs->fs_frag - frags; + cgp->cg_cs.cs_nffree += i; + fs->fs_cstotal.cs_nffree += i; + fs->fs_cs(fs, cg).cs_nffree += i; + fs->fs_fmod = 1; + cgp->cg_frsum[i]++; + bdwrite(bp); + return (bno); + } + bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); + if (bno < 0) { + brelse(bp); + return (NULL); + } + for (i = 0; i < frags; i++) + clrbit(cg_blksfree(cgp), bno + i); + cgp->cg_cs.cs_nffree -= frags; + fs->fs_cstotal.cs_nffree -= frags; + fs->fs_cs(fs, cg).cs_nffree -= frags; + fs->fs_fmod = 1; + cgp->cg_frsum[allocsiz]--; + if (frags != allocsiz) + cgp->cg_frsum[allocsiz - frags]++; + bdwrite(bp); + return (cg * fs->fs_fpg + bno); } /* @@ -657,109 +869,196 @@ alloccg(int cg, * blocks may be fragmented by the routine that allocates them. */ static daddr_t -alloccgblk(struct cg *cgp, - volatile daddr_t bpref) +ffs_alloccgblk(fs, cgp, bpref) + register struct fs *fs; + register struct cg *cgp; + daddr_t bpref; { - daddr_t bno; - int cylno, pos, delta; - short *cylbp; - int i; - daddr_t ret; - - if (diskfs_catch_exception ()) - return 0; - - if (bpref == 0) - { - bpref = cgp->cg_rotor; - goto norot; - } - bpref = blknum(bpref); - bpref = dtogd(bpref); - /* - * if the requested block is available, use it - */ - if (isblock(cg_blksfree(cgp), fragstoblks(bpref))) - { - bno = bpref; - goto gotit; - } - /* - * check for a block available on the same cylinder - */ - cylno = cbtocylno(bpref); - if (cg_blktot(cgp)[cylno] == 0) - goto norot; - if (sblock->fs_cpc == 0) - { - /* - * block layout info is not available, so just have - * to take any block in this cylinder. - */ - bpref = howmany(sblock->fs_spc * cylno, NSPF); - goto norot; - } - /* - * check the summary information to see if a block is - * available in the requested cylinder starting at the - * requested rotational position and proceeding around. - */ - cylbp = cg_blks(cgp, cylno); - pos = cbtorpos(bpref); - for (i = pos; i < sblock->fs_nrpos; i++) - if (cylbp[i] > 0) - break; - if (i == sblock->fs_nrpos) - for (i = 0; i < pos; i++) - if (cylbp[i] > 0) - break; - if (cylbp[i] > 0) - { - /* - * found a rotational position, now find the actual - * block. A panic if none is actually there. - */ - pos = cylno % sblock->fs_cpc; - bno = (cylno - pos) * sblock->fs_spc / NSPB; - assert ("postbl table bad" &&fs_postbl(pos)[i] != -1); - for (i = fs_postbl(pos)[i];; ) - { - if (isblock(cg_blksfree(cgp), bno + i)) - { - bno = blkstofrags(bno + i); - goto gotit; - } - delta = fs_rotbl[i]; - if (delta <= 0 || - delta + i > fragstoblks(sblock->fs_fpg)) - break; - i += delta; + daddr_t bno, blkno; + int cylno, pos, delta; + short *cylbp; + register int i; + + if (bpref == 0 || dtog(fs, bpref) != cgp->cg_cgx) { + bpref = cgp->cg_rotor; + goto norot; } - assert ("Inconsistent rotbl table" && 0); - } - norot: - /* - * no blocks in the requested cylinder, so take next - * available one in this cylinder group. - */ - bno = mapsearch(cgp, bpref, (int)sblock->fs_frag); - if (bno < 0) - { - diskfs_end_catch_exception (); - return 0; - } - cgp->cg_rotor = bno; - gotit: - clrblock(cg_blksfree(cgp), (long)fragstoblks(bno)); - cgp->cg_cs.cs_nbfree--; - sblock->fs_cstotal.cs_nbfree--; - csum[cgp->cg_cgx].cs_nbfree--; - cylno = cbtocylno(bno); - cg_blks(cgp, cylno)[cbtorpos(bno)]--; - cg_blktot(cgp)[cylno]--; - ret = cgp->cg_cgx * sblock->fs_fpg + bno; - diskfs_end_catch_exception (); - return ret; + bpref = blknum(fs, bpref); + bpref = dtogd(fs, bpref); + /* + * if the requested block is available, use it + */ + if (ffs_isblock(fs, cg_blksfree(cgp), fragstoblks(fs, bpref))) { + bno = bpref; + goto gotit; + } + /* + * check for a block available on the same cylinder + */ + cylno = cbtocylno(fs, bpref); + if (cg_blktot(cgp)[cylno] == 0) + goto norot; + if (fs->fs_cpc == 0) { + /* + * Block layout information is not available. + * Leaving bpref unchanged means we take the + * next available free block following the one + * we just allocated. Hopefully this will at + * least hit a track cache on drives of unknown + * geometry (e.g. SCSI). + */ + goto norot; + } + /* + * check the summary information to see if a block is + * available in the requested cylinder starting at the + * requested rotational position and proceeding around. + */ + cylbp = cg_blks(fs, cgp, cylno); + pos = cbtorpos(fs, bpref); + for (i = pos; i < fs->fs_nrpos; i++) + if (cylbp[i] > 0) + break; + if (i == fs->fs_nrpos) + for (i = 0; i < pos; i++) + if (cylbp[i] > 0) + break; + if (cylbp[i] > 0) { + /* + * found a rotational position, now find the actual + * block. A panic if none is actually there. + */ + pos = cylno % fs->fs_cpc; + bno = (cylno - pos) * fs->fs_spc / NSPB(fs); + if (fs_postbl(fs, pos)[i] == -1) { + printf("pos = %d, i = %d, fs = %s\n", + pos, i, fs->fs_fsmnt); + panic("ffs_alloccgblk: cyl groups corrupted"); + } + for (i = fs_postbl(fs, pos)[i];; ) { + if (ffs_isblock(fs, cg_blksfree(cgp), bno + i)) { + bno = blkstofrags(fs, (bno + i)); + goto gotit; + } + delta = fs_rotbl(fs)[i]; + if (delta <= 0 || + delta + i > fragstoblks(fs, fs->fs_fpg)) + break; + i += delta; + } + printf("pos = %d, i = %d, fs = %s\n", pos, i, fs->fs_fsmnt); + panic("ffs_alloccgblk: can't find blk in cyl"); + } +norot: + /* + * no blocks in the requested cylinder, so take next + * available one in this cylinder group. + */ + bno = ffs_mapsearch(fs, cgp, bpref, (int)fs->fs_frag); + if (bno < 0) + return (NULL); + cgp->cg_rotor = bno; +gotit: + blkno = fragstoblks(fs, bno); + ffs_clrblock(fs, cg_blksfree(cgp), (long)blkno); + ffs_clusteracct(fs, cgp, blkno, -1); + cgp->cg_cs.cs_nbfree--; + fs->fs_cstotal.cs_nbfree--; + fs->fs_cs(fs, cgp->cg_cgx).cs_nbfree--; + cylno = cbtocylno(fs, bno); + cg_blks(fs, cgp, cylno)[cbtorpos(fs, bno)]--; + cg_blktot(cgp)[cylno]--; + fs->fs_fmod = 1; + return (cgp->cg_cgx * fs->fs_fpg + bno); +} + +/* + * Determine whether a cluster can be allocated. + * + * We do not currently check for optimal rotational layout if there + * are multiple choices in the same cylinder group. Instead we just + * take the first one that we find following bpref. + */ +static daddr_t +ffs_clusteralloc(ip, cg, bpref, len) + struct inode *ip; + int cg; + daddr_t bpref; + int len; +{ + register struct fs *fs; + register struct cg *cgp; + struct buf *bp; + int i, run, bno, bit, map; + u_char *mapp; + + fs = ip->i_fs; + if (fs->fs_cs(fs, cg).cs_nbfree < len) + return (NULL); + if (bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, + NOCRED, &bp)) + goto fail; + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp)) + goto fail; + /* + * Check to see if a cluster of the needed size (or bigger) is + * available in this cylinder group. + */ + for (i = len; i <= fs->fs_contigsumsize; i++) + if (cg_clustersum(cgp)[i] > 0) + break; + if (i > fs->fs_contigsumsize) + goto fail; + /* + * Search the cluster map to find a big enough cluster. + * We take the first one that we find, even if it is larger + * than we need as we prefer to get one close to the previous + * block allocation. We do not search before the current + * preference point as we do not want to allocate a block + * that is allocated before the previous one (as we will + * then have to wait for another pass of the elevator + * algorithm before it will be read). We prefer to fail and + * be recalled to try an allocation in the next cylinder group. + */ + if (dtog(fs, bpref) != cg) + bpref = 0; + else + bpref = fragstoblks(fs, dtogd(fs, blknum(fs, bpref))); + mapp = &cg_clustersfree(cgp)[bpref / NBBY]; + map = *mapp++; + bit = 1 << (bpref % NBBY); + for (run = 0, i = bpref; i < cgp->cg_nclusterblks; i++) { + if ((map & bit) == 0) { + run = 0; + } else { + run++; + if (run == len) + break; + } + if ((i & (NBBY - 1)) != (NBBY - 1)) { + bit <<= 1; + } else { + map = *mapp++; + bit = 1; + } + } + if (i == cgp->cg_nclusterblks) + goto fail; + /* + * Allocate the cluster that we have found. + */ + bno = cg * fs->fs_fpg + blkstofrags(fs, i - run + 1); + len = blkstofrags(fs, len); + for (i = 0; i < len; i += fs->fs_frag) + if (ffs_alloccgblk(fs, cgp, bno + i) != bno + i) + panic("ffs_clusteralloc: lost block"); + brelse(bp); + return (bno); + +fail: + brelse(bp); + return (0); } /* @@ -771,72 +1070,77 @@ alloccgblk(struct cg *cgp, * 2) allocate the next available inode after the requested * inode in the specified cylinder group. */ -static u_long -ialloccg(int cg, - volatile daddr_t ipref, - int modein) +static ino_t +ffs_nodealloccg(ip, cg, ipref, mode) + struct inode *ip; + int cg; + daddr_t ipref; + int mode; { - struct cg *cgp; - int start, len, loc, map, i; - mode_t mode = (mode_t) modein; - - if (csum[cg].cs_nifree == 0) - return 0; - - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + register struct fs *fs; + register struct cg *cgp; + struct buf *bp; + int error, start, len, loc, map, i; - if (diskfs_catch_exception ()) - return 0; - - if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) - { - printf ("Cylinder group %d bad magic number: %ld/%ld\n", - cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); - diskfs_end_catch_exception (); - return 0; - } - cgp->cg_time = diskfs_mtime->seconds; - if (ipref) - { - ipref %= sblock->fs_ipg; - if (isclr(cg_inosused(cgp), ipref)) - goto gotit; - } - start = cgp->cg_irotor / NBBY; - len = howmany(sblock->fs_ipg - cgp->cg_irotor, NBBY); - loc = skpc(0xff, len, (u_char *) &cg_inosused(cgp)[start]); - if (loc == 0) - { - len = start + 1; - start = 0; - loc = skpc(0xff, len, (u_char *) &cg_inosused(cgp)[0]); - assert ("inconsistent cg_inosused table" && loc); - } - i = start + len - loc; - map = cg_inosused(cgp)[i]; - ipref = i * NBBY; - for (i = 1; i < (1 << NBBY); i <<= 1, ipref++) - { - if ((map & i) == 0) - { - cgp->cg_irotor = ipref; - goto gotit; + fs = ip->i_fs; + if (fs->fs_cs(fs, cg).cs_nifree == 0) + return (NULL); + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (NULL); + } + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { + brelse(bp); + return (NULL); + } + cgp->cg_time = time.tv_sec; + if (ipref) { + ipref %= fs->fs_ipg; + if (isclr(cg_inosused(cgp), ipref)) + goto gotit; + } + start = cgp->cg_irotor / NBBY; + len = howmany(fs->fs_ipg - cgp->cg_irotor, NBBY); + loc = skpc(0xff, len, &cg_inosused(cgp)[start]); + if (loc == 0) { + len = start + 1; + start = 0; + loc = skpc(0xff, len, &cg_inosused(cgp)[0]); + if (loc == 0) { + printf("cg = %d, irotor = %d, fs = %s\n", + cg, cgp->cg_irotor, fs->fs_fsmnt); + panic("ffs_nodealloccg: map corrupted"); + /* NOTREACHED */ + } + } + i = start + len - loc; + map = cg_inosused(cgp)[i]; + ipref = i * NBBY; + for (i = 1; i < (1 << NBBY); i <<= 1, ipref++) { + if ((map & i) == 0) { + cgp->cg_irotor = ipref; + goto gotit; + } + } + printf("fs = %s\n", fs->fs_fsmnt); + panic("ffs_nodealloccg: block not in map"); + /* NOTREACHED */ +gotit: + setbit(cg_inosused(cgp), ipref); + cgp->cg_cs.cs_nifree--; + fs->fs_cstotal.cs_nifree--; + fs->fs_cs(fs, cg).cs_nifree--; + fs->fs_fmod = 1; + if ((mode & IFMT) == IFDIR) { + cgp->cg_cs.cs_ndir++; + fs->fs_cstotal.cs_ndir++; + fs->fs_cs(fs, cg).cs_ndir++; } - } - assert ("inconsistent cg_inosused table" && 0); - gotit: - setbit(cg_inosused(cgp), ipref); - cgp->cg_cs.cs_nifree--; - sblock->fs_cstotal.cs_nifree--; - csum[cg].cs_nifree--; - if ((mode & IFMT) == IFDIR) - { - cgp->cg_cs.cs_ndir++; - sblock->fs_cstotal.cs_ndir++; - csum[cg].cs_ndir++; - } - diskfs_end_catch_exception (); - return (u_long)(cg * sblock->fs_ipg + ipref); + bdwrite(bp); + return (cg * fs->fs_ipg + ipref); } /* @@ -846,99 +1150,103 @@ ialloccg(int cg, * free map. If a fragment is deallocated, a possible * block reassembly is checked. */ -void -blkfree(volatile daddr_t bno, - int size) +ffs_blkfree(ip, bno, size) + register struct inode *ip; + daddr_t bno; + long size; { - struct cg *cgp; - int cg, blk, frags, bbase; - int i; - - assert ("free of bad sized block" &&(unsigned) size <= sblock->fs_bsize - && !fragoff (size) && size != 0); - cg = dtog(bno); - if ((unsigned)bno >= sblock->fs_size) - { - printf("bad block %ld\n", bno); - return; - } + register struct fs *fs; + register struct cg *cgp; + struct buf *bp; + daddr_t blkno; + int i, error, cg, blk, frags, bbase; - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); - - spin_lock (&alloclock); - - if (diskfs_catch_exception ()) - { - spin_unlock (&alloclock); - return; - } - - if (!cg_chkmagic(cgp)) - { - spin_unlock (&alloclock); - printf ("Cylinder group %d bad magic number: %ld/%ld\n", - cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); - diskfs_end_catch_exception (); - return; - } - cgp->cg_time = diskfs_mtime->seconds; - bno = dtogd(bno); - if (size == sblock->fs_bsize) - { - assert ("inconsistent cg_blskfree table" - && !isblock (cg_blksfree (cgp), fragstoblks (bno))); - setblock(cg_blksfree(cgp), fragstoblks(bno)); - cgp->cg_cs.cs_nbfree++; - sblock->fs_cstotal.cs_nbfree++; - csum[cg].cs_nbfree++; - i = cbtocylno(bno); - cg_blks(cgp, i)[cbtorpos(bno)]++; - cg_blktot(cgp)[i]++; - } - else - { - bbase = bno - fragnum(bno); - /* - * decrement the counts associated with the old frags - */ - blk = blkmap(cg_blksfree(cgp), bbase); - fragacct(blk, cgp->cg_frsum, -1); - /* - * deallocate the fragment - */ - frags = numfrags(size); - for (i = 0; i < frags; i++) - { - assert ("inconsistent cg_blksfree table" - && !isset (cg_blksfree (cgp), bno + i)); - setbit(cg_blksfree(cgp), bno + i); + fs = ip->i_fs; + if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { + printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", + ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); + panic("blkfree: bad size"); + } + cg = dtog(fs, bno); + if ((u_int)bno >= fs->fs_size) { + printf("bad block %d, ino %d\n", bno, ip->i_number); + ffs_fserr(fs, ip->i_uid, "bad block"); + return; } - cgp->cg_cs.cs_nffree += i; - sblock->fs_cstotal.cs_nffree += i; - csum[cg].cs_nffree += i; - /* - * add back in counts associated with the new frags - */ - blk = blkmap(cg_blksfree(cgp), bbase); - fragacct(blk, cgp->cg_frsum, 1); - /* - * if a complete block has been reassembled, account for it - */ - if (isblock(cg_blksfree(cgp), (daddr_t)fragstoblks(bbase))) - { - cgp->cg_cs.cs_nffree -= sblock->fs_frag; - sblock->fs_cstotal.cs_nffree -= sblock->fs_frag; - csum[cg].cs_nffree -= sblock->fs_frag; - cgp->cg_cs.cs_nbfree++; - sblock->fs_cstotal.cs_nbfree++; - csum[cg].cs_nbfree++; - i = cbtocylno(bbase); - cg_blks(cgp, i)[cbtorpos(bbase)]++; - cg_blktot(cgp)[i]++; + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + if (error) { + brelse(bp); + return; } - } - spin_unlock (&alloclock); - diskfs_end_catch_exception (); + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp)) { + brelse(bp); + return; + } + cgp->cg_time = time.tv_sec; + bno = dtogd(fs, bno); + if (size == fs->fs_bsize) { + blkno = fragstoblks(fs, bno); + if (ffs_isblock(fs, cg_blksfree(cgp), blkno)) { + printf("dev = 0x%x, block = %d, fs = %s\n", + ip->i_dev, bno, fs->fs_fsmnt); + panic("blkfree: freeing free block"); + } + ffs_setblock(fs, cg_blksfree(cgp), blkno); + ffs_clusteracct(fs, cgp, blkno, 1); + cgp->cg_cs.cs_nbfree++; + fs->fs_cstotal.cs_nbfree++; + fs->fs_cs(fs, cg).cs_nbfree++; + i = cbtocylno(fs, bno); + cg_blks(fs, cgp, i)[cbtorpos(fs, bno)]++; + cg_blktot(cgp)[i]++; + } else { + bbase = bno - fragnum(fs, bno); + /* + * decrement the counts associated with the old frags + */ + blk = blkmap(fs, cg_blksfree(cgp), bbase); + ffs_fragacct(fs, blk, cgp->cg_frsum, -1); + /* + * deallocate the fragment + */ + frags = numfrags(fs, size); + for (i = 0; i < frags; i++) { + if (isset(cg_blksfree(cgp), bno + i)) { + printf("dev = 0x%x, block = %d, fs = %s\n", + ip->i_dev, bno + i, fs->fs_fsmnt); + panic("blkfree: freeing free frag"); + } + setbit(cg_blksfree(cgp), bno + i); + } + cgp->cg_cs.cs_nffree += i; + fs->fs_cstotal.cs_nffree += i; + fs->fs_cs(fs, cg).cs_nffree += i; + /* + * add back in counts associated with the new frags + */ + blk = blkmap(fs, cg_blksfree(cgp), bbase); + ffs_fragacct(fs, blk, cgp->cg_frsum, 1); + /* + * if a complete block has been reassembled, account for it + */ + blkno = fragstoblks(fs, bbase); + if (ffs_isblock(fs, cg_blksfree(cgp), blkno)) { + cgp->cg_cs.cs_nffree -= fs->fs_frag; + fs->fs_cstotal.cs_nffree -= fs->fs_frag; + fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; + ffs_clusteracct(fs, cgp, blkno, 1); + cgp->cg_cs.cs_nbfree++; + fs->fs_cstotal.cs_nbfree++; + fs->fs_cs(fs, cg).cs_nbfree++; + i = cbtocylno(fs, bbase); + cg_blks(fs, cgp, i)[cbtorpos(fs, bbase)]++; + cg_blktot(cgp)[i]++; + } + } + fs->fs_fmod = 1; + bdwrite(bp); } /* @@ -946,111 +1254,221 @@ blkfree(volatile daddr_t bno, * * The specified inode is placed back in the free map. */ -void -diskfs_free_node(struct node *np, mode_t mode) +int +ffs_vfree(ap) + struct vop_vfree_args /* { + struct vnode *a_pvp; + ino_t a_ino; + int a_mode; + } */ *ap; { - struct cg *cgp; - int cg; - volatile int ino = np->dn->number; - - assert ("invalid inode number" && ino < sblock->fs_ipg * sblock->fs_ncg); - - cg = itog(ino); - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + register struct fs *fs; + register struct cg *cgp; + register struct inode *pip; + ino_t ino = ap->a_ino; + struct buf *bp; + int error, cg; - spin_lock (&alloclock); - if (diskfs_catch_exception ()) - { - spin_unlock (&alloclock); - return; - } - - if (!cg_chkmagic(cgp)) - { - spin_unlock (&alloclock); - printf ("Cylinder group %d bad magic number: %ld/%ld\n", - cg, cgp->cg_magic, ((struct ocg *)(cgp))->cg_magic); - diskfs_end_catch_exception (); - return; - } - cgp->cg_time = diskfs_mtime->seconds; - ino %= sblock->fs_ipg; - assert ("inconsistent cg_inosused table" && !isclr (cg_inosused (cgp), ino)); - clrbit(cg_inosused(cgp), ino); - if (ino < cgp->cg_irotor) - cgp->cg_irotor = ino; - cgp->cg_cs.cs_nifree++; - sblock->fs_cstotal.cs_nifree++; - csum[cg].cs_nifree++; - if ((mode & IFMT) == IFDIR) - { - cgp->cg_cs.cs_ndir--; - sblock->fs_cstotal.cs_ndir--; - csum[cg].cs_ndir--; - } - spin_unlock (&alloclock); - diskfs_end_catch_exception (); + pip = VTOI(ap->a_pvp); + fs = pip->i_fs; + if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) + panic("ifree: range: dev = 0x%x, ino = %d, fs = %s\n", + pip->i_dev, ino, fs->fs_fsmnt); + cg = ino_to_cg(fs, ino); + error = bread(pip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (0); + } + cgp = (struct cg *)bp->b_data; + if (!cg_chkmagic(cgp)) { + brelse(bp); + return (0); + } + cgp->cg_time = time.tv_sec; + ino %= fs->fs_ipg; + if (isclr(cg_inosused(cgp), ino)) { + printf("dev = 0x%x, ino = %d, fs = %s\n", + pip->i_dev, ino, fs->fs_fsmnt); + if (fs->fs_ronly == 0) + panic("ifree: freeing free inode"); + } + clrbit(cg_inosused(cgp), ino); + if (ino < cgp->cg_irotor) + cgp->cg_irotor = ino; + cgp->cg_cs.cs_nifree++; + fs->fs_cstotal.cs_nifree++; + fs->fs_cs(fs, cg).cs_nifree++; + if ((ap->a_mode & IFMT) == IFDIR) { + cgp->cg_cs.cs_ndir--; + fs->fs_cstotal.cs_ndir--; + fs->fs_cs(fs, cg).cs_ndir--; + } + fs->fs_fmod = 1; + bdwrite(bp); + return (0); } - /* * Find a block of the specified size in the specified cylinder group. * * It is a panic if a request is made to find a block if none are * available. */ -/* This routine expects to be called from inside a diskfs_catch_exception */ static daddr_t -mapsearch(struct cg *cgp, - daddr_t bpref, - int allocsiz) +ffs_mapsearch(fs, cgp, bpref, allocsiz) + register struct fs *fs; + register struct cg *cgp; + daddr_t bpref; + int allocsiz; +{ + daddr_t bno; + int start, len, loc, i; + int blk, field, subfield, pos; + + /* + * find the fragment by searching through the free block + * map for an appropriate bit pattern + */ + if (bpref) + start = dtogd(fs, bpref) / NBBY; + else + start = cgp->cg_frotor / NBBY; + len = howmany(fs->fs_fpg, NBBY) - start; + loc = scanc((u_int)len, (u_char *)&cg_blksfree(cgp)[start], + (u_char *)fragtbl[fs->fs_frag], + (u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); + if (loc == 0) { + len = start + 1; + start = 0; + loc = scanc((u_int)len, (u_char *)&cg_blksfree(cgp)[0], + (u_char *)fragtbl[fs->fs_frag], + (u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); + if (loc == 0) { + printf("start = %d, len = %d, fs = %s\n", + start, len, fs->fs_fsmnt); + panic("ffs_alloccg: map corrupted"); + /* NOTREACHED */ + } + } + bno = (start + len - loc) * NBBY; + cgp->cg_frotor = bno; + /* + * found the byte in the map + * sift through the bits to find the selected frag + */ + for (i = bno + NBBY; bno < i; bno += fs->fs_frag) { + blk = blkmap(fs, cg_blksfree(cgp), bno); + blk <<= 1; + field = around[allocsiz]; + subfield = inside[allocsiz]; + for (pos = 0; pos <= fs->fs_frag - allocsiz; pos++) { + if ((blk & field) == subfield) + return (bno + pos); + field <<= 1; + subfield <<= 1; + } + } + printf("bno = %d, fs = %s\n", bno, fs->fs_fsmnt); + panic("ffs_alloccg: block not in map"); + return (-1); +} + +/* + * Update the cluster map because of an allocation or free. + * + * Cnt == 1 means free; cnt == -1 means allocating. + */ +ffs_clusteracct(fs, cgp, blkno, cnt) + struct fs *fs; + struct cg *cgp; + daddr_t blkno; + int cnt; { - daddr_t bno; - int start, len, loc, i; - int blk, field, subfield, pos; - - /* - * find the fragment by searching through the free block - * map for an appropriate bit pattern - */ - if (bpref) - start = dtogd(bpref) / NBBY; - else - start = cgp->cg_frotor / NBBY; - len = howmany(sblock->fs_fpg, NBBY) - start; - loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[start], - (u_char *)fragtbl[sblock->fs_frag], - (u_char)(1 << (allocsiz - 1 + (sblock->fs_frag % NBBY)))); - if (loc == 0) - { - len = start + 1; - start = 0; - loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[0], - (u_char *)fragtbl[sblock->fs_frag], - (u_char)(1 << (allocsiz - 1 + (sblock->fs_frag % NBBY)))); - assert ("incosistent cg_blksfree table" && loc); - } - bno = (start + len - loc) * NBBY; - cgp->cg_frotor = bno; - /* - * found the byte in the map - * sift through the bits to find the selected frag - */ - for (i = bno + NBBY; bno < i; bno += sblock->fs_frag) - { - blk = blkmap(cg_blksfree(cgp), bno); - blk <<= 1; - field = around[allocsiz]; - subfield = inside[allocsiz]; - for (pos = 0; pos <= sblock->fs_frag - allocsiz; pos++) - { - if ((blk & field) == subfield) - return (bno + pos); - field <<= 1; - subfield <<= 1; + long *sump; + u_char *freemapp, *mapp; + int i, start, end, forw, back, map, bit; + + if (fs->fs_contigsumsize <= 0) + return; + freemapp = cg_clustersfree(cgp); + sump = cg_clustersum(cgp); + /* + * Allocate or clear the actual block. + */ + if (cnt > 0) + setbit(freemapp, blkno); + else + clrbit(freemapp, blkno); + /* + * Find the size of the cluster going forward. + */ + start = blkno + 1; + end = start + fs->fs_contigsumsize; + if (end >= cgp->cg_nclusterblks) + end = cgp->cg_nclusterblks; + mapp = &freemapp[start / NBBY]; + map = *mapp++; + bit = 1 << (start % NBBY); + for (i = start; i < end; i++) { + if ((map & bit) == 0) + break; + if ((i & (NBBY - 1)) != (NBBY - 1)) { + bit <<= 1; + } else { + map = *mapp++; + bit = 1; + } + } + forw = i - start; + /* + * Find the size of the cluster going backward. + */ + start = blkno - 1; + end = start - fs->fs_contigsumsize; + if (end < 0) + end = -1; + mapp = &freemapp[start / NBBY]; + map = *mapp--; + bit = 1 << (start % NBBY); + for (i = start; i > end; i--) { + if ((map & bit) == 0) + break; + if ((i & (NBBY - 1)) != 0) { + bit >>= 1; + } else { + map = *mapp--; + bit = 1 << (NBBY - 1); + } } - } - assert ("inconsistent cg_blksfree table" && 0); + back = start - i; + /* + * Account for old cluster and the possibly new forward and + * back clusters. + */ + i = back + forw + 1; + if (i > fs->fs_contigsumsize) + i = fs->fs_contigsumsize; + sump[i] += cnt; + if (back > 0) + sump[back] -= cnt; + if (forw > 0) + sump[forw] -= cnt; } +/* + * Fserr prints the name of a file system with an error diagnostic. + * + * The form of the error message is: + * fs: error message + */ +static void +ffs_fserr(fs, uid, cp) + struct fs *fs; + u_int uid; + char *cp; +{ + log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->fs_fsmnt, cp); +} -- cgit v1.2.3 From 45a96b9898b4a57446a70bbb49c9d3da114f1a58 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 21:12:31 +0000 Subject: Formerly fs.h.~4~ --- ufs/fs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs/fs.h b/ufs/fs.h index bef052fe..7a4e6d7c 100644 --- a/ufs/fs.h +++ b/ufs/fs.h @@ -281,6 +281,7 @@ struct fs { /* cluster sum */ (fs)->fs_contigsumsize * sizeof(long) + \ /* cluster map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPB(fs), NBBY))) +#if 0 /* Wrong for GNU Hurd ufs; we don't use fs_csp at all. */ /* * Convert cylinder group to base address of its global summary info. * @@ -288,6 +289,11 @@ struct fs { */ #define fs_cs(fs, indx) \ fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask] +#else +/* Global variable csum is declared in ufs.h; use it instead + of fs_cs stuff. */ +#define fs_cs(fs, indx) this will generate a syntax error. +#endif /* * Cylinder group block for a file system. -- cgit v1.2.3 From af1078995f8e299fcd3c054cb24622dd08dbb699 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 21:36:26 +0000 Subject: Formerly ufs.h.~15~ --- ufs/ufs.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 920134ef..f6769916 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -179,6 +179,22 @@ int nextgennumber; mach_port_t ufs_device; +/* The compat_mode specifies whether or not we write + extensions onto the disk. */ +enum compat_mode +{ + COMPAT_GNU = 0, + COMPAT_BSD42 = 1, + COMPAT_BSD44 = 2, +}; + +/* If this is set, then this filesystem has two extensions: + 1) directory entries include the type field. + 2) symlink targets might be written directly in the di_db field + of the dinode. */ +int direct_symlink_extension; + + #define DEV_BSIZE 512 #define NBBY 8 #define btodb(n) ((n) / DEV_BSIZE) @@ -190,11 +206,11 @@ mach_port_t ufs_device; #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<(i)%NBBY)) /* From alloc.c: */ -error_t alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, - struct protid *); -void blkfree(volatile daddr_t bno, int size); -daddr_t blkpref (struct node *, daddr_t, int, daddr_t *); -error_t realloccg(struct node *, daddr_t, daddr_t, +error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, + struct protid *); +void ffs_blkfree(struct node *, volatile daddr_t bno, int size); +daddr_t ffs_blkpref (struct node *, daddr_t, int, daddr_t *); +error_t ffs_realloccg(struct node *, daddr_t, daddr_t, int, int, daddr_t *, struct protid *); /* From devio.c: */ -- cgit v1.2.3 From 556b10d5fc783b7f8059856315de9a4232b339c7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 21:40:31 +0000 Subject: Formerly sizes.c.~15~ --- ufs/sizes.c | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 423c13bb..d7f132c0 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -49,6 +49,25 @@ diskfs_truncate (struct node *np, if (length >= osize) return 0; + /* Check to see if this is a kludged symlink. */ + if (direct_symlink_extension && S_ISLNK (np->dn_stat.st_mode) + && osize < sblock->fs_maxsymlinklen) + { + error_t err; + + /* Prune it here */ + err = diskfs_catch_exception (); + if (err) + return err; + + bzero (dinodes[np->dn->number].di_shortlink + length, + osize - length); + diskfs_end_catch_exception (); + np->dn_stat.st_size = length; + np->dn_set_ctime = 1; + np->dn_set_mtime = 1; + } + /* Calculate block number of last block */ lastblock = lblkno (length + sblock->fs_bsize - 1) - 1; olastblock = lblkno (osize + sblock->fs_bsize - 1) - 1; @@ -109,7 +128,7 @@ diskfs_truncate (struct node *np, { if (np->dn->sinloc[idx - NDADDR]) { - blkfree (np->dn->sinloc[idx - NDADDR], sblock->fs_bsize); + ffs_blkfree (np, np->dn->sinloc[idx - NDADDR], sblock->fs_bsize); np->dn->sinloc[idx - NDADDR] = 0; np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; np->dn_stat_dirty = 1; @@ -138,7 +157,7 @@ diskfs_truncate (struct node *np, bsize = blksize (np, idx); else bsize = sblock->fs_bsize; - blkfree (bn, bsize); + ffs_blkfree (np, bn, bsize); np->dn_stat.st_blocks -= bsize / DEV_BSIZE; np->dn_stat_dirty = 1; } @@ -158,7 +177,7 @@ diskfs_truncate (struct node *np, if (oldspace - newspace) { bn += numfrags (newspace); - blkfree (bn, oldspace - newspace); + ffs_blkfree (np, bn, oldspace - newspace); np->dn_stat.st_blocks -= (oldspace - newspace) / DEV_BSIZE; np->dn_stat_dirty = 1; } @@ -192,7 +211,8 @@ dindir_drop (struct node *np) if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE]) { - blkfree (dinodes[np->dn->number].di_ib[INDIR_DOUBLE], sblock->fs_bsize); + ffs_blkfree (np, dinodes[np->dn->number].di_ib[INDIR_DOUBLE], + sblock->fs_bsize); dinodes[np->dn->number].di_ib[INDIR_DOUBLE] = 0; np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; } @@ -225,7 +245,7 @@ sindir_drop (struct node *np, { if (np->dn->dinloc[idx - 1]) { - blkfree (np->dn->dinloc[idx - 1], sblock->fs_bsize); + ffs_blkfree (np, np->dn->dinloc[idx - 1], sblock->fs_bsize); np->dn->dinloc[idx - 1] = 0; np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; } @@ -244,7 +264,8 @@ sindir_drop (struct node *np, /* Drop the block from the inode if we don't need it any more */ if (first == 0 && dinodes[np->dn->number].di_ib[INDIR_SINGLE]) { - blkfree (dinodes[np->dn->number].di_ib[INDIR_SINGLE], sblock->fs_bsize); + ffs_blkfree (np, dinodes[np->dn->number].di_ib[INDIR_SINGLE], + sblock->fs_bsize); dinodes[np->dn->number].di_ib[INDIR_SINGLE] = 0; np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; } @@ -312,7 +333,7 @@ diskfs_grow (struct node *np, if (err = diskfs_catch_exception()) { if (dealloc_on_error) - blkfree (dealloc_on_error, dealloc_size); + ffs_blkfree (np, dealloc_on_error, dealloc_size); goto out; } @@ -334,8 +355,8 @@ diskfs_grow (struct node *np, if (osize < sblock->fs_bsize && osize > 0) { daddr_t old_pbn; - err = realloccg (np, nb, - blkpref (np, nb, (int)nb, + err = ffs_realloccg (np, nb, + ffs_blkpref (np, nb, (int)nb, dinodes[np->dn->number].di_db), osize, sblock->fs_bsize, &pbn, cred); if (err) @@ -372,8 +393,8 @@ diskfs_grow (struct node *np, osize = sblock->fs_bsize; if (size > osize) { - err = realloccg (np, lbn, - blkpref (np, lbn, lbn, + err = ffs_realloccg (np, lbn, + ffs_blkpref (np, lbn, lbn, dinodes[np->dn->number].di_db), osize, size, &pbn, cred); if (err) @@ -396,9 +417,10 @@ diskfs_grow (struct node *np, } else { - err = alloc (np, lbn, - blkpref (np, lbn, lbn, dinodes[np->dn->number].di_db), - size, &pbn, cred); + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, lbn, + dinodes[np->dn->number].di_db), + size, &pbn, cred); if (err) goto out; dealloc_on_error = pbn; @@ -425,9 +447,9 @@ diskfs_grow (struct node *np, lbn -= NDADDR; if (!np->dn->sinloc[lbn]) { - err = alloc (np, lbn, blkpref (np, lbn + NDADDR, lbn, - np->dn->sinloc), - sblock->fs_bsize, &pbn, cred); + err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn + NDADDR, lbn, + np->dn->sinloc), + sblock->fs_bsize, &pbn, cred); if (err) goto out; dealloc_on_error = pbn; -- cgit v1.2.3 From 7b0c5fe429fd598011edd4c2c0cae008263b8467 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Jul 1994 21:45:29 +0000 Subject: Formerly alloc.c.~12~ --- ufs/alloc.c | 531 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 275 insertions(+), 256 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index cdd2e4b2..7dfe5785 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,3 +1,23 @@ +/* Disk allocation routines + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Modified from UCB by Michael I. Bushnell. */ /* * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -33,35 +53,18 @@ * @(#)ffs_alloc.c 8.8 (Berkeley) 2/21/94 */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include "ufs.h" +#include "fs.h" +#include "dinode.h" +#include -#include -#include - -#include -#include +/* These don't work *at all* here; don't even try setting them. */ +#undef DIAGNOSTIC +#undef QUOTA extern u_long nextgennumber; -static daddr_t ffs_alloccg __P((struct inode *, int, daddr_t, int)); -static daddr_t ffs_alloccgblk __P((struct fs *, struct cg *, daddr_t)); -static daddr_t ffs_clusteralloc __P((struct inode *, int, daddr_t, int)); -static ino_t ffs_dirpref __P((struct fs *)); -static daddr_t ffs_fragextend __P((struct inode *, int, long, int, int)); -static void ffs_fserr __P((struct fs *, u_int, char *)); -static u_long ffs_hashalloc - __P((struct inode *, int, long, int, u_long (*)())); -static ino_t ffs_nodealloccg __P((struct inode *, int, daddr_t, int)); -static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); +spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; /* * Allocate a block in the file system. @@ -82,31 +85,32 @@ static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); * 2) quadradically rehash into other cylinder groups, until an * available block is located. */ -ffs_alloc(ip, lbn, bpref, size, cred, bnp) - register struct inode *ip; - daddr_t lbn, bpref; - int size; - struct ucred *cred; - daddr_t *bnp; +ffs_alloc(register struct node *np, + daddr_t lbn, + daddr_t bpref, + int size, + daddr_t *bnp, + struct protid *cred) { register struct fs *fs; daddr_t bno; int cg, error; *bnp = 0; - fs = ip->i_fs; + fs = sblock; #ifdef DIAGNOSTIC if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); panic("ffs_alloc: bad size"); } - if (cred == NOCRED) - panic("ffs_alloc: missing credential\n"); + assert (cred); #endif /* DIAGNOSTIC */ + spin_lock (&alloclock); if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) goto nospace; - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) + if (cred && !diskfs_isuid (0, cred) + && freespace(fs, fs->fs_minfree) <= 0) goto nospace; #ifdef QUOTA if (error = chkdq(ip, (long)btodb(size), cred, 0)) @@ -115,14 +119,16 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) if (bpref >= fs->fs_size) bpref = 0; if (bpref == 0) - cg = ino_to_cg(fs, ip->i_number); + cg = ino_to_cg(fs, np->dn->number); else cg = dtog(fs, bpref); - bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size, + bno = (daddr_t)ffs_hashalloc(np, cg, (long)bpref, size, (u_long (*)())ffs_alloccg); if (bno > 0) { - ip->i_blocks += btodb(size); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + spin_unlock (&alloclock); + np->dn_stat.st_blocks += btodb(size); + np->dn_set_ctime = 1; + np->dn_set_mtime = 1; *bnp = bno; return (0); } @@ -133,8 +139,10 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) (void) chkdq(ip, (long)-btodb(size), cred, FORCE); #endif nospace: - ffs_fserr(fs, cred->cr_uid, "file system full"); - uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); + spin_unlock (&alloclock); + printf ("file system full"); +/* ffs_fserr(fs, cred->cr_uid, "file system full"); */ +/* uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); */ return (ENOSPC); } @@ -146,21 +154,20 @@ nospace: * the original block. Failing that, the regular block allocator is * invoked to get an appropriate block. */ -ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) - register struct inode *ip; - daddr_t lbprev; - daddr_t bpref; - int osize, nsize; - struct ucred *cred; - struct buf **bpp; +ffs_realloccg(register struct node *np, + daddr_t lbprev, + daddr_t bpref, + int osize, + int nsize, + daddr_t *pbn, + struct protid *cred) { register struct fs *fs; - struct buf *bp; int cg, request, error; daddr_t bprev, bno; - *bpp = 0; - fs = ip->i_fs; + *pbn = 0; + fs = sblock; #ifdef DIAGNOSTIC if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { @@ -172,13 +179,18 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) if (cred == NOCRED) panic("ffs_realloccg: missing credential\n"); #endif /* DIAGNOSTIC */ - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) + + spin_lock (&alloclock); + + if (!isuid (0, cred) && freespace(fs, fs->fs_minfree) <= 0) goto nospace; - if ((bprev = ip->i_db[lbprev]) == 0) { - printf("dev = 0x%x, bsize = %d, bprev = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, bprev, fs->fs_fsmnt); - panic("ffs_realloccg: bad bprev"); - } + if (error = diskfs_catch_exception ()) + return error; + bprev = dinodes[np->dn->number].di_db[lbprev]; + diskfs_end_catch_exception (); + assert ("old block not allocated" && bprev); + +#if 0 /* Not needed in GNU Hurd ufs */ /* * Allocate the extra space in the buffer. */ @@ -192,19 +204,25 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) return (error); } #endif +#endif /* 0 */ + /* * Check for extension in the existing location. */ cg = dtog(fs, bprev); - if (bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) { - if (bp->b_blkno != fsbtodb(fs, bno)) - panic("bad blockno"); - ip->i_blocks += btodb(nsize - osize); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (bno = ffs_fragextend(np, cg, (long)bprev, osize, nsize)) { + assert (bno == bprev); + spin_unlock (&alloclock); + np->dn_stat.st_blocks += btodb(nsize - osize); + np->dn_set_ctime = 1; + np->dn_set_mtime = 1; + *pbn = bno; +#if 0 /* Not done this way in GNU Hurd ufs. */ allocbuf(bp, nsize); bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; +#endif return (0); } /* @@ -252,24 +270,31 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) default: printf("dev = 0x%x, optim = %d, fs = %s\n", ip->i_dev, fs->fs_optim, fs->fs_fsmnt); - panic("ffs_realloccg: bad optim"); + assert (0); /* NOTREACHED */ } - bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request, + bno = (daddr_t)ffs_hashalloc(np, cg, (long)bpref, request, (u_long (*)())ffs_alloccg); if (bno > 0) { +#if 0 /* Not necessary in GNU Hurd ufs */ bp->b_blkno = fsbtodb(fs, bno); (void) vnode_pager_uncache(ITOV(ip)); - ffs_blkfree(ip, bprev, (long)osize); +#endif + ffs_blkfree(np, bprev, (long)osize); if (nsize < request) - ffs_blkfree(ip, bno + numfrags(fs, nsize), + ffs_blkfree(np, bno + numfrags(fs, nsize), (long)(request - nsize)); - ip->i_blocks += btodb(nsize - osize); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + spin_unlock (&alloclock); + np->dn_stat.st_blocks += btodb(nsize - osize); + np->dn_set_mtime = 1; + np->dn_set_ctime = 1; + *pbn = bno; +#if 0 /* Not done this way in GNU Hurd ufs */ allocbuf(bp, nsize); bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; +#endif /* 0 */ return (0); } #ifdef QUOTA @@ -278,16 +303,21 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) */ (void) chkdq(ip, (long)-btodb(nsize - osize), cred, FORCE); #endif +#if 0 /* Not necesarry in GNU Hurd ufs */ brelse(bp); +#endif nospace: /* * no space available */ - ffs_fserr(fs, cred->cr_uid, "file system full"); - uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); + spin_unlock (&alloclock); + printf ("file system full"); +/* ffs_fserr(fs, cred->cr_uid, "file system full"); */ +/* uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); */ return (ENOSPC); } +#if 0 /* Not used (yet?) in GNU Hurd ufs */ /* * Reallocate a sequence of blocks into a contiguous sequence of blocks. * @@ -450,6 +480,7 @@ fail: brelse(sbp); return (ENOSPC); } +#endif /* 0 */ /* * Allocate an inode in the file system. @@ -466,65 +497,64 @@ fail: * 2) quadradically rehash into other cylinder groups, until an * available inode is located. */ -ffs_valloc(ap) - struct vop_valloc_args /* { - struct vnode *a_pvp; - int a_mode; - struct ucred *a_cred; - struct vnode **a_vpp; - } */ *ap; +/* This is now the diskfs_alloc_node callback from the diskfs library + (described in ). It used to be ffs_valloc in BSD. */ +error_t +diskfs_alloc_node (struct node *dir, + mode_t mode, + struct node **npp) { - register struct vnode *pvp = ap->a_pvp; - register struct inode *pip; register struct fs *fs; - register struct inode *ip; - mode_t mode = ap->a_mode; + register struct node *np; ino_t ino, ipref; int cg, error; - *ap->a_vpp = NULL; - pip = VTOI(pvp); - fs = pip->i_fs; + fs = sblock; + + + spin_lock (&alloclock); + if (fs->fs_cstotal.cs_nifree == 0) - goto noinodes; + { + spin_unlock (&alloclock); + goto noinodes; + } - if ((mode & IFMT) == IFDIR) + if (S_ISDIR (mode)) ipref = ffs_dirpref(fs); else - ipref = pip->i_number; + ipref = dir->dn->number; + if (ipref >= fs->fs_ncg * fs->fs_ipg) ipref = 0; cg = ino_to_cg(fs, ipref); - ino = (ino_t)ffs_hashalloc(pip, cg, (long)ipref, mode, ffs_nodealloccg); + ino = (ino_t)ffs_hashalloc(dir, cg, (long)ipref, + mode, ffs_nodealloccg); + spin_unlock (&alloclock); if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, ap->a_vpp); - if (error) { - VOP_VFREE(pvp, ino, mode); - return (error); - } - ip = VTOI(*ap->a_vpp); - if (ip->i_mode) { - printf("mode = 0%o, inum = %d, fs = %s\n", - ip->i_mode, ip->i_number, fs->fs_fsmnt); - panic("ffs_valloc: dup alloc"); - } - if (ip->i_blocks) { /* XXX */ - printf("free inode %s/%d had %d blocks\n", - fs->fs_fsmnt, ino, ip->i_blocks); - ip->i_blocks = 0; + error = iget (ino, &np); + assert ("duplicate allocation" && !np->dn_stat.st_mode); + if (np->dn_stat.st_blocks) { + printf("free inode %d had %d blocks\n", + ino, ip->i_blocks); + np->dn_stat.st_blocks = 0; + np->dn_set_ctime = 1; } ip->i_flags = 0; /* * Set up a new generation number for this inode. */ + spin_lock (&gennumberlock); if (++nextgennumber < (u_long)time.tv_sec) nextgennumber = time.tv_sec; ip->i_gen = nextgennumber; + spin_unlock (&gennumberlock); return (0); noinodes: - ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); - uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); + printf ("out of inodes"); +/* ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); */ +/* uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt);*/ return (ENOSPC); } @@ -536,8 +566,7 @@ noinodes: * free inodes, the one with the smallest number of directories. */ static ino_t -ffs_dirpref(fs) - register struct fs *fs; +ffs_dirpref(register struct fs *fs) { int cg, minndir, mincg, avgifree; @@ -545,10 +574,10 @@ ffs_dirpref(fs) minndir = fs->fs_ipg; mincg = 0; for (cg = 0; cg < fs->fs_ncg; cg++) - if (fs->fs_cs(fs, cg).cs_ndir < minndir && - fs->fs_cs(fs, cg).cs_nifree >= avgifree) { + if (csum[cg].cs_ndir < minndir && + csum[cg].cs_nifree >= avgifree) { mincg = cg; - minndir = fs->fs_cs(fs, cg).cs_ndir; + minndir = csum[cg].cs_ndir; } return ((ino_t)(fs->fs_ipg * mincg)); } @@ -580,21 +609,22 @@ ffs_dirpref(fs) * schedule another I/O transfer. */ daddr_t -ffs_blkpref(ip, lbn, indx, bap) - struct inode *ip; - daddr_t lbn; - int indx; - daddr_t *bap; +ffs_blkpref(struct node *np, + daddr_t lbn, + int indx, + daddr_t *bap) { register struct fs *fs; register int cg; int avgbfree, startcg; daddr_t nextblk; - fs = ip->i_fs; + fs = sblock; + spin_lock (&alloclock); if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { if (lbn < NDADDR) { - cg = ino_to_cg(fs, ip->i_number); + cg = ino_to_cg(fs, np->dn->number); + spin_unlock (&alloclock); return (fs->fs_fpg * cg + fs->fs_frag); } /* @@ -603,23 +633,28 @@ ffs_blkpref(ip, lbn, indx, bap) */ if (indx == 0 || bap[indx - 1] == 0) startcg = - ino_to_cg(fs, ip->i_number) + lbn / fs->fs_maxbpg; + (ino_to_cg(fs, np->dn->number) + + lbn / fs->fs_maxbpg); else startcg = dtog(fs, bap[indx - 1]) + 1; startcg %= fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; for (cg = startcg; cg < fs->fs_ncg; cg++) - if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { + if (csum[cg].cs_nbfree >= avgbfree) { fs->fs_cgrotor = cg; + spin_unlock (&alloclock); return (fs->fs_fpg * cg + fs->fs_frag); } for (cg = 0; cg <= startcg; cg++) - if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { + if (csum[cg].cs_nbfree >= avgbfree) { fs->fs_cgrotor = cg; + spin_unlock (&alloclock); return (fs->fs_fpg * cg + fs->fs_frag); } + spin_unlock (&alloclock); return (NULL); } + spin_unlock (&alloclock); /* * One or more previous blocks have been laid out. If less * than fs_maxcontig previous blocks are contiguous, the @@ -629,7 +664,9 @@ ffs_blkpref(ip, lbn, indx, bap) nextblk = bap[indx - 1] + fs->fs_frag; if (indx < fs->fs_maxcontig || bap[indx - fs->fs_maxcontig] + blkstofrags(fs, fs->fs_maxcontig) != nextblk) - return (nextblk); + { + return (nextblk); + } if (fs->fs_rotdelay != 0) /* * Here we convert ms of delay to frags as: @@ -652,22 +689,21 @@ ffs_blkpref(ip, lbn, indx, bap) */ /*VARARGS5*/ static u_long -ffs_hashalloc(ip, cg, pref, size, allocator) - struct inode *ip; - int cg; - long pref; - int size; /* size for data blocks, mode for inodes */ - u_long (*allocator)(); +ffs_hashalloc(struct node *np, + int cg, + long pref, + int size, /* size for data blocks, mode for inodes */ + u_long (*allocator)()) { register struct fs *fs; long result; int i, icg = cg; - fs = ip->i_fs; + fs = sblock; /* * 1: preferred cylinder group */ - result = (*allocator)(ip, cg, pref, size); + result = (*allocator)(np, cg, pref, size); if (result) return (result); /* @@ -677,7 +713,7 @@ ffs_hashalloc(ip, cg, pref, size, allocator) cg += i; if (cg >= fs->fs_ncg) cg -= fs->fs_ncg; - result = (*allocator)(ip, cg, 0, size); + result = (*allocator)(np, cg, 0, size); if (result) return (result); } @@ -688,7 +724,7 @@ ffs_hashalloc(ip, cg, pref, size, allocator) */ cg = (icg + 2) % fs->fs_ncg; for (i = 2; i < fs->fs_ncg; i++) { - result = (*allocator)(ip, cg, 0, size); + result = (*allocator)(np, cg, 0, size); if (result) return (result); cg++; @@ -705,11 +741,11 @@ ffs_hashalloc(ip, cg, pref, size, allocator) * if they are, allocate them. */ static daddr_t -ffs_fragextend(ip, cg, bprev, osize, nsize) - struct inode *ip; - int cg; - long bprev; - int osize, nsize; +ffs_fragextend(struct node *np, + int cg, + long bprev, + int osize, + int nsize) { register struct fs *fs; register struct cg *cgp; @@ -718,8 +754,8 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) int frags, bbase; int i, error; - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nffree < numfrags(fs, nsize - osize)) + fs = sblock; + if (csum[cg].cs_nffree < numfrags(fs, nsize - osize)) return (NULL); frags = numfrags(fs, nsize); bbase = fragnum(fs, bprev); @@ -727,6 +763,7 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) /* cannot extend across a block boundary */ return (NULL); } +#if 0 /* Wrong for GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { @@ -734,15 +771,18 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) return (NULL); } cgp = (struct cg *)bp->b_data; +#else + cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); +#endif if (!cg_chkmagic(cgp)) { - brelse(bp); +/* brelse(bp); */ return (NULL); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = diskfs_mtime->seconds; bno = dtogd(fs, bprev); for (i = numfrags(fs, osize); i < frags; i++) if (isclr(cg_blksfree(cgp), bno + i)) { - brelse(bp); +/* brelse(bp); */ return (NULL); } /* @@ -761,10 +801,10 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) clrbit(cg_blksfree(cgp), bno + i); cgp->cg_cs.cs_nffree--; fs->fs_cstotal.cs_nffree--; - fs->fs_cs(fs, cg).cs_nffree--; + csum[cg].cs_nffree--; } fs->fs_fmod = 1; - bdwrite(bp); +/* bdwrite(bp); */ return (bprev); } @@ -775,11 +815,10 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) * and if it is, allocate it. */ static daddr_t -ffs_alloccg(ip, cg, bpref, size) - struct inode *ip; - int cg; - daddr_t bpref; - int size; +ffs_alloccg(struct node *np, + int cg, + daddr_t bpref, + int size) { register struct fs *fs; register struct cg *cgp; @@ -787,9 +826,10 @@ ffs_alloccg(ip, cg, bpref, size) register int i; int error, bno, frags, allocsiz; - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) + fs = sblock; + if (csum[cg].cs_nbfree == 0 && size == fs->fs_bsize) return (NULL); +#if 0 /* Not this way in GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { @@ -797,15 +837,18 @@ ffs_alloccg(ip, cg, bpref, size) return (NULL); } cgp = (struct cg *)bp->b_data; +#else + cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); +#endif if (!cg_chkmagic(cgp) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { - brelse(bp); +/* brelse(bp); */ return (NULL); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = diskfs_mtime->seconds; if (size == fs->fs_bsize) { bno = ffs_alloccgblk(fs, cgp, bpref); - bdwrite(bp); +/* bdwrite(bp); */ return (bno); } /* @@ -823,7 +866,7 @@ ffs_alloccg(ip, cg, bpref, size) * allocated, and hacked up */ if (cgp->cg_cs.cs_nbfree == 0) { - brelse(bp); +/* brelse(bp); */ return (NULL); } bno = ffs_alloccgblk(fs, cgp, bpref); @@ -833,27 +876,27 @@ ffs_alloccg(ip, cg, bpref, size) i = fs->fs_frag - frags; cgp->cg_cs.cs_nffree += i; fs->fs_cstotal.cs_nffree += i; - fs->fs_cs(fs, cg).cs_nffree += i; + csum[cg].cs_nffree += i; fs->fs_fmod = 1; cgp->cg_frsum[i]++; - bdwrite(bp); +/* bdwrite(bp); */ return (bno); } bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); if (bno < 0) { - brelse(bp); +/* brelse(bp);* / return (NULL); } for (i = 0; i < frags; i++) clrbit(cg_blksfree(cgp), bno + i); cgp->cg_cs.cs_nffree -= frags; fs->fs_cstotal.cs_nffree -= frags; - fs->fs_cs(fs, cg).cs_nffree -= frags; + csum[cg].cs_nffree -= frags; fs->fs_fmod = 1; cgp->cg_frsum[allocsiz]--; if (frags != allocsiz) cgp->cg_frsum[allocsiz - frags]++; - bdwrite(bp); +/* bdwrite(bp); */ return (cg * fs->fs_fpg + bno); } @@ -869,10 +912,9 @@ ffs_alloccg(ip, cg, bpref, size) * blocks may be fragmented by the routine that allocates them. */ static daddr_t -ffs_alloccgblk(fs, cgp, bpref) - register struct fs *fs; - register struct cg *cgp; - daddr_t bpref; +ffs_alloccgblk(register struct fs *fs, + register struct cg *cgp, + daddr_t bpref) { daddr_t bno, blkno; int cylno, pos, delta; @@ -930,11 +972,7 @@ ffs_alloccgblk(fs, cgp, bpref) */ pos = cylno % fs->fs_cpc; bno = (cylno - pos) * fs->fs_spc / NSPB(fs); - if (fs_postbl(fs, pos)[i] == -1) { - printf("pos = %d, i = %d, fs = %s\n", - pos, i, fs->fs_fsmnt); - panic("ffs_alloccgblk: cyl groups corrupted"); - } + assert (fs_postbl(fs, pos)[i] != -1); for (i = fs_postbl(fs, pos)[i];; ) { if (ffs_isblock(fs, cg_blksfree(cgp), bno + i)) { bno = blkstofrags(fs, (bno + i)); @@ -947,7 +985,7 @@ ffs_alloccgblk(fs, cgp, bpref) i += delta; } printf("pos = %d, i = %d, fs = %s\n", pos, i, fs->fs_fsmnt); - panic("ffs_alloccgblk: can't find blk in cyl"); + assert (0); } norot: /* @@ -964,7 +1002,7 @@ gotit: ffs_clusteracct(fs, cgp, blkno, -1); cgp->cg_cs.cs_nbfree--; fs->fs_cstotal.cs_nbfree--; - fs->fs_cs(fs, cgp->cg_cgx).cs_nbfree--; + csum[cgp->cg_cgx].cs_nbfree--; cylno = cbtocylno(fs, bno); cg_blks(fs, cgp, cylno)[cbtorpos(fs, bno)]--; cg_blktot(cgp)[cylno]--; @@ -972,6 +1010,7 @@ gotit: return (cgp->cg_cgx * fs->fs_fpg + bno); } +#if 0 /* Not needed in GNU Hurd ufs (yet?) */ /* * Determine whether a cluster can be allocated. * @@ -1060,6 +1099,7 @@ fail: brelse(bp); return (0); } +#endif /* * Determine whether an inode can be allocated. @@ -1071,20 +1111,20 @@ fail: * inode in the specified cylinder group. */ static ino_t -ffs_nodealloccg(ip, cg, ipref, mode) - struct inode *ip; - int cg; - daddr_t ipref; - int mode; +ffs_nodealloccg(struct node *np, + int cg, + daddr_t ipref, + int mode) { register struct fs *fs; register struct cg *cgp; struct buf *bp; int error, start, len, loc, map, i; - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nifree == 0) + fs = sblock; + if (csum[cg].cs_nifree == 0) return (NULL); +#if 0 /* Not this way in GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { @@ -1092,8 +1132,11 @@ ffs_nodealloccg(ip, cg, ipref, mode) return (NULL); } cgp = (struct cg *)bp->b_data; +#else + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); +#endif if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { - brelse(bp); +/* brelse(bp); */ return (NULL); } cgp->cg_time = time.tv_sec; @@ -1109,12 +1152,7 @@ ffs_nodealloccg(ip, cg, ipref, mode) len = start + 1; start = 0; loc = skpc(0xff, len, &cg_inosused(cgp)[0]); - if (loc == 0) { - printf("cg = %d, irotor = %d, fs = %s\n", - cg, cgp->cg_irotor, fs->fs_fsmnt); - panic("ffs_nodealloccg: map corrupted"); - /* NOTREACHED */ - } + assert (loc != 0); } i = start + len - loc; map = cg_inosused(cgp)[i]; @@ -1125,21 +1163,20 @@ ffs_nodealloccg(ip, cg, ipref, mode) goto gotit; } } - printf("fs = %s\n", fs->fs_fsmnt); - panic("ffs_nodealloccg: block not in map"); + assort (0); /* NOTREACHED */ gotit: setbit(cg_inosused(cgp), ipref); cgp->cg_cs.cs_nifree--; fs->fs_cstotal.cs_nifree--; - fs->fs_cs(fs, cg).cs_nifree--; + csum[cg].cs_nifree--; fs->fs_fmod = 1; if ((mode & IFMT) == IFDIR) { cgp->cg_cs.cs_ndir++; fs->fs_cstotal.cs_ndir++; - fs->fs_cs(fs, cg).cs_ndir++; + csum[cg].cs_ndir++; } - bdwrite(bp); +/* bdwrite(bp); */ return (cg * fs->fs_ipg + ipref); } @@ -1150,10 +1187,9 @@ gotit: * free map. If a fragment is deallocated, a possible * block reassembly is checked. */ -ffs_blkfree(ip, bno, size) - register struct inode *ip; - daddr_t bno; - long size; +ffs_blkfree(register struct node *np, + daddr_t bno, + long size) { register struct fs *fs; register struct cg *cgp; @@ -1161,18 +1197,15 @@ ffs_blkfree(ip, bno, size) daddr_t blkno; int i, error, cg, blk, frags, bbase; - fs = ip->i_fs; - if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { - printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); - panic("blkfree: bad size"); - } + fs = sblock; + assert ((u_int)size <= fs->fs_bsize && !fragoff (fs, size)); cg = dtog(fs, bno); if ((u_int)bno >= fs->fs_size) { - printf("bad block %d, ino %d\n", bno, ip->i_number); - ffs_fserr(fs, ip->i_uid, "bad block"); + printf("bad block %d, ino %d\n", bno, np->dn->number); +/* ffs_fserr(fs, ip->i_uid, "bad block"); */ return; } +#if 0 /* Not this way in GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { @@ -1180,24 +1213,23 @@ ffs_blkfree(ip, bno, size) return; } cgp = (struct cg *)bp->b_data; +#else + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); +#endif if (!cg_chkmagic(cgp)) { - brelse(bp); +/* brelse(bp); */ return; } cgp->cg_time = time.tv_sec; bno = dtogd(fs, bno); if (size == fs->fs_bsize) { blkno = fragstoblks(fs, bno); - if (ffs_isblock(fs, cg_blksfree(cgp), blkno)) { - printf("dev = 0x%x, block = %d, fs = %s\n", - ip->i_dev, bno, fs->fs_fsmnt); - panic("blkfree: freeing free block"); - } + assert (!ffs_isblock(fs, cg_blksfree (cgp), blkno)); ffs_setblock(fs, cg_blksfree(cgp), blkno); ffs_clusteracct(fs, cgp, blkno, 1); cgp->cg_cs.cs_nbfree++; fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; + csum[cg].cs_nbfree++; i = cbtocylno(fs, bno); cg_blks(fs, cgp, i)[cbtorpos(fs, bno)]++; cg_blktot(cgp)[i]++; @@ -1213,16 +1245,12 @@ ffs_blkfree(ip, bno, size) */ frags = numfrags(fs, size); for (i = 0; i < frags; i++) { - if (isset(cg_blksfree(cgp), bno + i)) { - printf("dev = 0x%x, block = %d, fs = %s\n", - ip->i_dev, bno + i, fs->fs_fsmnt); - panic("blkfree: freeing free frag"); - } - setbit(cg_blksfree(cgp), bno + i); + assert (!isset (cg_blksfree(cgp, bno + i))); + setbit(cg_blksfree(cgp), bno + i); } cgp->cg_cs.cs_nffree += i; fs->fs_cstotal.cs_nffree += i; - fs->fs_cs(fs, cg).cs_nffree += i; + csum[cg].cs_nffree += i; /* * add back in counts associated with the new frags */ @@ -1235,18 +1263,18 @@ ffs_blkfree(ip, bno, size) if (ffs_isblock(fs, cg_blksfree(cgp), blkno)) { cgp->cg_cs.cs_nffree -= fs->fs_frag; fs->fs_cstotal.cs_nffree -= fs->fs_frag; - fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; + csum[cg].cs_nffree -= fs->fs_frag; ffs_clusteracct(fs, cgp, blkno, 1); cgp->cg_cs.cs_nbfree++; fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; + csum[cg].cs_nbfree++; i = cbtocylno(fs, bbase); cg_blks(fs, cgp, i)[cbtorpos(fs, bbase)]++; cg_blktot(cgp)[i]++; } } fs->fs_fmod = 1; - bdwrite(bp); +/* bdwrite(bp); */ } /* @@ -1254,27 +1282,21 @@ ffs_blkfree(ip, bno, size) * * The specified inode is placed back in the free map. */ -int -ffs_vfree(ap) - struct vop_vfree_args /* { - struct vnode *a_pvp; - ino_t a_ino; - int a_mode; - } */ *ap; +/* Implement diskfs call back diskfs_free_node (described in + . This was called ffs_vfree in BSD. */ +void +diskfs_free_node (struct node *np, mode_t mode) { register struct fs *fs; register struct cg *cgp; - register struct inode *pip; - ino_t ino = ap->a_ino; + ino_t ino = np->dn->number; struct buf *bp; int error, cg; - pip = VTOI(ap->a_pvp); - fs = pip->i_fs; - if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) - panic("ifree: range: dev = 0x%x, ino = %d, fs = %s\n", - pip->i_dev, ino, fs->fs_fsmnt); + fs = sblock; + assert (ino < fs->fs_ipg * fs->fs_ncg); cg = ino_to_cg(fs, ino); +#if 0 /* Not this way in GNU Hurd ufs */ error = bread(pip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { @@ -1282,8 +1304,11 @@ ffs_vfree(ap) return (0); } cgp = (struct cg *)bp->b_data; +#else + cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); +#endif if (!cg_chkmagic(cgp)) { - brelse(bp); +/* brelse(bp); */ return (0); } cgp->cg_time = time.tv_sec; @@ -1291,22 +1316,21 @@ ffs_vfree(ap) if (isclr(cg_inosused(cgp), ino)) { printf("dev = 0x%x, ino = %d, fs = %s\n", pip->i_dev, ino, fs->fs_fsmnt); - if (fs->fs_ronly == 0) - panic("ifree: freeing free inode"); + assert (diskfs_readonly); } clrbit(cg_inosused(cgp), ino); if (ino < cgp->cg_irotor) cgp->cg_irotor = ino; cgp->cg_cs.cs_nifree++; fs->fs_cstotal.cs_nifree++; - fs->fs_cs(fs, cg).cs_nifree++; + csum[cg].cs_nifree++; if ((ap->a_mode & IFMT) == IFDIR) { cgp->cg_cs.cs_ndir--; fs->fs_cstotal.cs_ndir--; - fs->fs_cs(fs, cg).cs_ndir--; + csum[cg].cs_ndir--; } fs->fs_fmod = 1; - bdwrite(bp); +/* bdwrite(bp); */ return (0); } @@ -1317,11 +1341,10 @@ ffs_vfree(ap) * available. */ static daddr_t -ffs_mapsearch(fs, cgp, bpref, allocsiz) - register struct fs *fs; - register struct cg *cgp; - daddr_t bpref; - int allocsiz; +ffs_mapsearch(register struct fs *fs, + register struct cg *cgp, + daddr_t bpref, + int allocsiz) { daddr_t bno; int start, len, loc, i; @@ -1345,12 +1368,8 @@ ffs_mapsearch(fs, cgp, bpref, allocsiz) loc = scanc((u_int)len, (u_char *)&cg_blksfree(cgp)[0], (u_char *)fragtbl[fs->fs_frag], (u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); - if (loc == 0) { - printf("start = %d, len = %d, fs = %s\n", - start, len, fs->fs_fsmnt); - panic("ffs_alloccg: map corrupted"); - /* NOTREACHED */ - } + assert (loc); + } bno = (start + len - loc) * NBBY; cgp->cg_frotor = bno; @@ -1370,8 +1389,7 @@ ffs_mapsearch(fs, cgp, bpref, allocsiz) subfield <<= 1; } } - printf("bno = %d, fs = %s\n", bno, fs->fs_fsmnt); - panic("ffs_alloccg: block not in map"); + assert (0); return (-1); } @@ -1380,11 +1398,10 @@ ffs_mapsearch(fs, cgp, bpref, allocsiz) * * Cnt == 1 means free; cnt == -1 means allocating. */ -ffs_clusteracct(fs, cgp, blkno, cnt) - struct fs *fs; - struct cg *cgp; - daddr_t blkno; - int cnt; +ffs_clusteracct(struct fs *fs, + struct cg *cgp, + daddr_t blkno, + int cnt) { long *sump; u_char *freemapp, *mapp; @@ -1457,6 +1474,7 @@ ffs_clusteracct(fs, cgp, blkno, cnt) sump[forw] -= cnt; } +#if 0 /* * Fserr prints the name of a file system with an error diagnostic. * @@ -1472,3 +1490,4 @@ ffs_fserr(fs, uid, cp) log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->fs_fsmnt, cp); } +#endif -- cgit v1.2.3 From ca6d84dd97fc2a772609f40962c52f8ed726dbbb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 16:28:07 +0000 Subject: Formerly ufs.h.~16~ --- ufs/ufs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index f6769916..c79aaeb7 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -24,6 +24,10 @@ #include #include +/* XXX */ +typedef unsigned long long u_quad_t; + + /* 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. */ -- cgit v1.2.3 From 343851b0b1768bda70ef6d1b997bb608d31ac8c9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 16:42:43 +0000 Subject: Formerly main.c.~14~ --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index de90cea8..dc58a20e 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -133,7 +133,7 @@ main (int argc, char **argv) compat_mode = COMPAT_GNU; } - diskfs_init_diskfs (); + diskfs_init_diskfs (bootstrap); err = device_open (diskfs_master_device, (diskfs_readonly ? 0 : D_WRITE) | D_READ, -- cgit v1.2.3 From 722776a1b5997cfc5a0dbf936fae9f4e20f600c1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 16:50:51 +0000 Subject: Formerly subr.c.~5~ --- ufs/subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/subr.c b/ufs/subr.c index 1730e737..5a6acd88 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -169,7 +169,7 @@ ffs_isblock(fs, cp, h) mask = 0x01 << (h & 0x7); return ((cp[h >> 3] & mask) == mask); default: - panic("ffs_isblock"); + assert (0); } } -- cgit v1.2.3 From cc079a24d3a2f6fc68e4f4c712164613de1af8d7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:22:18 +0000 Subject: Formerly ufs.h.~17~ --- ufs/ufs.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index c79aaeb7..2fb825cc 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -26,6 +26,12 @@ /* XXX */ typedef unsigned long long u_quad_t; +typedef long long quad_t; +struct timespec +{ + long ts_sec; + long ts_nsec; +}; /* Define this if memory objects should not be cached by the kernel. @@ -179,7 +185,7 @@ struct mutex dinmaplock; struct mutex sinmaplock; spin_lock_t gennumberlock; -int nextgennumber; +u_long nextgennumber; mach_port_t ufs_device; @@ -190,7 +196,7 @@ enum compat_mode COMPAT_GNU = 0, COMPAT_BSD42 = 1, COMPAT_BSD44 = 2, -}; +} compat_mode; /* If this is set, then this filesystem has two extensions: 1) directory entries include the type field. @@ -212,7 +218,7 @@ int direct_symlink_extension; /* From alloc.c: */ error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, struct protid *); -void ffs_blkfree(struct node *, volatile daddr_t bno, int size); +void ffs_blkfree(struct node *, daddr_t bno, long size); daddr_t ffs_blkpref (struct node *, daddr_t, int, daddr_t *); error_t ffs_realloccg(struct node *, daddr_t, daddr_t, int, int, daddr_t *, struct protid *); @@ -243,9 +249,9 @@ void drop_pager_softrefs (struct node *); void allow_pager_softrefs (struct node *); /* From subr.c: */ -void fragacct (int, long [], int); -int isblock(u_char *, daddr_t); -void clrblock(u_char *, daddr_t); -void setblock (u_char *, daddr_t); +void ffs_fragacct (struct fs *, int, long [], int); +int ffs_isblock(struct fs *, u_char *, daddr_t); +void ffs_clrblock(struct fs *, u_char *, daddr_t); +void ffs_setblock (struct fs *, u_char *, daddr_t); int skpc (u_char, u_int, u_char *); int scanc (u_int, u_char *, u_char [], u_char); -- cgit v1.2.3 From 2cfce87e9a8b27de0eeac18be9fa90b24bda6565 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:23:00 +0000 Subject: Formerly alloc.c.~13~ --- ufs/alloc.c | 112 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 7dfe5785..8afa6aa7 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -66,6 +66,17 @@ extern u_long nextgennumber; spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; +/* Forward declarations */ +static u_long ffs_hashalloc (struct node *, int, long, int, + u_long (*)(struct node *, int, daddr_t, int)); +static u_long ffs_alloccg (struct node *, int, daddr_t, int); +static daddr_t ffs_fragextend (struct node *, int, long, int, int); +static ino_t ffs_dirpref (struct fs *); +static u_long ffs_nodealloccg (struct node *, int, daddr_t, int); +static daddr_t ffs_alloccgblk (struct fs *, struct cg *, daddr_t); +static daddr_t ffs_mapsearch (struct fs *, struct cg *, daddr_t, int); +void ffs_clusteracct (struct fs *, struct cg *, daddr_t, int); + /* * Allocate a block in the file system. * @@ -85,6 +96,7 @@ spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; * 2) quadradically rehash into other cylinder groups, until an * available block is located. */ +error_t ffs_alloc(register struct node *np, daddr_t lbn, daddr_t bpref, @@ -94,7 +106,7 @@ ffs_alloc(register struct node *np, { register struct fs *fs; daddr_t bno; - int cg, error; + int cg; *bnp = 0; fs = sblock; @@ -154,16 +166,18 @@ nospace: * the original block. Failing that, the regular block allocator is * invoked to get an appropriate block. */ +error_t ffs_realloccg(register struct node *np, daddr_t lbprev, - daddr_t bpref, + volatile daddr_t bpref, int osize, int nsize, daddr_t *pbn, struct protid *cred) { register struct fs *fs; - int cg, request, error; + int cg, error; + volatile int request; daddr_t bprev, bno; *pbn = 0; @@ -182,7 +196,7 @@ ffs_realloccg(register struct node *np, spin_lock (&alloclock); - if (!isuid (0, cred) && freespace(fs, fs->fs_minfree) <= 0) + if (!diskfs_isuid (0, cred) && freespace(fs, fs->fs_minfree) <= 0) goto nospace; if (error = diskfs_catch_exception ()) return error; @@ -244,7 +258,7 @@ ffs_realloccg(register struct node *np, fs->fs_cstotal.cs_nffree > fs->fs_dsize * fs->fs_minfree / (2 * 100)) break; - log(LOG_NOTICE, "%s: optimization changed from SPACE to TIME\n", + printf ("%s: optimization changed from SPACE to TIME\n", fs->fs_fsmnt); fs->fs_optim = FS_OPTTIME; break; @@ -263,13 +277,11 @@ ffs_realloccg(register struct node *np, if (fs->fs_cstotal.cs_nffree < fs->fs_dsize * (fs->fs_minfree - 2) / 100) break; - log(LOG_NOTICE, "%s: optimization changed from TIME to SPACE\n", + printf ("%s: optimization changed from TIME to SPACE\n", fs->fs_fsmnt); fs->fs_optim = FS_OPTSPACE; break; default: - printf("dev = 0x%x, optim = %d, fs = %s\n", - ip->i_dev, fs->fs_optim, fs->fs_fsmnt); assert (0); /* NOTREACHED */ } @@ -505,9 +517,10 @@ diskfs_alloc_node (struct node *dir, struct node **npp) { register struct fs *fs; - register struct node *np; + struct node *np; ino_t ino, ipref; int cg, error; + int sex; fs = sblock; @@ -537,18 +550,19 @@ diskfs_alloc_node (struct node *dir, assert ("duplicate allocation" && !np->dn_stat.st_mode); if (np->dn_stat.st_blocks) { printf("free inode %d had %d blocks\n", - ino, ip->i_blocks); + ino, np->dn_stat.st_blocks); np->dn_stat.st_blocks = 0; np->dn_set_ctime = 1; } - ip->i_flags = 0; + np->dn_stat.st_flags = 0; /* * Set up a new generation number for this inode. */ spin_lock (&gennumberlock); - if (++nextgennumber < (u_long)time.tv_sec) - nextgennumber = time.tv_sec; - ip->i_gen = nextgennumber; + sex = diskfs_mtime->seconds; + if (++nextgennumber < (u_long)sex) + nextgennumber = sex; + np->dn_stat.st_gen = nextgennumber; spin_unlock (&gennumberlock); return (0); noinodes: @@ -652,7 +666,7 @@ ffs_blkpref(struct node *np, return (fs->fs_fpg * cg + fs->fs_frag); } spin_unlock (&alloclock); - return (NULL); + return 0; } spin_unlock (&alloclock); /* @@ -731,7 +745,7 @@ ffs_hashalloc(struct node *np, if (cg == fs->fs_ncg) cg = 0; } - return (NULL); + return 0; } /* @@ -749,19 +763,18 @@ ffs_fragextend(struct node *np, { register struct fs *fs; register struct cg *cgp; - struct buf *bp; long bno; int frags, bbase; - int i, error; + int i; fs = sblock; if (csum[cg].cs_nffree < numfrags(fs, nsize - osize)) - return (NULL); + return 0; frags = numfrags(fs, nsize); bbase = fragnum(fs, bprev); if (bbase > fragnum(fs, (bprev + frags - 1))) { /* cannot extend across a block boundary */ - return (NULL); + return 0; } #if 0 /* Wrong for GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), @@ -776,14 +789,14 @@ ffs_fragextend(struct node *np, #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ - return (NULL); + return 0; } cgp->cg_time = diskfs_mtime->seconds; bno = dtogd(fs, bprev); for (i = numfrags(fs, osize); i < frags; i++) if (isclr(cg_blksfree(cgp), bno + i)) { /* brelse(bp); */ - return (NULL); + return 0; } /* * the current fragment can be extended @@ -814,7 +827,7 @@ ffs_fragextend(struct node *np, * Check to see if a block of the appropriate size is available, * and if it is, allocate it. */ -static daddr_t +static u_long ffs_alloccg(struct node *np, int cg, daddr_t bpref, @@ -822,13 +835,12 @@ ffs_alloccg(struct node *np, { register struct fs *fs; register struct cg *cgp; - struct buf *bp; register int i; - int error, bno, frags, allocsiz; + int bno, frags, allocsiz; fs = sblock; if (csum[cg].cs_nbfree == 0 && size == fs->fs_bsize) - return (NULL); + return 0; #if 0 /* Not this way in GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); @@ -843,7 +855,7 @@ ffs_alloccg(struct node *np, if (!cg_chkmagic(cgp) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { /* brelse(bp); */ - return (NULL); + return 0; } cgp->cg_time = diskfs_mtime->seconds; if (size == fs->fs_bsize) { @@ -867,7 +879,7 @@ ffs_alloccg(struct node *np, */ if (cgp->cg_cs.cs_nbfree == 0) { /* brelse(bp); */ - return (NULL); + return 0; } bno = ffs_alloccgblk(fs, cgp, bpref); bpref = dtogd(fs, bno); @@ -884,8 +896,8 @@ ffs_alloccg(struct node *np, } bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); if (bno < 0) { -/* brelse(bp);* / - return (NULL); +/* brelse(bp); */ + return 0; } for (i = 0; i < frags; i++) clrbit(cg_blksfree(cgp), bno + i); @@ -994,7 +1006,7 @@ norot: */ bno = ffs_mapsearch(fs, cgp, bpref, (int)fs->fs_frag); if (bno < 0) - return (NULL); + return 0; cgp->cg_rotor = bno; gotit: blkno = fragstoblks(fs, bno); @@ -1110,7 +1122,7 @@ fail: * 2) allocate the next available inode after the requested * inode in the specified cylinder group. */ -static ino_t +static u_long ffs_nodealloccg(struct node *np, int cg, daddr_t ipref, @@ -1118,12 +1130,11 @@ ffs_nodealloccg(struct node *np, { register struct fs *fs; register struct cg *cgp; - struct buf *bp; - int error, start, len, loc, map, i; + int start, len, loc, map, i; fs = sblock; if (csum[cg].cs_nifree == 0) - return (NULL); + return 0; #if 0 /* Not this way in GNU Hurd ufs */ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); @@ -1137,9 +1148,9 @@ ffs_nodealloccg(struct node *np, #endif if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { /* brelse(bp); */ - return (NULL); + return 0; } - cgp->cg_time = time.tv_sec; + cgp->cg_time = diskfs_mtime->seconds; if (ipref) { ipref %= fs->fs_ipg; if (isclr(cg_inosused(cgp), ipref)) @@ -1163,7 +1174,7 @@ ffs_nodealloccg(struct node *np, goto gotit; } } - assort (0); + assert (0); /* NOTREACHED */ gotit: setbit(cg_inosused(cgp), ipref); @@ -1187,21 +1198,21 @@ gotit: * free map. If a fragment is deallocated, a possible * block reassembly is checked. */ +void ffs_blkfree(register struct node *np, daddr_t bno, long size) { register struct fs *fs; register struct cg *cgp; - struct buf *bp; daddr_t blkno; - int i, error, cg, blk, frags, bbase; + int i, cg, blk, frags, bbase; fs = sblock; assert ((u_int)size <= fs->fs_bsize && !fragoff (fs, size)); cg = dtog(fs, bno); if ((u_int)bno >= fs->fs_size) { - printf("bad block %d, ino %d\n", bno, np->dn->number); + printf("bad block %ld, ino %d\n", bno, np->dn->number); /* ffs_fserr(fs, ip->i_uid, "bad block"); */ return; } @@ -1220,7 +1231,7 @@ ffs_blkfree(register struct node *np, /* brelse(bp); */ return; } - cgp->cg_time = time.tv_sec; + cgp->cg_time = diskfs_mtime->seconds; bno = dtogd(fs, bno); if (size == fs->fs_bsize) { blkno = fragstoblks(fs, bno); @@ -1245,7 +1256,7 @@ ffs_blkfree(register struct node *np, */ frags = numfrags(fs, size); for (i = 0; i < frags; i++) { - assert (!isset (cg_blksfree(cgp, bno + i))); + assert (!isset (cg_blksfree(cgp), bno + i)); setbit(cg_blksfree(cgp), bno + i); } cgp->cg_cs.cs_nffree += i; @@ -1290,8 +1301,7 @@ diskfs_free_node (struct node *np, mode_t mode) register struct fs *fs; register struct cg *cgp; ino_t ino = np->dn->number; - struct buf *bp; - int error, cg; + int cg; fs = sblock; assert (ino < fs->fs_ipg * fs->fs_ncg); @@ -1309,13 +1319,13 @@ diskfs_free_node (struct node *np, mode_t mode) #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ - return (0); + return; } - cgp->cg_time = time.tv_sec; + cgp->cg_time = diskfs_mtime->seconds; ino %= fs->fs_ipg; if (isclr(cg_inosused(cgp), ino)) { - printf("dev = 0x%x, ino = %d, fs = %s\n", - pip->i_dev, ino, fs->fs_fsmnt); +/* printf("dev = 0x%x, ino = %d, fs = %s\n", + pip->i_dev, ino, fs->fs_fsmnt); */ assert (diskfs_readonly); } clrbit(cg_inosused(cgp), ino); @@ -1324,14 +1334,13 @@ diskfs_free_node (struct node *np, mode_t mode) cgp->cg_cs.cs_nifree++; fs->fs_cstotal.cs_nifree++; csum[cg].cs_nifree++; - if ((ap->a_mode & IFMT) == IFDIR) { + if ((mode & IFMT) == IFDIR) { cgp->cg_cs.cs_ndir--; fs->fs_cstotal.cs_ndir--; csum[cg].cs_ndir--; } fs->fs_fmod = 1; /* bdwrite(bp); */ - return (0); } /* @@ -1398,6 +1407,7 @@ ffs_mapsearch(register struct fs *fs, * * Cnt == 1 means free; cnt == -1 means allocating. */ +void ffs_clusteracct(struct fs *fs, struct cg *cgp, daddr_t blkno, -- cgit v1.2.3 From 7490c7f6549dd620ffc24f396b6fd36151ba0f58 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:28:01 +0000 Subject: Formerly dir.c.~23~ --- ufs/dir.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 9cbb42d5..7c793d84 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -326,7 +326,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, || DIRSIZ (DIRECT_NAMLEN (entry)) > entry->d_reclen || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { - fprintf (stderr, "Bad directory entry: inode: %ld offset: %d\n", + fprintf (stderr, "Bad directory entry: inode: %d offset: %d\n", dp->dn->number, currentoff - blockaddr); return ENOENT; } @@ -443,7 +443,7 @@ diskfs_direnter(struct node *dp, ds->entry->d_ino = np->dn->number; DIRECT_NAMLEN (ds->entry) = namelen; if (direct_symlink_extension) - ds->d_type = IFTODT (np->dn->dn_stat.st_mode); + ds->entry->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, ds->entry->d_name, namelen + 1); break; @@ -460,7 +460,7 @@ diskfs_direnter(struct node *dp, new->d_reclen = ds->entry->d_reclen - oldneeded; DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) - ds->d_type = IFTODT (np->dn->dn_stat.st_mode); + new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); ds->entry->d_reclen = oldneeded; @@ -500,7 +500,7 @@ diskfs_direnter(struct node *dp, new->d_reclen = totfreed; DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) - new->d_type = IFTODT (np->dn->dn_stat.st_mode); + new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); break; @@ -522,7 +522,7 @@ diskfs_direnter(struct node *dp, new->d_reclen = DIRBLKSIZ; DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) - new->d_type = IFTODT (np->dn->dn_stat.st_mode); + new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); break; @@ -620,7 +620,7 @@ diskfs_dirrewrite(struct node *dp, ds->entry->d_ino = np->dn->number; if (direct_symlink_extension) - ds->entry->d_type = IFTODT (np->dn->dn_stat.st_mode); + ds->entry->d_type = IFTODT (np->dn_stat.st_mode); vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); -- cgit v1.2.3 From 28f85f65a9b3e1044006394e3862c95017aa7ad6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:36:29 +0000 Subject: entered into RCS --- ufs/dinode.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ufs/dinode.h b/ufs/dinode.h index 8f9dae0e..00be0d94 100644 --- a/ufs/dinode.h +++ b/ufs/dinode.h @@ -71,6 +71,14 @@ #define NDADDR 12 /* Direct addresses in inode. */ #define NIADDR 3 /* Indirect addresses in inode. */ +/* Maximum value of di_nlink field. */ +#define LINK_MAX 32767 + +/* Indexes into di_ib */ +#define INDIR_SINGLE 0 +#define INDIR_DOUBLE 1 +#define INDIR_TRIPLE 2 /* NOT SUPPORTED */ + struct dinode { u_short di_model; /* 0: IFMT and permissions. */ short di_nlink; /* 2: File link count. */ -- cgit v1.2.3 From a8b691bf8231ff07a1074bd8a254be368b616f21 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:45:34 +0000 Subject: entered into RCS --- ufs/fs.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ufs/fs.h b/ufs/fs.h index 7a4e6d7c..a2a3cc9b 100644 --- a/ufs/fs.h +++ b/ufs/fs.h @@ -83,6 +83,16 @@ * to determine block availability, aligned fragments are examined. */ +/* + * 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 make make some file systems unmountable. + */ +#define MAXBSIZE MAXPHYS +#define MAXFRAG 8 + /* * MINBSIZE is the smallest allowable block size. * In order to insure that it is possible to create files of size @@ -465,14 +475,18 @@ struct ocg { /* * 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) \ +/* Changed from BSD to use allocsize instead of i_size. */ +#define blksize(fs, np, lbn) \ + (((lbn) >= NDADDR || (np)->allocsize >= ((lbn) + 1) << (fs)->fs_bshift) \ ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) + : (fragroundup(fs, blkoff(fs, (np)->allocsize)))) + +#if 0 /* Don't use this */ #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)))) +#endif /* * Number of disk sectors per block; assumes DEV_BSIZE byte sector size. -- cgit v1.2.3 From 2428fdffd15b737a0fa4c2714c44c99d7223e735 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:49:36 +0000 Subject: Formerly sizes.c.~16~ --- ufs/sizes.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index d7f132c0..c34474f5 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -22,6 +22,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" #include "fs.h" #include "dinode.h" +#include #ifdef DONT_CACHE_MEMORY_OBJECTS #define MAY_CACHE 0 @@ -69,14 +70,16 @@ diskfs_truncate (struct node *np, } /* Calculate block number of last block */ - lastblock = lblkno (length + sblock->fs_bsize - 1) - 1; - olastblock = lblkno (osize + sblock->fs_bsize - 1) - 1; + lastblock = lblkno (sblock, length + sblock->fs_bsize - 1) - 1; + olastblock = lblkno (sblock, osize + sblock->fs_bsize - 1) - 1; /* If the prune is not to a block boundary, zero the bit upto the next block boundary. */ - if (blkoff (length)) + if (blkoff (sblock, length)) diskfs_node_rdwr (np, (void *) zeroblock, length, - blksize (np, lastblock) - blkoff (length), 1, 0, 0); + (blksize (sblock, np, lastblock) + - blkoff (sblock, length)), + 1, 0, 0); /* We are going to throw away the block pointers for the blocks olastblock+1 through lastblock. This will cause the underlying @@ -137,8 +140,9 @@ diskfs_truncate (struct node *np, /* Prune the block pointers handled by the sindir pager. This will free all the indirect blocks and such as necessary. */ - sindir_drop (np, lblkno((first2free - NDADDR) * sizeof (daddr_t)), - lblkno ((olastblock - NDADDR) * sizeof (daddr_t))); + sindir_drop (np, lblkno(sblock, + (first2free - NDADDR) * sizeof (daddr_t)), + lblkno (sblock, (olastblock - NDADDR) * sizeof (daddr_t))); if (!np->dn->fileinfo) sin_unmap (np); @@ -154,7 +158,7 @@ diskfs_truncate (struct node *np, dinodes[np->dn->number].di_db[idx] = 0; assert (idx <= olastblock); if (idx == olastblock) - bsize = blksize (np, idx); + bsize = blksize (sblock, np, idx); else bsize = sblock->fs_bsize; ffs_blkfree (np, bn, bsize); @@ -171,12 +175,12 @@ diskfs_truncate (struct node *np, { off_t oldspace, newspace; - oldspace = blksize (np, lastblock); - newspace = fragroundup (blkoff (length));; + oldspace = blksize (sblock, np, lastblock); + newspace = fragroundup (sblock, blkoff (sblock, length));; assert (newspace); if (oldspace - newspace) { - bn += numfrags (newspace); + bn += numfrags (sblock, newspace); ffs_blkfree (np, bn, oldspace - newspace); np->dn_stat.st_blocks -= (oldspace - newspace) / DEV_BSIZE; np->dn_stat_dirty = 1; @@ -185,9 +189,9 @@ diskfs_truncate (struct node *np, } if (lastblock < NDADDR) - np->allocsize = fragroundup (length); + np->allocsize = fragroundup (sblock, length); else - np->allocsize = blkroundup (length); + np->allocsize = blkroundup (sblock, length); rwlock_writer_unlock (&np->dn->datalock, np->dn); @@ -338,20 +342,20 @@ diskfs_grow (struct node *np, } /* This is the logical block number of what will be the last block. */ - lbn = lblkno (end + sblock->fs_bsize - 1) - 1; + lbn = lblkno (sblock, end + sblock->fs_bsize - 1) - 1; /* This is the size to be of that block if it is in the NDADDR array. */ - size = fragroundup (blkoff (end)); + size = fragroundup (sblock, blkoff (sblock, end)); if (size == 0) size = sblock->fs_bsize; /* if we are writing a new block, then an old one may need to be reallocated into a full block. */ - nb = lblkno (np->allocsize + sblock->fs_bsize - 1) - 1; + nb = lblkno (sblock, np->allocsize + sblock->fs_bsize - 1) - 1; if (np->allocsize && nb < NDADDR && nb < lbn) { - osize = blksize (np, nb); + osize = blksize (sblock, np, nb); if (osize < sblock->fs_bsize && osize > 0) { daddr_t old_pbn; @@ -388,7 +392,7 @@ diskfs_grow (struct node *np, if (nb != 0) { /* consider need to reallocate a fragment. */ - osize = blkoff (np->allocsize); + osize = blkoff (sblock, np->allocsize); if (osize == 0) osize = sblock->fs_bsize; if (size > osize) @@ -427,7 +431,7 @@ diskfs_grow (struct node *np, dealloc_size = size; dinodes[np->dn->number].di_db[lbn] = pbn; } - np->allocsize = fragroundup (end); + np->allocsize = fragroundup (sblock, end); } else { @@ -436,11 +440,11 @@ diskfs_grow (struct node *np, if (np->dn->sinloc) { sin_remap (np, end); - np->allocsize = blkroundup (end); + np->allocsize = blkroundup (sblock, end); } else { - np->allocsize = blkroundup (end); + np->allocsize = blkroundup (sblock, end); sin_map (np); } -- cgit v1.2.3 From dbc48a1fc573f362b3afc7e76b261044aef5a698 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:54:51 +0000 Subject: Formerly hyper.c.~7~ --- ufs/hyper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index c9ffcc63..a1a19706 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -17,6 +17,7 @@ #include "ufs.h" #include "fs.h" +#include "dinode.h" #include #include @@ -49,7 +50,7 @@ get_hypermetadata (void) if (sblock->fs_maxsymlinklen > MAXSYMLINKLEN) { - fprintf (stderr, "Max shortcut symlinklen %d is too big (max is %d)\n", + fprintf (stderr, "Max shortcut symlinklen %ld is too big (max is %ld)\n", sblock->fs_maxsymlinklen, MAXSYMLINKLEN); exit (1); } @@ -70,7 +71,8 @@ get_hypermetadata (void) else direct_symlink_extension = 0; - err = dev_read_sync (fsbtodb (sblock->fs_csaddr), (vm_address_t *) &csum, + err = dev_read_sync (fsbtodb (sblock, sblock->fs_csaddr), + (vm_address_t *) &csum, sblock->fs_fsize * howmany (sblock->fs_cssize, sblock->fs_fsize)); assert (!err); @@ -88,7 +90,7 @@ diskfs_set_hypermetadata (int wait, int clean) spin_lock (&alloclock); if (csum_dirty) { - (*writefn)(fsbtodb (sblock->fs_csaddr), (vm_address_t) csum, + (*writefn)(fsbtodb (sblock, sblock->fs_csaddr), (vm_address_t) csum, sblock->fs_fsize * howmany (sblock->fs_cssize, sblock->fs_fsize)); csum_dirty = 0; -- cgit v1.2.3 From b36c0f1892a2c5d66b9fc12faea7479678593872 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 15 Jul 1994 17:58:08 +0000 Subject: Formerly subr.c.~6~ --- ufs/subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/subr.c b/ufs/subr.c index 5a6acd88..5833dfef 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -197,7 +197,7 @@ ffs_clrblock(fs, cp, h) cp[h >> 3] &= ~(0x01 << (h & 0x7)); return; default: - panic("ffs_clrblock"); + assert (0); } } -- cgit v1.2.3 From 5a98ad25014b20f4303abba4c3e3db0a2c8e5a4e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 18 Jul 1994 20:01:23 +0000 Subject: Formerly subr.c.~7~ --- ufs/subr.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ufs/subr.c b/ufs/subr.c index 5833dfef..6c7ea5f2 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -226,6 +226,40 @@ ffs_setblock(fs, cp, h) cp[h >> 3] |= (0x01 << (h & 0x7)); return; default: - panic("ffs_setblock"); + assert (0); } } + +/* Taken from 4.4 BSD sys/libkern/skpc.c: + @(#)skpc.c 8.1 (Berkeley) 6/10/93 +*/ +int +skpc(mask0, size, cp0) + int mask0; + int size; + char *cp0; +{ + register u_char *cp, *end, mask; + + mask = mask0; + cp = (u_char *)cp0; + for (end = &cp[size]; cp < end && *cp == mask; ++cp); + return (end - cp); +} + +/* Taken from 4.4 BSD sys/libkern/scanc.c: + @(#)scanc.c 8.1 (Berkeley) 6/10/93 +*/ +int +scanc(size, cp, table, mask0) + u_int size; + register u_char *cp, table[]; + int mask0; +{ + register u_char *end; + register u_char mask; + + mask = mask0; + for (end = &cp[size]; cp < end && (table[*cp] & mask) == 0; ++cp); + return (end - cp); +} -- cgit v1.2.3 From efca89c3f5a5bd907d7328e0a1b4208b07511e82 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 18 Jul 1994 20:28:31 +0000 Subject: Formerly ufs.h.~18~ --- ufs/ufs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 2fb825cc..2ffa835d 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -253,5 +253,5 @@ void ffs_fragacct (struct fs *, int, long [], int); int ffs_isblock(struct fs *, u_char *, daddr_t); void ffs_clrblock(struct fs *, u_char *, daddr_t); void ffs_setblock (struct fs *, u_char *, daddr_t); -int skpc (u_char, u_int, u_char *); -int scanc (u_int, u_char *, u_char [], u_char); +int skpc (int, int, char *); +int scanc (u_int, u_char *, u_char [], int); -- cgit v1.2.3 From 3f2794eb61e97bbf2890944dcf335ed241d9f4f0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 00:19:10 +0000 Subject: Initial revision --- ufs/pager.c | 937 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 937 insertions(+) create mode 100644 ufs/pager.c diff --git a/ufs/pager.c b/ufs/pager.c new file mode 100644 index 00000000..7aea0f9d --- /dev/null +++ b/ufs/pager.c @@ -0,0 +1,937 @@ +/* Pager for ufs + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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 "ufs.h" +#include "fs.h" +#include "dinode.h" +#include +#include + +mach_port_t dinport; +mach_port_t dinodeport; +mach_port_t cgport; + +/* Filesystem blocks of inodes per cylinder group */ +static int infsb_pcg; + +spin_lock_t pagerlistlock = SPIN_LOCK_INITIALIZER; +struct user_pager_info *filelist, *sinlist; + +static void enqueue_pager (struct user_pager_info *); +static void dequeue_pager (struct user_pager_info *); +static daddr_t indir_alloc (struct node *, int, int); + +/* Locks all nodes' sininfo and fileinfo fields. */ +static struct mutex pagernplock = MUTEX_INITIALIZER; + +#ifdef DONT_CACHE_MEMORY_OBJECTS +#define MAY_CACHE 0 +#else +#define MAY_CACHE 1 +#endif + +/* Find the location on disk of page OFFSET in pager UPI. Return the + disk address (in disk block) in *ADDR. If *NPLOCK is set on + return, then release that mutex after I/O on the data has + completed. Set DISKSIZE to be the amount of valid data on disk. + (If this is an unallocated block, then set *ADDR to zero.) */ +static error_t +find_address (struct user_pager_info *upi, + vm_address_t offset, + daddr_t *addr, + int *disksize, + struct rwlock **nplock, + struct disknode **dnp) +{ + int vblkno = lblkno (sblock, offset); + int fsbaddr; + struct node *volatile np; + error_t err; + struct mutex *maplock = 0; + + if (upi->type != FILE_DATA) + *disksize = __vm_page_size; + + switch (upi->type) + { + default: + assert (0); + + case CG: + fsbaddr = cgtod (sblock, vblkno); + *nplock = 0; + break; + + case DINODE: + fsbaddr = (cgimin (sblock, vblkno / infsb_pcg) + + blkstofrags (sblock, vblkno % infsb_pcg)); + *nplock = 0; + break; + + case DINDIR: + np = ifind (vblkno); + + rwlock_reader_lock (&np->dn->dinlock, np->dn); + *nplock = &np->dn->dinlock; + *dnp = np->dn; + if (err = diskfs_catch_exception ()) + goto error; + + fsbaddr = dinodes[np->dn->number].di_ib[INDIR_DOUBLE]; + diskfs_end_catch_exception (); + break; + + case SINDIR: + np = upi->np; + + rwlock_reader_lock (&np->dn->sinlock, np->dn); + *nplock = &np->dn->sinlock; + *dnp = np->dn; + + if (err = diskfs_catch_exception ()) + goto error; + + if (vblkno == 0) + fsbaddr = dinodes[np->dn->number].di_ib[INDIR_SINGLE]; + else + { + mutex_lock (&dinmaplock); + maplock = &dinmaplock; + if (!np->dn->dinloc) + din_map (np); + fsbaddr = np->dn->dinloc[vblkno - 1]; + mutex_unlock (&dinmaplock); + } + + diskfs_end_catch_exception (); + break; + + case FILE_DATA: + np = upi->np; + + rwlock_reader_lock (&np->dn->datalock, np->dn); + *nplock = &np->dn->datalock; + *dnp = np->dn; + + if (offset >= np->allocsize) + { + err = EIO; + goto error; + } + + if (offset + __vm_page_size > np->allocsize) + *disksize = np->allocsize - offset; + else + *disksize = __vm_page_size; + + if (err = diskfs_catch_exception ()) + goto error; + + if (vblkno < NDADDR) + fsbaddr = dinodes[np->dn->number].di_db[vblkno]; + else + { + mutex_lock (&sinmaplock); + maplock = &sinmaplock; + if (!np->dn->sinloc) + sin_map (np); + fsbaddr = np->dn->sinloc[vblkno - NDADDR]; + mutex_unlock (&sinmaplock); + } + diskfs_end_catch_exception (); + break; + } + + if (fsbaddr) + *addr = fsbtodb (sblock, fsbaddr) + blkoff (sblock, offset) / DEV_BSIZE; + else + *addr = 0; + + return 0; + + error: + if (*nplock) + rwlock_reader_unlock (*nplock, *dnp); + if (maplock) + mutex_unlock (maplock); + return err; +} + +/* Implement the pager_read_page callback from the pager library. See + for the interface description. */ +error_t +pager_read_page (struct user_pager_info *pager, + vm_offset_t page, + vm_address_t *buf, + int *writelock) +{ + error_t err; + struct rwlock *nplock; + daddr_t addr; + int disksize; + struct disknode *dn; + + err = find_address (pager, page, &addr, &disksize, &nplock, &dn); + if (err) + return err; + + if (addr) + { + err = dev_read_sync (addr, (void *)buf, disksize); + if (!err && disksize != __vm_page_size) + bzero ((void *)(*buf + disksize), __vm_page_size - disksize); + *writelock = 0; + } + else + { + vm_allocate (mach_task_self (), buf, __vm_page_size, 1); + *writelock = 1; + } + + if (nplock) + rwlock_reader_unlock (nplock, dn); + + return err; +} + +/* Implement the pager_write_page callback from the pager library. See + for the interface description. */ +error_t +pager_write_page (struct user_pager_info *pager, + vm_offset_t page, + vm_address_t buf) +{ + daddr_t addr; + int disksize; + struct rwlock *nplock; + error_t err; + struct disknode *dn; + + err = find_address (pager, page, &addr, &disksize, &nplock, &dn); + if (err) + return err; + + if (addr) + err = dev_write_sync (addr, buf, disksize); + else + { + printf ("Attempt to write unallocated disk\n."); + err = 0; /* unallocated disk; + error would be pointless */ + } + + if (nplock) + rwlock_reader_unlock (nplock, dn); + + return err; +} + +/* Implement the pager_unlock_page callback from the pager library. See + for the interface description. */ +error_t +pager_unlock_page (struct user_pager_info *pager, + vm_offset_t address) +{ + struct node *volatile np; + error_t err; + daddr_t vblkno; + daddr_t *slot, *table; + daddr_t newblk; + + /* Problem--where to get cred values for allocation here? */ + + vblkno = address / sblock->fs_bsize; + + switch (pager->type) + { + case DINDIR: + np = ifind (vblkno); + + rwlock_writer_lock (&np->dn->dinlock, np->dn); + if (diskfs_catch_exception ()) + err = EIO; + else + { + if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE]) + err = 0; + else + { + newblk = indir_alloc (np, INDIR_DOUBLE, 0); + if (newblk) + { + dinodes[np->dn->number].di_ib[INDIR_DOUBLE] = newblk; + err = 0; + } + else + err = ENOSPC; + } + diskfs_end_catch_exception (); + } + rwlock_writer_unlock (&np->dn->dinlock, np->dn); + break; + + case SINDIR: + np = pager->np; + rwlock_writer_lock (&np->dn->sinlock, np->dn); + + if (diskfs_catch_exception ()) + err = EIO; + else + { + mutex_lock (&dinmaplock); + if (vblkno == 0) + slot = &dinodes[np->dn->number].di_ib[INDIR_SINGLE]; + else + { + if (!np->dn->dinloc) + din_map (np); + slot = &np->dn->dinloc[vblkno - 1]; + } + + if (*slot) + err = 0; + else + { + newblk = indir_alloc (np, INDIR_SINGLE, vblkno); + if (newblk) + { + *slot = newblk; + err = 0; + } + else + err = ENOSPC; + } + mutex_unlock (&dinmaplock); + diskfs_end_catch_exception (); + } + rwlock_writer_unlock (&np->dn->sinlock, np->dn); + break; + + case FILE_DATA: + np = pager->np; + rwlock_writer_lock (&np->dn->datalock, np->dn); + + /* If this is the last block, we don't let it get unlocked. */ + if (address + __vm_page_size + > blkroundup (sblock, np->allocsize) - sblock->fs_bsize) + { + printf ("attempt to unlock at last block denied\n"); + rwlock_writer_unlock (&np->dn->datalock, np->dn); + return EIO; + } + + if (diskfs_catch_exception ()) + err = EIO; + else + { + mutex_lock (&sinmaplock); + if (vblkno < NDADDR) + { + slot = &dinodes[np->dn->number].di_db[vblkno]; + table = dinodes[np->dn->number].di_db; + } + else + { + if (!np->dn->sinloc) + sin_map (np); + slot = &np->dn->sinloc[vblkno - NDADDR]; + table = np->dn->sinloc; + } + + if (*slot) + err = 0; + else + { + ffs_alloc (np, vblkno, + ffs_blkpref (np, vblkno, slot - table, table), + sblock->fs_bsize, &newblk, 0); + if (newblk) + { + *slot = newblk; + err = 0; + } + else + err = ENOSPC; + } + mutex_unlock (&sinmaplock); + diskfs_end_catch_exception (); + } + rwlock_writer_unlock (&np->dn->datalock, np->dn); + break; + + default: + err = 0; + } + + return err; +} + +/* Implement the pager_report_extent callback from the pager library. See + for the interface description. */ +inline error_t +pager_report_extent (struct user_pager_info *pager, + vm_address_t *offset, + vm_size_t *size) +{ + int sizet; + + *offset = 0; + switch (pager->type) + { + case DINODE: + *size = sblock->fs_ipg * sblock->fs_ncg * sizeof (struct dinode); + break; + + case CG: + *size = sblock->fs_bsize * sblock->fs_ncg; + break; + + case DINDIR: + *size = sblock->fs_ipg * sblock->fs_ncg * sblock->fs_bsize; + break; + + case SINDIR: + sizet = pager->np->allocsize; + sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; + sizet -= NDADDR; + sizet *= sizeof (daddr_t); + sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; + *size = sizet; + break; + + case FILE_DATA: + *size = pager->np->allocsize; + break; + } + + *size = round_page (*size); + return 0; +} + +/* Implement the pager_clear_user_data callback from the pager library. + See for the interface description. */ +void +pager_clear_user_data (struct user_pager_info *upi) +{ + struct node *np = upi->np; + + switch (upi->type) + { + case FILE_DATA: + mutex_lock (&sinmaplock); + mutex_lock (&pagernplock); + np->dn->fileinfo = 0; + mutex_unlock (&pagernplock); + if (np->dn->sinloc) + sin_unmap (np); + mutex_unlock (&sinmaplock); + break; + + case SINDIR: + mutex_lock (&dinmaplock); + mutex_lock (&pagernplock); + np->dn->sininfo = 0; + mutex_unlock (&pagernplock); + if (np->dn->dinloc) + din_unmap (np); + mutex_unlock (&dinmaplock); + break; + + case DINDIR: + dinpager = 0; + return; + case CG: + cgpager = 0; + return; + case DINODE: + dinodepager = 0; + return; + } + + if (np) + diskfs_nrele_light (np); + dequeue_pager (upi); + free (upi); +} + + +/* This is called (with sinmaplock held) to map the contents of the + single indirect blocks of node NP. */ +void +sin_map (struct node *np) +{ + int err; + struct user_pager_info *upi; + mach_port_t port; + vm_address_t offset; + vm_size_t extent; + + assert (!np->dn->sinloc); + + mutex_lock (&pagernplock); + if (np->dn->sininfo) + { + upi = np->dn->sininfo; + port = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), port, port, + MACH_MSG_TYPE_MAKE_SEND); + } + else + { + upi = malloc (sizeof (struct user_pager_info)); + upi->type = SINDIR; + upi->np = np; + diskfs_nref_light (np); + + upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + np->dn->sininfo = upi; + enqueue_pager (upi); + port = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), port, port, + MACH_MSG_TYPE_MAKE_SEND); + } + mutex_unlock (&pagernplock); + + pager_report_extent (upi, &offset, &extent); + + err = vm_map (mach_task_self (), (vm_address_t *)&np->dn->sinloc, + extent, 0, 1, port, offset, 0, VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); + mach_port_deallocate (mach_task_self (), port); + + assert (!err); + + diskfs_register_memory_fault_area (np->dn->sininfo->p, offset, + np->dn->sinloc, extent); +} + +/* This is caled when a file (NP) grows (to size NEWSIZE) to see + if the single indirect mapping needs to grow to. sinmaplock + must be held. + The caller must set ip->i_allocsize to reflect newsize. */ +void +sin_remap (struct node *np, + int newsize) +{ + struct user_pager_info *upi; + int err; + vm_address_t offset; + vm_size_t size; + mach_port_t port; + + mutex_lock (&pagernplock); + upi = np->dn->sininfo; + + pager_report_extent (upi, &offset, &size); + + /* This is the same calculation as in pager_report_extent + for the SINDIR case. */ + newsize = (newsize + sblock->fs_bsize - 1) / sblock->fs_bsize; + newsize -= NDADDR; + newsize *= sizeof (daddr_t); + newsize = (newsize + sblock->fs_bsize - 1) / sblock->fs_bsize; + newsize = round_page (newsize); + + assert (newsize >= size); + if (newsize != size) + { + diskfs_unregister_memory_fault_area (np->dn->sinloc, size); + vm_deallocate (mach_task_self (), (u_int) np->dn->sinloc, size); + + port = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), port, port, + MACH_MSG_TYPE_MAKE_SEND); + err = vm_map (mach_task_self (), (u_int *)&np->dn->sinloc, size, + 0, 1, port, 0, 0, VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); + mach_port_deallocate (mach_task_self (), port); + assert (!err); + diskfs_register_memory_fault_area (np->dn->sininfo->p, 0, + np->dn->sinloc, size); + } + mutex_unlock (&pagernplock); +} + +/* This is called (with sinmaplock set) to unmap the + single indirect block mapping of node NP. */ +void +sin_unmap (struct node *np) +{ + vm_offset_t start; + vm_size_t len; + + assert (np->dn->sinloc); + pager_report_extent (np->dn->sininfo, &start, &len); + diskfs_unregister_memory_fault_area (np->dn->sinloc, len); + vm_deallocate (mach_task_self (), (u_int) np->dn->sinloc, len); + np->dn->sinloc = 0; +} + +/* This is called (with dinmaplock set) to map the contents + of the double indirect block of node NP. */ +void +din_map (struct node *np) +{ + int err; + + assert (!np->dn->dinloc); + + err = vm_map (mach_task_self (), (vm_address_t *)&np->dn->dinloc, + sblock->fs_bsize, 0, 1, dinport, + np->dn->number * sblock->fs_bsize, 0, + VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, + VM_INHERIT_NONE); + assert (!err); + diskfs_register_memory_fault_area (dinpager->p, + np->dn->number * sblock->fs_bsize, + np->dn->dinloc, sblock->fs_bsize); +} + +/* This is called (with dinmaplock set) to unmap the double + indirect block mapping of node NP. */ +void +din_unmap (struct node *np) +{ + diskfs_unregister_memory_fault_area (np->dn->dinloc, sblock->fs_bsize); + vm_deallocate (mach_task_self (), (u_int) np->dn->dinloc, sblock->fs_bsize); + np->dn->dinloc = 0; +} + +/* Initialize the pager subsystem. */ +void +pager_init () +{ + struct user_pager_info *upi; + vm_address_t offset; + vm_size_t size; + error_t err; + + /* firewalls: */ + assert ((DEV_BSIZE % sizeof (struct dinode)) == 0); + assert ((__vm_page_size % DEV_BSIZE) == 0); + assert ((sblock->fs_bsize % DEV_BSIZE) == 0); + assert ((sblock->fs_ipg % sblock->fs_inopb) == 0); + assert (__vm_page_size <= sblock->fs_bsize); + + infsb_pcg = sblock->fs_ipg / sblock->fs_inopb; + + vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); + + upi = malloc (sizeof (struct user_pager_info)); + upi->type = DINODE; + upi->np = 0; + upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + dinodepager = upi; + dinodeport = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), dinodeport, dinodeport, + MACH_MSG_TYPE_MAKE_SEND); + pager_report_extent (upi, &offset, &size); + err = vm_map (mach_task_self (), (vm_address_t *)&dinodes, size, + 0, 1, dinodeport, offset, 0, VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); + assert (!err); + diskfs_register_memory_fault_area (dinodepager->p, 0, dinodes, size); + + upi = malloc (sizeof (struct user_pager_info)); + upi->type = CG; + upi->np = 0; + upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + cgpager = upi; + cgport = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), cgport, cgport, + MACH_MSG_TYPE_MAKE_SEND); + pager_report_extent (upi, &offset, &size); + err = vm_map (mach_task_self (), &cgs, size, + 0, 1, cgport, offset, 0, VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); + assert (!err); + diskfs_register_memory_fault_area (cgpager->p, 0, (void *)cgs, size); + + upi = malloc (sizeof (struct user_pager_info)); + upi->type = DINDIR; + upi->np = 0; + upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + dinpager = upi; + dinport = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), dinport, dinport, + MACH_MSG_TYPE_MAKE_SEND); +} + +/* Allocate one indirect block for NP. TYPE is either INDIR_DOUBLE or + INDIR_SINGLE; IND is (for INDIR_SINGLE) the index of the block + (The first block is 0, the next 1, etc.). */ +static daddr_t +indir_alloc (struct node *np, + int type, + int ind) +{ + daddr_t bn; + daddr_t lbn; + int error; + + switch (type) + { + case INDIR_DOUBLE: + lbn = NDADDR + sblock->fs_bsize / sizeof (daddr_t); + break; + case INDIR_SINGLE: + if (ind == 0) + lbn = NDADDR; + else + lbn = NDADDR + ind * sblock->fs_bsize / sizeof (daddr_t); + break; + default: + assert (0); + } + + if (error = ffs_alloc (np, NDADDR, + ffs_blkpref (np, lbn, 0, (daddr_t *)0), + sblock->fs_bsize, &bn, 0)) + return 0; + + /* We do this write synchronously so that the inode never + points at an indirect block full of garbage */ + if (dev_write_sync (fsbtodb (sblock, bn), zeroblock, sblock->fs_bsize)) + { + ffs_blkfree (np, bn, sblock->fs_bsize); + return 0; + } + else + return bn; +} + +/* Write a single dinode (NP->dn->number) to disk. This might sync more + than actually necessary; it's really just an attempt to avoid syncing + all the inodes. Return immediately if WAIT is clear. */ +void +sync_dinode (struct node *np, + int wait) +{ + vm_offset_t offset, offsetpg; + + offset = np->dn->number * sizeof (struct dinode); + offsetpg = offset / __vm_page_size; + offset = offsetpg * __vm_page_size; + + pager_sync_some (dinodepager->p, offset, __vm_page_size, wait); +} + +/* This syncs a single file (NP) to disk. Wait for all I/O to complete + if WAIT is set. NP->lock must be held. */ +void +diskfs_file_update (struct node *np, + int wait) +{ + mutex_lock (&pagernplock); + if (np->dn->fileinfo) + pager_sync (np->dn->fileinfo->p, wait); + mutex_unlock (&pagernplock); + + mutex_lock (&pagernplock); + if (np->dn->sininfo) + pager_sync (np->dn->sininfo->p, wait); + mutex_unlock (&pagernplock); + + pager_sync_some (dinpager->p, np->dn->number * sblock->fs_bsize, + sblock->fs_bsize, wait); + + diskfs_node_update (np, wait); +} + +/* Call this to create a FILE_DATA pager and return a send right. + NP must be locked. The toplock must be locked. */ +mach_port_t +diskfs_get_filemap (struct node *np) +{ + struct user_pager_info *upi; + mach_port_t right; + + assert (S_ISDIR (np->dn_stat.st_mode) + || S_ISREG (np->dn_stat.st_mode) + || (S_ISLNK (np->dn_stat.st_mode) + && (!direct_symlink_extension + || np->dn_stat.st_size >= sblock->fs_maxsymlinklen))); + + mutex_lock (&pagernplock); + if (!np->dn->fileinfo) + { + upi = malloc (sizeof (struct user_pager_info)); + upi->type = FILE_DATA; + upi->np = np; + diskfs_nref_light (np); + upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); + np->dn->fileinfo = upi; + enqueue_pager (upi); + } + right = pager_get_port (np->dn->fileinfo->p); + mutex_unlock (&pagernplock); + mach_port_insert_right (mach_task_self (), right, right, + MACH_MSG_TYPE_MAKE_SEND); + + return right; +} + +/* Call this when we should turn off caching so that unused memory object + ports get freed. */ +void +drop_pager_softrefs (struct node *np) +{ + if (MAY_CACHE) + { + mutex_lock (&pagernplock); + if (np->dn->fileinfo) + pager_change_attributes (np->dn->fileinfo->p, 0, + MEMORY_OBJECT_COPY_DELAY, 0); + if (np->dn->sininfo) + pager_change_attributes (np->dn->sininfo->p, 0, + MEMORY_OBJECT_COPY_DELAY, 0); + mutex_unlock (&pagernplock); + } +} + +/* Call this when we should turn on caching because it's no longer + important for unused memory object ports to get freed. */ +void +allow_pager_softrefs (struct node *np) +{ + if (MAY_CACHE) + { + mutex_lock (&pagernplock); + if (np->dn->fileinfo) + pager_change_attributes (np->dn->fileinfo->p, 1, + MEMORY_OBJECT_COPY_DELAY, 0); + if (np->dn->sininfo) + pager_change_attributes (np->dn->sininfo->p, 1, + MEMORY_OBJECT_COPY_DELAY, 0); + } +} + +/* Call this to find out the struct pager * corresponding to the + FILE_DATA pager of inode IP. This should be used *only* as a subsequent + argument to register_memory_fault_area, and will be deleted when + the kernel interface is fixed. */ +struct pager * +diskfs_get_filemap_pager_struct (struct node *np) +{ + struct pager *p; + mutex_unlock (&pagernplock); + p = np->dn->fileinfo->p; + mutex_unlock (&pagernplock); + return p; +} + +/* Add pager P to the appropriate list (filelist or sinlist) of pagers + of its type. */ +static void +enqueue_pager (struct user_pager_info *p) +{ + struct user_pager_info **listp; + + if (p->type == FILE_DATA) + listp = &filelist; + else if (p->type == SINDIR) + listp = &filelist; + else + return; + + spin_lock (&pagerlistlock); + + p->next = *listp; + p->prevp = listp; + *listp = p; + if (p->next) + p->next->prevp = &p->next; + + spin_unlock (&pagerlistlock); +} + +/* Remove pager P from the linked list it was placed on with enqueue_pager. */ +static void +dequeue_pager (struct user_pager_info *p) +{ + spin_lock (&pagerlistlock); + if (p->next) + p->next->prevp = p->prevp; + *p->prevp = p->next; + spin_unlock (&pagerlistlock); +} + +/* Call function FUNC (which takes one argument, a pager) on each pager, with + all file pagers being processed before sindir pagers, and then the dindir, + dinode, and cg pagers (in that order). Make the calls while holding + no locks. */ +static void +pager_traverse (void (*func)(struct user_pager_info *)) +{ + struct user_pager_info *p; + struct item {struct item *next; struct user_pager_info *p;} *list = 0; + struct item *i; + int looped; + + /* Putting SINDIR's on first means they will be removed last; after + the FILE_DATA pagers. */ + spin_lock (&pagerlistlock); + for (p = sinlist, looped = 0; + p || (!looped && (looped = 1, p = filelist)); + p = p->next) + { + i = alloca (sizeof (struct item)); + i->next = list; + list = i; + pager_reference (p->p); + i->p = p; + } + spin_unlock (&pagerlistlock); + + for (i = list; i; i = i->next) + { + (*func)(i->p); + pager_unreference (i->p->p); + } + + (*func)(dinpager); + (*func)(dinodepager); + (*func)(cgpager); +} + + +/* Shutdown all the pagers. */ +void +diskfs_shutdown_pager () +{ + void shutdown_one (struct user_pager_info *p) + { + pager_shutdown (p->p); + } + + write_all_disknodes (); + pager_traverse (shutdown_one); +} + +/* Sync all the pagers. */ +void +diskfs_sync_everything (int wait) +{ + void sync_one (struct user_pager_info *p) + { + pager_sync (p->p, wait); + } + + write_all_disknodes (); + pager_traverse (sync_one); +} + -- cgit v1.2.3 From 1872f7caee0355c300a27caa99f93609e492fa63 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 01:02:20 +0000 Subject: Formerly hyper.c.~8~ --- ufs/hyper.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index a1a19706..b39848ee 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -21,6 +21,8 @@ #include #include +static int oldformat = 0; + void get_hypermetadata (void) { @@ -48,7 +50,7 @@ get_hypermetadata (void) exit (1); } - if (sblock->fs_maxsymlinklen > MAXSYMLINKLEN) + if (sblock->fs_maxsymlinklen > (long)MAXSYMLINKLEN) { fprintf (stderr, "Max shortcut symlinklen %ld is too big (max is %ld)\n", sblock->fs_maxsymlinklen, MAXSYMLINKLEN); @@ -58,13 +60,32 @@ get_hypermetadata (void) /* If this is an old filesystem, then we have some more work to do; some crucial constants might not be set; we are therefore forced to set them here. */ + if (sblock->fs_npsect < sblock->fs_nsect) sblock->fs_npsect = sblock->fs_nsect; + if (sblock->fs_interleave < 1) sblock->fs_interleave = 1; + if (sblock->fs_postblformat == FS_42POSTBLFMT) sblock->fs_nrpos = 8; + if (sblock->fs_inodefmt < FS_44INODEFMT) + { + quad_t sizepb = sblock->fs_bsize; + int i; + + oldformat = 1; + sblock->fs_maxfilesize = sblock->fs_bsize * NDADDR - 1; + for (i = 0; i < NIADDR; i++) + { + sizepb *= NINDIR (sblock); + sblock->fs_maxfilesize += sizepb; + } + sblock->fs_qbmask = ~sblock->fs_bmask; + sblock->fs_qfmask = ~sblock->fs_fmask; + } + /* Find out if we support the 4.4 symlink/dirtype extension */ if (sblock->fs_maxsymlinklen > 0) direct_symlink_extension = 1; @@ -104,11 +125,20 @@ diskfs_set_hypermetadata (int wait, int clean) if (sblock_dirty) { - if (sblock->fs_postblformat == FS_42POSTBLFMT) + if (sblock->fs_postblformat == FS_42POSTBLFMT + || oldformat) { char sblockcopy[SBSIZE]; + struct fs *sbcopy = (struct fs *)sblockcopy; bcopy (sblock, sblockcopy, SBSIZE); - ((struct fs *)sblockcopy)->fs_nrpos = -1; + if (sblock->fs_postblformat == FS_42POSTBLFMT) + sbcopy->fs_nrpos = -1; + if (oldformat) + { + sbcopy->fs_maxfilesize = -1; + sbcopy->fs_qbmask = -1; + sbcopy->fs_qfmask = -1; + } (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); } else -- cgit v1.2.3 From d9fc33c37a55ac8d84023ac0dd0ddd9e10cd3a4c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 02:35:07 +0000 Subject: Formerly dir.c.~24~ --- ufs/dir.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index 7c793d84..f4bb4c63 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -722,6 +722,16 @@ count_dirents (struct node *dp, int nb, char *buf) return 0; } +/* XXX */ +struct olddirect +{ + u_long d_ino; + u_short d_reclen; + u_short d_namlen; + char d_name[MAXNAMLEN + 1]; +}; + + /* Implement the disikfs_get_directs callback as described in . */ error_t @@ -841,8 +851,22 @@ diskfs_get_directs (struct node *dp, if (entryp->d_ino) { +#ifdef notyet bcopy (bufp, datap, DIRSIZ (DIRECT_NAMLEN (entryp))); - ((struct direct *)bufp)->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); + if (!direct_symlink_extension) + { + /* Fix up fields into new format */ + ((struct direct *)datap)->d_namlen = DIRECT_NAMLEN (entryp); + ((struct direct *)datap)->d_type = DT_UNKNOWN; + } + ((struct direct *)datap)->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); +#else + struct olddirect *userd; + userd = (struct olddirect *)datap; + userd->d_ino = entryp->d_ino; + userd->d_reclen = userd->d_namlen = DIRECT_NAMLEN (entryp); + bcopy (entryp->d_name, userd->d_name, DIRECT_NAMLEN (entryp) + 1); +#endif i++; datap += DIRSIZ (DIRECT_NAMLEN (entryp)); } -- cgit v1.2.3 From c86d6cb87ec818c6bb051a21a111c53cdf4f9334 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 16:36:12 +0000 Subject: Formerly Maketools.~20~ --- =Maketools | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index 77243782..fbd0a416 100644 --- a/=Maketools +++ b/=Maketools @@ -13,7 +13,7 @@ mighost := ernst.gnu.ai.mit.edu # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). -CCTARGET=i386-mach +CCTARGET=i386-gnu CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.5.8) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 @@ -33,7 +33,7 @@ MIGCOM=rsh $(mighost) cd `pwd` \; umask `umask` \; /usr/local/lib/migcom else MIGCOM=/usr/local/lib/migcom endif -CPP=$(ccdir)/cpp +CPP=$(CC) -E -x c export CPP # I put a /usr/local/bin/mig on the hp300s that will run $CPP locally and # rsh to ernst to run migcom. --roland -- cgit v1.2.3 From 9401289a7a00f2ae71974466155df89b77ac3b27 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 16:48:29 +0000 Subject: Formerly Makefile.~27~ --- ufs/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 14a1260c..79b8f45e 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -38,10 +38,9 @@ LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) all: ufs -LDFLAGS=--no-keep-memory - +# Don't use $^ in this rule; it will omit the duplicates in $(LIBS). ufs: $(OBJS) $(LIBS) - $(link) + $(CC) -Xlinker --no-keep-memory $(CFLAGS) -o $@ $(OBJS) $(LIBS) exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs rsh $(mighost) -n cd `pwd` \; \ -- cgit v1.2.3 From 02288d5d114ab3557e2a415771b35e670ac35912 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 22:08:06 +0000 Subject: Formerly Makefile.~28~ --- ufs/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 79b8f45e..5beca669 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -40,7 +40,8 @@ all: ufs # Don't use $^ in this rule; it will omit the duplicates in $(LIBS). ufs: $(OBJS) $(LIBS) - $(CC) -Xlinker --no-keep-memory $(CFLAGS) -o $@ $(OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) +# -Xlinker --no-keep-memory exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs rsh $(mighost) -n cd `pwd` \; \ -- cgit v1.2.3 From 1b08bf90da78eb0909b5562347e1d3d921dee78b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 19 Jul 1994 23:34:36 +0000 Subject: Formerly main.c.~15~ --- ufs/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index dc58a20e..19963a9a 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -25,7 +25,6 @@ char *ufs_version = "0.0 pre-alpha"; -mach_port_t diskfs_dotdot_file; static char **save_argv; /* Parse the arguments for ufs when started as a translator. */ @@ -71,8 +70,7 @@ trans_parse_args (int argc, char **arg) mach_port_insert_right (mach_task_self (), ufs_control_port, ufs_control_port, MACH_MSG_TYPE_MAKE_SEND); - fsys_startup (bootstrap, ufs_control_port, &ufs_realnode, - &diskfs_dotdot_file); + fsys_startup (bootstrap, ufs_control_port, &ufs_realnode); mach_port_deallocate (mach_task_self (), ufs_control_port); #else task_terminate (mach_task_self ()); -- cgit v1.2.3 From c8282f9bd0f423e9e51d6fffc1cb4d75fa098f85 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 20 Jul 1994 01:53:07 +0000 Subject: Formerly ufs.h.~19~ --- ufs/ufs.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 2ffa835d..a9766422 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -24,15 +24,6 @@ #include #include -/* XXX */ -typedef unsigned long long u_quad_t; -typedef long long quad_t; -struct timespec -{ - long ts_sec; - long ts_nsec; -}; - /* 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 -- cgit v1.2.3 From 2b474e2589a83801bbac0c8d438a82fdb29ce3ab Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Jul 1994 20:01:28 +0000 Subject: Formerly main.c.~16~ --- ufs/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 19963a9a..1ae0d749 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -127,7 +127,6 @@ main (int argc, char **argv) else { devname = diskfs_parse_bootargs (argc, argv); - diskfs_dotdot_file = MACH_PORT_NULL; compat_mode = COMPAT_GNU; } -- cgit v1.2.3 From 523abd876fc15e28e0d47e34c91494357d8ccc41 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Jul 1994 20:26:50 +0000 Subject: Formerly Makefile.~11~ --- mkbootfs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index 95fcd542..c140bb00 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -23,7 +23,7 @@ SRCS = mkbootfs.c all: mkbootfs mkbootfs: mkbootfs.c - rsh -n $(mighost) cd `pwd` \; $(MIGHOSTCC) mkbootfs.c -o mkbootfs + rsh $(mighost) -n cd `pwd` \; gcc mkbootfs.c -o mkbootfs clean: rm -f mkbootfs *.o -- cgit v1.2.3 From ff4c54baf383829094aa518ad5039cdfc0c269f6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Jul 1994 21:25:23 +0000 Subject: Formerly Makefile.~29~ --- ufs/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 5beca669..e2e4fdcf 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -33,6 +33,7 @@ OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o #LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ $(libfshelp) $(libdiskfs) $(libthreads) $(libports) +#LIBS = $(LIBPARTS) LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) @@ -40,7 +41,7 @@ all: ufs # Don't use $^ in this rule; it will omit the duplicates in $(LIBS). ufs: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) # -Xlinker --no-keep-memory exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs -- cgit v1.2.3 From a5992f37bdb07c514d6d58c8ec50af187f2c1c34 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 22 Jul 1994 14:37:58 +0000 Subject: entered into RCS --- mkbootfs/Makefile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile index c140bb00..df5af560 100644 --- a/mkbootfs/Makefile +++ b/mkbootfs/Makefile @@ -16,20 +16,17 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dir := mkbootfs -include ../Makeconf +makemode := misc -DIST_FILES = mkbootfs.c Makefile ChangeLog SRCS = mkbootfs.c +include ../Makeconf + all: mkbootfs + mkbootfs: mkbootfs.c rsh $(mighost) -n cd `pwd` \; gcc mkbootfs.c -o mkbootfs clean: rm -f mkbootfs *.o -# Relink should do nothing here because this program does not use -# the Hurd libraries. -relink: - -install: -- cgit v1.2.3 From b11ffcd8476b5179f59b08383b06188856966e7b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 22 Jul 1994 19:19:07 +0000 Subject: Formerly Makefile.~30~ --- ufs/Makefile | 52 ++++++++++------------------------------------------ 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index e2e4fdcf..7b353160 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -16,48 +16,27 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dir := ufs - -include ../Makeconf - -VPATH=.:../machine +makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c - -TAGSLIBS=libdiskfs libports libpager libioserver libfshelp libthreads - -DIST_FILES=$(SRCS) ufs.h Makefile fs.h dinode.h dir.h ChangeLog - OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o +LCLHDRS = ufs.h fs.h dinode.h dir.h +REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ + ../hurd/ioserver.h ../hurd/fshelp.h +HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ + libfshelp libdiskfs libthreads libports +#HURDLIBS = libdiskfs libports libpager libioserver libfshelp +target = ufs -#LIBS = $(hurdinst)/lib/libdiskfscombined.a $(libthreads) -LIBS = $(libdiskfs) $(libports) $(libdiskfs) $(libpager) $(libioserver) \ - $(libfshelp) $(libdiskfs) $(libthreads) $(libports) -#LIBS = $(LIBPARTS) - -LIBPARTS = $(libdiskfs) $(libports) $(libpager) $(libioserver) $(libfshelp) - -all: ufs - -# Don't use $^ in this rule; it will omit the duplicates in $(LIBS). -ufs: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -# -Xlinker --no-keep-memory +include ../Makeconf exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs rsh $(mighost) -n cd `pwd` \; \ ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o -install: - -clean: - rm -f *.o ufs -relink: - rm -f ufs - $(OBJS): ufs.h -$(OBJS): $(addprefix $(includedir)/hurd/,diskfs.h pager.h ioserver.h \ - fshelp.h ports.h) +$(OBJS): $(REMHDRS) alloc.o: fs.h dinode.h consts.o: dinode.h dir.o: dir.h @@ -69,16 +48,5 @@ sizes.o: fs.h dinode.h subr.o: fs.h tables.o: fs.h -$(hurdinst)/lib/libdiskfscombined.a: $(LIBPARTS) - -mkdir foo - cd foo; $(AR) x $(libdiskfs) - cd foo; $(AR) x $(libports) - cd foo; $(AR) x $(libpager) - cd foo; $(AR) x $(libioserver) - cd foo; $(AR) x $(libfshelp) - cd foo; $(AR) cr $(hurdinst)/lib/libdiskfscombined.a * - rm -rf foo - $(RANLIB) $(hurdinst)/lib/libdiskfscombined.a - $(foreach dir,mkbootfs exec,../$(dir)/%): FORCE $(MAKE) -C $(@D) $(@F) -- cgit v1.2.3 From e4e7540de195bc58311434179d225bb324db4fe0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 23 Jul 1994 07:03:32 +0000 Subject: Formerly Makefile.~31~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 7b353160..9e5fe941 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,7 +26,7 @@ REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ libfshelp libdiskfs libthreads libports -#HURDLIBS = libdiskfs libports libpager libioserver libfshelp +#HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads target = ufs include ../Makeconf -- cgit v1.2.3 From 07b6f15775422f52802b6653aee54d8474a68a3e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 1 Aug 1994 01:15:05 +0000 Subject: Formerly Maketools.~21~ --- =Maketools | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/=Maketools b/=Maketools index fbd0a416..9e01bfd1 100644 --- a/=Maketools +++ b/=Maketools @@ -1,5 +1,5 @@ # This is the directory holding ar and ranlib -tooldir := /usr/local/i386-mach/bin +tooldir := /usr/local/i386-gnu/bin # This is a machine on which to run MiG. (MiG writes CPU dependent code, # so MiG has to be run on a machine that's the same as the one that will @@ -14,12 +14,10 @@ mighost := ernst.gnu.ai.mit.edu # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). CCTARGET=i386-gnu -CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.5.8) +CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.0) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 -MIGHOSTCCVERSION=$(firstword $(CCVERSION-$(mighost)) $(CCVERSION)) -MIGHOSTCCTYPE= -b $(CCTARGET) -V $(MIGHOSTCCVERSION) ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) @@ -27,7 +25,6 @@ ifndef HOST_CC export HOST_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -MIGHOSTCC= gcc $(MIGHOSTCCTYPE) -O2 ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=rsh $(mighost) cd `pwd` \; umask `umask` \; /usr/local/lib/migcom else @@ -42,8 +39,7 @@ AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(ccdir)/ld -L$(ccdir) -# objcopy zeroes the exec header, so we can't do this. -#INSTALL_BIN=$(tooldir)/objcopy -S -INSTALL_BIN=cp +INSTALL_BIN=$(tooldir)/objcopy -S +#INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From cddf66de9c7a9da7596195984b813eaea0e083d0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 1 Aug 1994 23:41:05 +0000 Subject: Formerly Maketools.~22~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 9e01bfd1..9f09c599 100644 --- a/=Maketools +++ b/=Maketools @@ -24,7 +24,7 @@ ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) ifndef HOST_CC export HOST_CC := $(CC) endif -CC=gcc $(CCTYPE) -O2 +CC=gcc $(CCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=rsh $(mighost) cd `pwd` \; umask `umask` \; /usr/local/lib/migcom else -- cgit v1.2.3 From 5a92483b8ff9718ef86ada672c7aa244641177f6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 5 Aug 1994 19:54:21 +0000 Subject: Formerly dir.c.~25~ --- ufs/dir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index f4bb4c63..a3b0b7f6 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -104,6 +104,9 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, type &= ~SPEC_DOTDOT; namelen = strlen (name); + + if (namelen > MAXNAMLEN) + return ENAMETOOLONG; if (!S_ISDIR (dp->dn_stat.st_mode)) return ENOTDIR; @@ -506,6 +509,8 @@ diskfs_direnter(struct node *dp, case EXTEND: /* Extend the file. */ + assert (needed <= DIRBLKSIZ); + while (dp->dn_stat.st_size + DIRBLKSIZ > dp->allocsize) if (err = diskfs_grow (dp, dp->dn_stat.st_size + DIRBLKSIZ, cred)) { @@ -864,7 +869,8 @@ diskfs_get_directs (struct node *dp, struct olddirect *userd; userd = (struct olddirect *)datap; userd->d_ino = entryp->d_ino; - userd->d_reclen = userd->d_namlen = DIRECT_NAMLEN (entryp); + userd->d_namlen = DIRECT_NAMLEN (entryp); + userd->d_reclen = DIRSIZ (userd->d_namlen); bcopy (entryp->d_name, userd->d_name, DIRECT_NAMLEN (entryp) + 1); #endif i++; -- cgit v1.2.3 From ab0103c6888946ee1a98df2c4464fe9d28188412 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 10 Aug 1994 17:41:51 +0000 Subject: Formerly Maketools.~23~ --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 9f09c599..ffd724cb 100644 --- a/=Maketools +++ b/=Maketools @@ -37,7 +37,7 @@ export CPP MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib -LD=$(ccdir)/ld -L$(ccdir) +LD=$(tooldir)/ld -L$(ccdir) INSTALL_BIN=$(tooldir)/objcopy -S #INSTALL_BIN=cp -- cgit v1.2.3 From c1343045a51d11debddf7b820d723b6c570cff4f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Aug 1994 02:19:12 +0000 Subject: entered into RCS --- =Maketools | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/=Maketools b/=Maketools index ffd724cb..4679b119 100644 --- a/=Maketools +++ b/=Maketools @@ -21,8 +21,8 @@ CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) -ifndef HOST_CC -export HOST_CC := $(CC) +ifndef BUILD_CC +export BUILD_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) @@ -39,7 +39,7 @@ AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) -INSTALL_BIN=$(tooldir)/objcopy -S +INSTALL_BIN=i386-gnu-objcopy -S #INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From 080f2c714857fd99f198924532af339d6dc770c4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 16 Aug 1994 18:04:35 +0000 Subject: Formerly Makefile.~33~ --- ufs/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/Makefile b/ufs/Makefile index 9e5fe941..2cb7e84e 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -27,6 +27,7 @@ REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ libfshelp libdiskfs libthreads libports #HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads +LDFLAGS = -Wl,--no-keep-memory target = ufs include ../Makeconf -- cgit v1.2.3 From 5c1e6655a532185b661a90fd6380b9334575f77e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Aug 1994 16:40:57 +0000 Subject: Formerly alloc.c.~14~ --- ufs/alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/alloc.c b/ufs/alloc.c index 8afa6aa7..19389afe 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -564,6 +564,8 @@ diskfs_alloc_node (struct node *dir, nextgennumber = sex; np->dn_stat.st_gen = nextgennumber; spin_unlock (&gennumberlock); + + *npp = np; return (0); noinodes: printf ("out of inodes"); -- cgit v1.2.3 From 538566e5a53f2738660bc49bc97b6215831b054c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Aug 1994 16:41:42 +0000 Subject: Formerly Makefile.~34~ --- ufs/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 2cb7e84e..17bcf3f4 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -24,9 +24,9 @@ OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h -HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ - libfshelp libdiskfs libthreads libports -#HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads +#HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ +# libfshelp libdiskfs libthreads libports +HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads LDFLAGS = -Wl,--no-keep-memory target = ufs -- cgit v1.2.3 From f7fa9f7edc626c0c42e63f1143cc6ff1d25f80c7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 19:29:25 +0000 Subject: entered into RCS --- bsdfsck/preen.c | 355 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 355 insertions(+) create mode 100644 bsdfsck/preen.c diff --git a/bsdfsck/preen.c b/bsdfsck/preen.c new file mode 100644 index 00000000..7893a5e1 --- /dev/null +++ b/bsdfsck/preen.c @@ -0,0 +1,355 @@ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)preen.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: preen.c,v 1.1 1994/08/23 19:29:25 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include + +char *rawname(), *unrawname(), *blockcheck(); + +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 */ +} *badlist, **badnext = &badlist; + +struct disk { + char *name; /* disk base name */ + struct disk *next; /* forward link for list of disks */ + struct part *part; /* head of list of partitions on disk */ + int pid; /* If != 0, pid of proc working on */ +} *disks; + +int nrun, ndisks; +char hotroot; + +checkfstab(preen, maxrun, docheck, chkit) + int preen, maxrun; + int (*docheck)(), (*chkit)(); +{ + register struct fstab *fsp; + register struct disk *dk, *nextdisk; + register struct part *pt; + int ret, pid, retcode, passno, sumstatus, status; + long auxdata; + char *name; + + sumstatus = 0; + for (passno = 1; passno <= 2; passno++) { + if (setfsent() == 0) { + fprintf(stderr, "Can't open checklist file: %s\n", + _PATH_FSTAB); + return (8); + } + while ((fsp = getfsent()) != 0) { + if ((auxdata = (*docheck)(fsp)) == 0) + continue; + if (preen == 0 || passno == 1 && fsp->fs_passno == 1) { + if (name = blockcheck(fsp->fs_spec)) { + if (sumstatus = (*chkit)(name, + fsp->fs_file, auxdata, 0)) + return (sumstatus); + } else if (preen) + return (8); + } else if (passno == 2 && fsp->fs_passno > 1) { + if ((name = blockcheck(fsp->fs_spec)) == NULL) { + fprintf(stderr, "BAD DISK NAME %s\n", + fsp->fs_spec); + sumstatus |= 8; + continue; + } + addpart(name, fsp->fs_file, auxdata); + } + } + if (preen == 0) + return (0); + } + if (preen) { + if (maxrun == 0) + maxrun = ndisks; + if (maxrun > ndisks) + maxrun = ndisks; + nextdisk = disks; + for (passno = 0; passno < maxrun; ++passno) { + while (ret = startdisk(nextdisk, chkit) && nrun > 0) + sleep(10); + if (ret) + return (ret); + nextdisk = nextdisk->next; + } + while ((pid = wait(&status)) != -1) { + for (dk = disks; dk; dk = dk->next) + if (dk->pid == pid) + break; + if (dk == 0) { + printf("Unknown pid %d\n", pid); + continue; + } + if (WIFEXITED(status)) + retcode = WEXITSTATUS(status); + else + retcode = 0; + if (WIFSIGNALED(status)) { + printf("%s (%s): EXITED WITH SIGNAL %d\n", + dk->part->name, dk->part->fsname, + WTERMSIG(status)); + retcode = 8; + } + if (retcode != 0) { + sumstatus |= retcode; + *badnext = dk->part; + badnext = &dk->part->next; + dk->part = dk->part->next; + *badnext = NULL; + } else + dk->part = dk->part->next; + dk->pid = 0; + nrun--; + if (dk->part == NULL) + ndisks--; + + if (nextdisk == NULL) { + if (dk->part) { + while (ret = startdisk(dk, chkit) && + nrun > 0) + sleep(10); + if (ret) + return (ret); + } + } else if (nrun < maxrun && nrun < ndisks) { + for ( ;; ) { + if ((nextdisk = nextdisk->next) == NULL) + nextdisk = disks; + if (nextdisk->part != NULL && + nextdisk->pid == 0) + break; + } + while (ret = startdisk(nextdisk, chkit) && + nrun > 0) + sleep(10); + if (ret) + return (ret); + } + } + } + if (sumstatus) { + if (badlist == 0) + return (sumstatus); + fprintf(stderr, "THE FOLLOWING FILE SYSTEM%s HAD AN %s\n\t", + badlist->next ? "S" : "", "UNEXPECTED INCONSISTENCY:"); + for (pt = badlist; pt; pt = pt->next) + fprintf(stderr, "%s (%s)%s", pt->name, pt->fsname, + pt->next ? ", " : "\n"); + return (sumstatus); + } + (void)endfsent(); + return (0); +} + +struct disk * +finddisk(name) + char *name; +{ + register struct disk *dk, **dkp; + register char *p; + size_t len; + + for (p = name + strlen(name) - 1; p >= name; --p) + if (isdigit(*p)) { + len = p - name + 1; + break; + } + if (p < name) + len = strlen(name); + + for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) { + if (strncmp(dk->name, name, len) == 0 && + dk->name[len] == 0) + return (dk); + } + if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) { + fprintf(stderr, "out of memory"); + exit (8); + } + dk = *dkp; + if ((dk->name = malloc(len + 1)) == NULL) { + fprintf(stderr, "out of memory"); + exit (8); + } + (void)strncpy(dk->name, name, len); + dk->name[len] = '\0'; + dk->part = NULL; + dk->next = NULL; + dk->pid = 0; + ndisks++; + return (dk); +} + +addpart(name, fsname, auxdata) + char *name, *fsname; + long auxdata; +{ + struct disk *dk = finddisk(name); + register struct part *pt, **ppt = &dk->part; + + for (pt = dk->part; pt; ppt = &pt->next, pt = pt->next) + if (strcmp(pt->name, name) == 0) { + printf("%s in fstab more than once!\n", name); + return; + } + if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) { + fprintf(stderr, "out of memory"); + exit (8); + } + pt = *ppt; + if ((pt->name = malloc(strlen(name) + 1)) == NULL) { + fprintf(stderr, "out of memory"); + exit (8); + } + (void)strcpy(pt->name, name); + if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) { + fprintf(stderr, "out of memory"); + exit (8); + } + (void)strcpy(pt->fsname, fsname); + pt->next = NULL; + pt->auxdata = auxdata; +} + +startdisk(dk, checkit) + register struct disk *dk; + int (*checkit)(); +{ + register struct part *pt = dk->part; + + dk->pid = fork(); + if (dk->pid < 0) { + perror("fork"); + return (8); + } + if (dk->pid == 0) + exit((*checkit)(pt->name, pt->fsname, pt->auxdata, 1)); + nrun++; + return (0); +} + +char * +blockcheck(name) + char *name; +{ + struct stat stslash, stblock, stchar; + char *raw; + int retried = 0; + + hotroot = 0; + if (stat("/", &stslash) < 0) { + perror("/"); + printf("Can't stat root\n"); + return (0); + } +retry: + if (stat(name, &stblock) < 0) { + perror(name); + printf("Can't stat %s\n", name); + return (0); + } + if ((stblock.st_mode & S_IFMT) == S_IFBLK) { + if (stslash.st_dev == stblock.st_rdev) + hotroot++; + raw = rawname(name); + if (stat(raw, &stchar) < 0) { + perror(raw); + printf("Can't stat %s\n", raw); + return (name); + } + if ((stchar.st_mode & S_IFMT) == S_IFCHR) { + return (raw); + } else { + printf("%s is not a character device\n", raw); + return (name); + } + } else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) { + name = unrawname(name); + retried++; + goto retry; + } + printf("Can't make sense out of name %s\n", name); + return (0); +} + +char * +unrawname(name) + char *name; +{ + char *dp; + struct stat stb; + + if ((dp = rindex(name, '/')) == 0) + return (name); + if (stat(name, &stb) < 0) + return (name); + if ((stb.st_mode & S_IFMT) != S_IFCHR) + return (name); + if (dp[1] != 'r') + return (name); + (void)strcpy(&dp[1], &dp[2]); + return (name); +} + +char * +rawname(name) + char *name; +{ + static char rawbuf[32]; + char *dp; + + if ((dp = rindex(name, '/')) == 0) + return (0); + *dp = 0; + (void)strcpy(rawbuf, name); + *dp = '/'; + (void)strcat(rawbuf, "/r"); + (void)strcat(rawbuf, &dp[1]); + return (rawbuf); +} -- cgit v1.2.3 From 212103a299c805c1568811847ef52ad1636d81bd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 19:30:43 +0000 Subject: Initial revision --- bsdfsck/Makefile | 14 + bsdfsck/dir.c | 689 +++++++++++++++++++++++++++++ bsdfsck/inode.c | 549 +++++++++++++++++++++++ bsdfsck/main.c | 319 +++++++++++++ bsdfsck/pass1.c | 324 ++++++++++++++ bsdfsck/pass1b.c | 100 +++++ bsdfsck/pass2.c | 431 ++++++++++++++++++ bsdfsck/pass3.c | 72 +++ bsdfsck/pass4.c | 134 ++++++ bsdfsck/pass5.c | 320 ++++++++++++++ bsdfsck/setup.c | 467 +++++++++++++++++++ bsdfsck/utilities.c | 567 ++++++++++++++++++++++++ ufs-utils/Makefile | 15 + ufs-utils/mkfs.c | 1229 +++++++++++++++++++++++++++++++++++++++++++++++++++ ufs-utils/newfs.c | 679 ++++++++++++++++++++++++++++ 15 files changed, 5909 insertions(+) create mode 100644 bsdfsck/Makefile create mode 100644 bsdfsck/dir.c create mode 100644 bsdfsck/inode.c create mode 100644 bsdfsck/main.c create mode 100644 bsdfsck/pass1.c create mode 100644 bsdfsck/pass1b.c create mode 100644 bsdfsck/pass2.c create mode 100644 bsdfsck/pass3.c create mode 100644 bsdfsck/pass4.c create mode 100644 bsdfsck/pass5.c create mode 100644 bsdfsck/setup.c create mode 100644 bsdfsck/utilities.c create mode 100644 ufs-utils/Makefile create mode 100644 ufs-utils/mkfs.c create mode 100644 ufs-utils/newfs.c diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile new file mode 100644 index 00000000..b1e25a2f --- /dev/null +++ b/bsdfsck/Makefile @@ -0,0 +1,14 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/5/93 +# $Id: Makefile,v 1.1 1994/08/23 19:29:26 mib Exp $ + +PROG= fsck +MAN8= fsck.0 +SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ + pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c +.PATH: ${.CURDIR}/../../sys/ufs/ffs + +.if make(install) +SUBDIR+= SMM.doc +.endif + +.include diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c new file mode 100644 index 00000000..e086439e --- /dev/null +++ b/bsdfsck/dir.c @@ -0,0 +1,689 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: dir.c,v 1.1 1994/08/23 19:29:21 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +char *lfname = "lost+found"; +int lfmode = 01777; +struct dirtemplate emptydir = { 0, DIRBLKSIZ }; +struct dirtemplate dirhead = { + 0, 12, DT_DIR, 1, ".", + 0, DIRBLKSIZ - 12, DT_DIR, 2, ".." +}; +struct odirtemplate odirhead = { + 0, 12, 1, ".", + 0, DIRBLKSIZ - 12, 2, ".." +}; + +struct direct *fsck_readdir(); +struct bufarea *getdirblk(); + +/* + * Propagate connected state through the tree. + */ +propagate() +{ + register struct inoinfo **inpp, *inp; + struct inoinfo **inpend; + long change; + + inpend = &inpsort[inplast]; + do { + change = 0; + for (inpp = inpsort; inpp < inpend; inpp++) { + inp = *inpp; + if (inp->i_parent == 0) + continue; + if (statemap[inp->i_parent] == DFOUND && + statemap[inp->i_number] == DSTATE) { + statemap[inp->i_number] = DFOUND; + change++; + } + } + } while (change > 0); +} + +/* + * Scan each entry in a directory block. + */ +dirscan(idesc) + register struct inodesc *idesc; +{ + register struct direct *dp; + register struct bufarea *bp; + int dsize, n; + long blksiz; + char dbuf[DIRBLKSIZ]; + + if (idesc->id_type != DATA) + errexit("wrong type to dirscan %d\n", idesc->id_type); + if (idesc->id_entryno == 0 && + (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0) + idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ); + blksiz = idesc->id_numfrags * sblock.fs_fsize; + if (chkrange(idesc->id_blkno, idesc->id_numfrags)) { + idesc->id_filesize -= blksiz; + return (SKIP); + } + idesc->id_loc = 0; + for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) { + dsize = dp->d_reclen; + bcopy((char *)dp, dbuf, (size_t)dsize); +# if (BYTE_ORDER == LITTLE_ENDIAN) + if (!newinofmt) { + struct direct *tdp = (struct direct *)dbuf; + u_char tmp; + + tmp = tdp->d_namlen; + tdp->d_namlen = tdp->d_type; + tdp->d_type = tmp; + } +# endif + idesc->id_dirp = (struct direct *)dbuf; + if ((n = (*idesc->id_func)(idesc)) & ALTERED) { +# if (BYTE_ORDER == LITTLE_ENDIAN) + if (!newinofmt && !doinglevel2) { + struct direct *tdp; + u_char tmp; + + tdp = (struct direct *)dbuf; + tmp = tdp->d_namlen; + tdp->d_namlen = tdp->d_type; + tdp->d_type = tmp; + } +# endif + bp = getdirblk(idesc->id_blkno, blksiz); + bcopy(dbuf, bp->b_un.b_buf + idesc->id_loc - dsize, + (size_t)dsize); + dirty(bp); + sbdirty(); + } + if (n & STOP) + return (n); + } + return (idesc->id_filesize > 0 ? KEEPON : STOP); +} + +/* + * get next entry in a directory. + */ +struct direct * +fsck_readdir(idesc) + register struct inodesc *idesc; +{ + register struct direct *dp, *ndp; + register struct bufarea *bp; + long size, blksiz, fix, dploc; + + blksiz = idesc->id_numfrags * sblock.fs_fsize; + bp = getdirblk(idesc->id_blkno, blksiz); + if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 && + idesc->id_loc < blksiz) { + dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc); + if (dircheck(idesc, dp)) + goto dpok; + fix = dofix(idesc, "DIRECTORY CORRUPTED"); + bp = getdirblk(idesc->id_blkno, blksiz); + dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc); + dp->d_reclen = DIRBLKSIZ; + dp->d_ino = 0; + dp->d_type = 0; + dp->d_namlen = 0; + dp->d_name[0] = '\0'; + if (fix) + dirty(bp); + idesc->id_loc += DIRBLKSIZ; + idesc->id_filesize -= DIRBLKSIZ; + return (dp); + } +dpok: + if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz) + return NULL; + dploc = idesc->id_loc; + dp = (struct direct *)(bp->b_un.b_buf + dploc); + idesc->id_loc += dp->d_reclen; + idesc->id_filesize -= dp->d_reclen; + if ((idesc->id_loc % DIRBLKSIZ) == 0) + return (dp); + ndp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc); + if (idesc->id_loc < blksiz && idesc->id_filesize > 0 && + dircheck(idesc, ndp) == 0) { + size = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); + idesc->id_loc += size; + idesc->id_filesize -= size; + fix = dofix(idesc, "DIRECTORY CORRUPTED"); + bp = getdirblk(idesc->id_blkno, blksiz); + dp = (struct direct *)(bp->b_un.b_buf + dploc); + dp->d_reclen += size; + if (fix) + dirty(bp); + } + return (dp); +} + +/* + * Verify that a directory entry is valid. + * This is a superset of the checks made in the kernel. + */ +dircheck(idesc, dp) + struct inodesc *idesc; + register struct direct *dp; +{ + register int size; + register char *cp; + u_char namlen, type; + int spaceleft; + + size = DIRSIZ(!newinofmt, dp); + spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); +# if (BYTE_ORDER == LITTLE_ENDIAN) + if (!newinofmt) { + type = dp->d_namlen; + namlen = dp->d_type; + } else { + namlen = dp->d_namlen; + type = dp->d_type; + } +# else + namlen = dp->d_namlen; + type = dp->d_type; +# endif + if (dp->d_ino < maxino && + dp->d_reclen != 0 && + dp->d_reclen <= spaceleft && + (dp->d_reclen & 0x3) == 0 && + dp->d_reclen >= size && + idesc->id_filesize >= size && + namlen <= MAXNAMLEN && + type <= 15) { + if (dp->d_ino == 0) + return (1); + for (cp = dp->d_name, size = 0; size < namlen; size++) + if (*cp == 0 || (*cp++ == '/')) + return (0); + if (*cp == 0) + return (1); + } + return (0); +} + +direrror(ino, errmesg) + ino_t ino; + char *errmesg; +{ + + fileerror(ino, ino, errmesg); +} + +fileerror(cwd, ino, errmesg) + ino_t cwd, ino; + char *errmesg; +{ + register struct dinode *dp; + char pathbuf[MAXPATHLEN + 1]; + + pwarn("%s ", errmesg); + pinode(ino); + printf("\n"); + getpathname(pathbuf, cwd, ino); + if (ino < ROOTINO || ino > maxino) { + pfatal("NAME=%s\n", pathbuf); + return; + } + dp = ginode(ino); + if (ftypeok(dp)) + pfatal("%s=%s\n", + (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf); + else + pfatal("NAME=%s\n", pathbuf); +} + +adjust(idesc, lcnt) + register struct inodesc *idesc; + short lcnt; +{ + register struct dinode *dp; + + dp = ginode(idesc->id_number); + if (dp->di_nlink == lcnt) { + if (linkup(idesc->id_number, (ino_t)0) == 0) + clri(idesc, "UNREF", 0); + } else { + pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname : + ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE")); + pinode(idesc->id_number); + printf(" COUNT %d SHOULD BE %d", + dp->di_nlink, dp->di_nlink - lcnt); + if (preen) { + if (lcnt < 0) { + printf("\n"); + pfatal("LINK COUNT INCREASING"); + } + printf(" (ADJUSTED)\n"); + } + if (preen || reply("ADJUST") == 1) { + dp->di_nlink -= lcnt; + inodirty(); + } + } +} + +mkentry(idesc) + struct inodesc *idesc; +{ + register struct direct *dirp = idesc->id_dirp; + struct direct newent; + int newlen, oldlen; + + newent.d_namlen = strlen(idesc->id_name); + newlen = DIRSIZ(0, &newent); + if (dirp->d_ino != 0) + oldlen = DIRSIZ(0, dirp); + else + oldlen = 0; + if (dirp->d_reclen - oldlen < newlen) + return (KEEPON); + newent.d_reclen = dirp->d_reclen - oldlen; + dirp->d_reclen = oldlen; + dirp = (struct direct *)(((char *)dirp) + oldlen); + dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ + if (newinofmt) { + dirp->d_type = typemap[idesc->id_parent]; + dirp->d_namlen = newent.d_namlen; + } else { +# if (BYTE_ORDER == LITTLE_ENDIAN) + dirp->d_type = newent.d_namlen; + dirp->d_namlen = 0; +# else + dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; +# endif + } + dirp->d_reclen = newent.d_reclen; + bcopy(idesc->id_name, dirp->d_name, (size_t)newent.d_namlen + 1); + return (ALTERED|STOP); +} + +chgino(idesc) + struct inodesc *idesc; +{ + register struct direct *dirp = idesc->id_dirp; + + if (bcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1)) + return (KEEPON); + dirp->d_ino = idesc->id_parent; + if (newinofmt) + dirp->d_type = typemap[idesc->id_parent]; + else + dirp->d_type = 0; + return (ALTERED|STOP); +} + +linkup(orphan, parentdir) + ino_t orphan; + ino_t parentdir; +{ + register struct dinode *dp; + int lostdir; + ino_t oldlfdir; + struct inodesc idesc; + char tempname[BUFSIZ]; + extern int pass4check(); + + bzero((char *)&idesc, sizeof(struct inodesc)); + dp = ginode(orphan); + lostdir = (dp->di_mode & IFMT) == IFDIR; + pwarn("UNREF %s ", lostdir ? "DIR" : "FILE"); + pinode(orphan); + if (preen && dp->di_size == 0) + return (0); + if (preen) + printf(" (RECONNECTED)\n"); + else + if (reply("RECONNECT") == 0) + return (0); + if (lfdir == 0) { + dp = ginode(ROOTINO); + idesc.id_name = lfname; + idesc.id_type = DATA; + idesc.id_func = findino; + idesc.id_number = ROOTINO; + if ((ckinode(dp, &idesc) & FOUND) != 0) { + lfdir = idesc.id_parent; + } else { + pwarn("NO lost+found DIRECTORY"); + if (preen || reply("CREATE")) { + lfdir = allocdir(ROOTINO, (ino_t)0, lfmode); + if (lfdir != 0) { + if (makeentry(ROOTINO, lfdir, lfname) != 0) { + if (preen) + printf(" (CREATED)\n"); + } else { + freedir(lfdir, ROOTINO); + lfdir = 0; + if (preen) + printf("\n"); + } + } + } + } + if (lfdir == 0) { + pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY"); + printf("\n\n"); + return (0); + } + } + dp = ginode(lfdir); + if ((dp->di_mode & IFMT) != IFDIR) { + pfatal("lost+found IS NOT A DIRECTORY"); + if (reply("REALLOCATE") == 0) + return (0); + oldlfdir = lfdir; + if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) { + pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n"); + return (0); + } + if ((changeino(ROOTINO, lfname, lfdir) & ALTERED) == 0) { + pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n"); + return (0); + } + inodirty(); + idesc.id_type = ADDR; + idesc.id_func = pass4check; + idesc.id_number = oldlfdir; + adjust(&idesc, lncntp[oldlfdir] + 1); + lncntp[oldlfdir] = 0; + dp = ginode(lfdir); + } + if (statemap[lfdir] != DFOUND) { + pfatal("SORRY. NO lost+found DIRECTORY\n\n"); + return (0); + } + (void)lftempname(tempname, orphan); + if (makeentry(lfdir, orphan, tempname) == 0) { + pfatal("SORRY. NO SPACE IN lost+found DIRECTORY"); + printf("\n\n"); + return (0); + } + lncntp[orphan]--; + if (lostdir) { + if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 && + parentdir != (ino_t)-1) + (void)makeentry(orphan, lfdir, ".."); + dp = ginode(lfdir); + dp->di_nlink++; + inodirty(); + lncntp[lfdir]++; + pwarn("DIR I=%lu CONNECTED. ", orphan); + if (parentdir != (ino_t)-1) + printf("PARENT WAS I=%lu\n", parentdir); + if (preen == 0) + printf("\n"); + } + return (1); +} + +/* + * fix an entry in a directory. + */ +changeino(dir, name, newnum) + ino_t dir; + char *name; + ino_t newnum; +{ + struct inodesc idesc; + + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = DATA; + idesc.id_func = chgino; + idesc.id_number = dir; + idesc.id_fix = DONTKNOW; + idesc.id_name = name; + idesc.id_parent = newnum; /* new value for name */ + return (ckinode(ginode(dir), &idesc)); +} + +/* + * make an entry in a directory + */ +makeentry(parent, ino, name) + ino_t parent, ino; + char *name; +{ + struct dinode *dp; + struct inodesc idesc; + char pathbuf[MAXPATHLEN + 1]; + + if (parent < ROOTINO || parent >= maxino || + ino < ROOTINO || ino >= maxino) + return (0); + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = DATA; + idesc.id_func = mkentry; + idesc.id_number = parent; + idesc.id_parent = ino; /* this is the inode to enter */ + idesc.id_fix = DONTKNOW; + idesc.id_name = name; + dp = ginode(parent); + if (dp->di_size % DIRBLKSIZ) { + dp->di_size = roundup(dp->di_size, DIRBLKSIZ); + inodirty(); + } + if ((ckinode(dp, &idesc) & ALTERED) != 0) + return (1); + getpathname(pathbuf, parent, parent); + dp = ginode(parent); + if (expanddir(dp, pathbuf) == 0) + return (0); + return (ckinode(dp, &idesc) & ALTERED); +} + +/* + * Attempt to expand the size of a directory + */ +expanddir(dp, name) + register struct dinode *dp; + char *name; +{ + daddr_t lastbn, newblk; + register struct bufarea *bp; + char *cp, firstblk[DIRBLKSIZ]; + + lastbn = lblkno(&sblock, dp->di_size); + if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0) + return (0); + if ((newblk = allocblk(sblock.fs_frag)) == 0) + return (0); + dp->di_db[lastbn + 1] = dp->di_db[lastbn]; + dp->di_db[lastbn] = newblk; + dp->di_size += sblock.fs_bsize; + dp->di_blocks += btodb(sblock.fs_bsize); + bp = getdirblk(dp->di_db[lastbn + 1], + (long)dblksize(&sblock, dp, lastbn + 1)); + if (bp->b_errs) + goto bad; + bcopy(bp->b_un.b_buf, firstblk, DIRBLKSIZ); + bp = getdirblk(newblk, sblock.fs_bsize); + if (bp->b_errs) + goto bad; + bcopy(firstblk, bp->b_un.b_buf, DIRBLKSIZ); + for (cp = &bp->b_un.b_buf[DIRBLKSIZ]; + cp < &bp->b_un.b_buf[sblock.fs_bsize]; + cp += DIRBLKSIZ) + bcopy((char *)&emptydir, cp, sizeof emptydir); + dirty(bp); + bp = getdirblk(dp->di_db[lastbn + 1], + (long)dblksize(&sblock, dp, lastbn + 1)); + if (bp->b_errs) + goto bad; + bcopy((char *)&emptydir, bp->b_un.b_buf, sizeof emptydir); + pwarn("NO SPACE LEFT IN %s", name); + if (preen) + printf(" (EXPANDED)\n"); + else if (reply("EXPAND") == 0) + goto bad; + dirty(bp); + inodirty(); + return (1); +bad: + dp->di_db[lastbn] = dp->di_db[lastbn + 1]; + dp->di_db[lastbn + 1] = 0; + dp->di_size -= sblock.fs_bsize; + dp->di_blocks -= btodb(sblock.fs_bsize); + freeblk(newblk, sblock.fs_frag); + return (0); +} + +/* + * allocate a new directory + */ +allocdir(parent, request, mode) + ino_t parent, request; + int mode; +{ + ino_t ino; + char *cp; + struct dinode *dp; + register struct bufarea *bp; + struct dirtemplate *dirp; + + ino = allocino(request, IFDIR|mode); + if (newinofmt) + dirp = &dirhead; + else + dirp = (struct dirtemplate *)&odirhead; + dirp->dot_ino = ino; + dirp->dotdot_ino = parent; + dp = ginode(ino); + bp = getdirblk(dp->di_db[0], sblock.fs_fsize); + if (bp->b_errs) { + freeino(ino); + return (0); + } + bcopy((char *)dirp, bp->b_un.b_buf, sizeof(struct dirtemplate)); + for (cp = &bp->b_un.b_buf[DIRBLKSIZ]; + cp < &bp->b_un.b_buf[sblock.fs_fsize]; + cp += DIRBLKSIZ) + bcopy((char *)&emptydir, cp, sizeof emptydir); + dirty(bp); + dp->di_nlink = 2; + inodirty(); + if (ino == ROOTINO) { + lncntp[ino] = dp->di_nlink; + cacheino(dp, ino); + return(ino); + } + if (statemap[parent] != DSTATE && statemap[parent] != DFOUND) { + freeino(ino); + return (0); + } + cacheino(dp, ino); + statemap[ino] = statemap[parent]; + if (statemap[ino] == DSTATE) { + lncntp[ino] = dp->di_nlink; + lncntp[parent]++; + } + dp = ginode(parent); + dp->di_nlink++; + inodirty(); + return (ino); +} + +/* + * free a directory inode + */ +freedir(ino, parent) + ino_t ino, parent; +{ + struct dinode *dp; + + if (ino != parent) { + dp = ginode(parent); + dp->di_nlink--; + inodirty(); + } + freeino(ino); +} + +/* + * generate a temporary name for the lost+found directory. + */ +lftempname(bufp, ino) + char *bufp; + ino_t ino; +{ + register ino_t in; + register char *cp; + int namlen; + + cp = bufp + 2; + for (in = maxino; in > 0; in /= 10) + cp++; + *--cp = 0; + namlen = cp - bufp; + in = ino; + while (cp > bufp) { + *--cp = (in % 10) + '0'; + in /= 10; + } + *cp = '#'; + return (namlen); +} + +/* + * Get a directory block. + * Insure that it is held until another is requested. + */ +struct bufarea * +getdirblk(blkno, size) + daddr_t blkno; + long size; +{ + + if (pdirbp != 0) + pdirbp->b_flags &= ~B_INUSE; + pdirbp = getdatablk(blkno, size); + return (pdirbp); +} diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c new file mode 100644 index 00000000..10a01afa --- /dev/null +++ b/bsdfsck/inode.c @@ -0,0 +1,549 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ +static char *rcsid = "$Id: inode.c,v 1.1 1994/08/23 19:29:21 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#ifndef SMALL +#include +#endif +#include +#include +#include "fsck.h" + +static ino_t startinum; + +ckinode(dp, idesc) + struct dinode *dp; + register struct inodesc *idesc; +{ + register daddr_t *ap; + long ret, n, ndb, offset; + struct dinode dino; + quad_t remsize, sizepb; + mode_t mode; + + if (idesc->id_fix != IGNORE) + idesc->id_fix = DONTKNOW; + idesc->id_entryno = 0; + idesc->id_filesize = dp->di_size; + mode = dp->di_mode & IFMT; + if (mode == IFBLK || mode == IFCHR || (mode == IFLNK && + (dp->di_size < sblock.fs_maxsymlinklen || + (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) + return (KEEPON); + dino = *dp; + ndb = howmany(dino.di_size, sblock.fs_bsize); + for (ap = &dino.di_db[0]; ap < &dino.di_db[NDADDR]; ap++) { + if (--ndb == 0 && (offset = blkoff(&sblock, dino.di_size)) != 0) + idesc->id_numfrags = + numfrags(&sblock, fragroundup(&sblock, offset)); + else + idesc->id_numfrags = sblock.fs_frag; + if (*ap == 0) + continue; + idesc->id_blkno = *ap; + if (idesc->id_type == ADDR) + ret = (*idesc->id_func)(idesc); + else + ret = dirscan(idesc); + if (ret & STOP) + return (ret); + } + idesc->id_numfrags = sblock.fs_frag; + remsize = dino.di_size - sblock.fs_bsize * NDADDR; + sizepb = sblock.fs_bsize; + for (ap = &dino.di_ib[0], n = 1; n <= NIADDR; ap++, n++) { + if (*ap) { + idesc->id_blkno = *ap; + ret = iblock(idesc, n, remsize); + if (ret & STOP) + return (ret); + } + sizepb *= NINDIR(&sblock); + remsize -= sizepb; + } + return (KEEPON); +} + +iblock(idesc, ilevel, isize) + struct inodesc *idesc; + long ilevel; + quad_t isize; +{ + register daddr_t *ap; + register daddr_t *aplim; + register struct bufarea *bp; + int i, n, (*func)(), nif; + quad_t sizepb; + char buf[BUFSIZ]; + extern int dirscan(), pass1check(); + + if (idesc->id_type == ADDR) { + func = idesc->id_func; + if (((n = (*func)(idesc)) & KEEPON) == 0) + return (n); + } else + func = dirscan; + if (chkrange(idesc->id_blkno, idesc->id_numfrags)) + return (SKIP); + bp = getdatablk(idesc->id_blkno, sblock.fs_bsize); + ilevel--; + for (sizepb = sblock.fs_bsize, i = 0; i < ilevel; i++) + sizepb *= NINDIR(&sblock); + nif = howmany(isize , sizepb); + if (nif > NINDIR(&sblock)) + nif = NINDIR(&sblock); + if (idesc->id_func == pass1check && nif < NINDIR(&sblock)) { + aplim = &bp->b_un.b_indir[NINDIR(&sblock)]; + for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) { + if (*ap == 0) + continue; + (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%lu", + idesc->id_number); + if (dofix(idesc, buf)) { + *ap = 0; + dirty(bp); + } + } + flush(fswritefd, bp); + } + aplim = &bp->b_un.b_indir[nif]; + for (ap = bp->b_un.b_indir; ap < aplim; ap++) { + if (*ap) { + idesc->id_blkno = *ap; + if (ilevel == 0) + n = (*func)(idesc); + else + n = iblock(idesc, ilevel, isize); + if (n & STOP) { + bp->b_flags &= ~B_INUSE; + return (n); + } + } + isize -= sizepb; + } + bp->b_flags &= ~B_INUSE; + return (KEEPON); +} + +/* + * Check that a block in a legal block number. + * Return 0 if in range, 1 if out of range. + */ +chkrange(blk, cnt) + daddr_t blk; + int cnt; +{ + register int c; + + if ((unsigned)(blk + cnt) > maxfsblock) + return (1); + c = dtog(&sblock, blk); + if (blk < cgdmin(&sblock, c)) { + if ((blk + cnt) > cgsblock(&sblock, c)) { + if (debug) { + printf("blk %ld < cgdmin %ld;", + blk, cgdmin(&sblock, c)); + printf(" blk + cnt %ld > cgsbase %ld\n", + blk + cnt, cgsblock(&sblock, c)); + } + return (1); + } + } else { + if ((blk + cnt) > cgbase(&sblock, c+1)) { + if (debug) { + printf("blk %ld >= cgdmin %ld;", + blk, cgdmin(&sblock, c)); + printf(" blk + cnt %ld > sblock.fs_fpg %ld\n", + blk+cnt, sblock.fs_fpg); + } + return (1); + } + } + return (0); +} + +/* + * General purpose interface for reading inodes. + */ +struct dinode * +ginode(inumber) + ino_t inumber; +{ + daddr_t iblk; + + if (inumber < ROOTINO || inumber > maxino) + errexit("bad inode number %d to ginode\n", inumber); + if (startinum == 0 || + inumber < startinum || inumber >= startinum + INOPB(&sblock)) { + iblk = ino_to_fsba(&sblock, inumber); + if (pbp != 0) + pbp->b_flags &= ~B_INUSE; + pbp = getdatablk(iblk, sblock.fs_bsize); + startinum = (inumber / INOPB(&sblock)) * INOPB(&sblock); + } + return (&pbp->b_un.b_dinode[inumber % INOPB(&sblock)]); +} + +/* + * Special purpose version of ginode used to optimize first pass + * over all the inodes in numerical order. + */ +ino_t nextino, lastinum; +long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize; +struct dinode *inodebuf; + +struct dinode * +getnextinode(inumber) + ino_t inumber; +{ + long size; + daddr_t dblk; + static struct dinode *dp; + + if (inumber != nextino++ || inumber > maxino) + errexit("bad inode number %d to nextinode\n", inumber); + if (inumber >= lastinum) { + readcnt++; + dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum)); + if (readcnt % readpercg == 0) { + size = partialsize; + lastinum += partialcnt; + } else { + size = inobufsize; + lastinum += fullcnt; + } + (void)bread(fsreadfd, (char *)inodebuf, dblk, size); /* ??? */ + dp = inodebuf; + } + return (dp++); +} + +resetinodebuf() +{ + + startinum = 0; + nextino = 0; + lastinum = 0; + readcnt = 0; + inobufsize = blkroundup(&sblock, INOBUFSIZE); + fullcnt = inobufsize / sizeof(struct dinode); + readpercg = sblock.fs_ipg / fullcnt; + partialcnt = sblock.fs_ipg % fullcnt; + partialsize = partialcnt * sizeof(struct dinode); + if (partialcnt != 0) { + readpercg++; + } else { + partialcnt = fullcnt; + partialsize = inobufsize; + } + if (inodebuf == NULL && + (inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL) + errexit("Cannot allocate space for inode buffer\n"); + while (nextino < ROOTINO) + (void)getnextinode(nextino); +} + +freeinodebuf() +{ + + if (inodebuf != NULL) + free((char *)inodebuf); + inodebuf = NULL; +} + +/* + * Routines to maintain information about directory inodes. + * This is built during the first pass and used during the + * second and third passes. + * + * Enter inodes into the cache. + */ +cacheino(dp, inumber) + register struct dinode *dp; + ino_t inumber; +{ + register struct inoinfo *inp; + struct inoinfo **inpp; + unsigned int blks; + + blks = howmany(dp->di_size, sblock.fs_bsize); + if (blks > NDADDR) + blks = NDADDR + NIADDR; + inp = (struct inoinfo *) + malloc(sizeof(*inp) + (blks - 1) * sizeof(daddr_t)); + if (inp == NULL) + return; + inpp = &inphead[inumber % numdirs]; + inp->i_nexthash = *inpp; + *inpp = inp; + inp->i_parent = (ino_t)0; + inp->i_dotdot = (ino_t)0; + inp->i_number = inumber; + inp->i_isize = dp->di_size; + inp->i_numblks = blks * sizeof(daddr_t); + bcopy((char *)&dp->di_db[0], (char *)&inp->i_blks[0], + (size_t)inp->i_numblks); + if (inplast == listmax) { + listmax += 100; + inpsort = (struct inoinfo **)realloc((char *)inpsort, + (unsigned)listmax * sizeof(struct inoinfo *)); + if (inpsort == NULL) + errexit("cannot increase directory list"); + } + inpsort[inplast++] = inp; +} + +/* + * Look up an inode cache structure. + */ +struct inoinfo * +getinoinfo(inumber) + ino_t inumber; +{ + register struct inoinfo *inp; + + for (inp = inphead[inumber % numdirs]; inp; inp = inp->i_nexthash) { + if (inp->i_number != inumber) + continue; + return (inp); + } + errexit("cannot find inode %d\n", inumber); + return ((struct inoinfo *)0); +} + +/* + * Clean up all the inode cache structure. + */ +inocleanup() +{ + register struct inoinfo **inpp; + + if (inphead == NULL) + return; + for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) + free((char *)(*inpp)); + free((char *)inphead); + free((char *)inpsort); + inphead = inpsort = NULL; +} + +inodirty() +{ + + dirty(pbp); +} + +clri(idesc, type, flag) + register struct inodesc *idesc; + char *type; + int flag; +{ + register struct dinode *dp; + + dp = ginode(idesc->id_number); + if (flag == 1) { + pwarn("%s %s", type, + (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"); + pinode(idesc->id_number); + } + if (preen || reply("CLEAR") == 1) { + if (preen) + printf(" (CLEARED)\n"); + n_files--; + (void)ckinode(dp, idesc); + clearinode(dp); + statemap[idesc->id_number] = USTATE; + inodirty(); + } +} + +findname(idesc) + struct inodesc *idesc; +{ + register struct direct *dirp = idesc->id_dirp; + + if (dirp->d_ino != idesc->id_parent) + return (KEEPON); + bcopy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1); + return (STOP|FOUND); +} + +findino(idesc) + struct inodesc *idesc; +{ + register struct direct *dirp = idesc->id_dirp; + + if (dirp->d_ino == 0) + return (KEEPON); + if (strcmp(dirp->d_name, idesc->id_name) == 0 && + dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) { + idesc->id_parent = dirp->d_ino; + return (STOP|FOUND); + } + return (KEEPON); +} + +pinode(ino) + ino_t ino; +{ + register struct dinode *dp; + register char *p; + struct passwd *pw; + char *ctime(); + + printf(" I=%lu ", ino); + if (ino < ROOTINO || ino > maxino) + return; + dp = ginode(ino); + printf(" OWNER="); +#ifndef SMALL + if ((pw = getpwuid((int)dp->di_uid)) != 0) + printf("%s ", pw->pw_name); + else +#endif + printf("%u ", (unsigned)dp->di_uid); + printf("MODE=%o\n", dp->di_mode); + if (preen) + printf("%s: ", cdevname); + printf("SIZE=%qu ", dp->di_size); + p = ctime(&dp->di_mtime.ts_sec); + printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]); +} + +blkerror(ino, type, blk) + ino_t ino; + char *type; + daddr_t blk; +{ + + pfatal("%ld %s I=%lu", blk, type, ino); + printf("\n"); + switch (statemap[ino]) { + + case FSTATE: + statemap[ino] = FCLEAR; + return; + + case DSTATE: + statemap[ino] = DCLEAR; + return; + + case FCLEAR: + case DCLEAR: + return; + + default: + errexit("BAD STATE %d TO BLKERR", statemap[ino]); + /* NOTREACHED */ + } +} + +/* + * allocate an unused inode + */ +ino_t +allocino(request, type) + ino_t request; + int type; +{ + register ino_t ino; + register struct dinode *dp; + + if (request == 0) + request = ROOTINO; + else if (statemap[request] != USTATE) + return (0); + for (ino = request; ino < maxino; ino++) + if (statemap[ino] == USTATE) + break; + if (ino == maxino) + return (0); + switch (type & IFMT) { + case IFDIR: + statemap[ino] = DSTATE; + break; + case IFREG: + case IFLNK: + statemap[ino] = FSTATE; + break; + default: + return (0); + } + dp = ginode(ino); + dp->di_db[0] = allocblk((long)1); + if (dp->di_db[0] == 0) { + statemap[ino] = USTATE; + return (0); + } + dp->di_mode = type; + (void)time(&dp->di_atime.ts_sec); + dp->di_mtime = dp->di_ctime = dp->di_atime; + dp->di_size = sblock.fs_fsize; + dp->di_blocks = btodb(sblock.fs_fsize); + n_files++; + inodirty(); + if (newinofmt) + typemap[ino] = IFTODT(type); + return (ino); +} + +/* + * deallocate an inode + */ +freeino(ino) + ino_t ino; +{ + struct inodesc idesc; + extern int pass4check(); + struct dinode *dp; + + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = ADDR; + idesc.id_func = pass4check; + idesc.id_number = ino; + dp = ginode(ino); + (void)ckinode(dp, &idesc); + clearinode(dp); + inodirty(); + statemap[ino] = USTATE; + n_files--; +} diff --git a/bsdfsck/main.c b/bsdfsck/main.c new file mode 100644 index 00000000..e8f952a1 --- /dev/null +++ b/bsdfsck/main.c @@ -0,0 +1,319 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1980, 1986, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)main.c 8.2 (Berkeley) 1/23/94";*/ +static char *rcsid = "$Id: main.c,v 1.1 1994/08/23 19:29:22 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +void catch(), catchquit(), voidquit(); +int returntosingle; + +main(argc, argv) + int argc; + char *argv[]; +{ + int ch; + int ret, maxrun = 0; + extern int docheck(), checkfilesys(); + extern char *optarg, *blockcheck(); + extern int optind; + + sync(); + while ((ch = getopt(argc, argv, "dpnNyYb:c:l:m:")) != EOF) { + switch (ch) { + case 'p': + preen++; + break; + + case 'b': + bflag = argtoi('b', "number", optarg, 10); + printf("Alternate super block location: %d\n", bflag); + break; + + case 'c': + cvtlevel = argtoi('c', "conversion level", optarg, 10); + break; + + case 'd': + debug++; + break; + + case 'l': + maxrun = argtoi('l', "number", optarg, 10); + break; + + case 'm': + lfmode = argtoi('m', "mode", optarg, 8); + if (lfmode &~ 07777) + errexit("bad mode to -m: %o\n", lfmode); + printf("** lost+found creation mode %o\n", lfmode); + break; + + case 'n': + case 'N': + nflag++; + yflag = 0; + break; + + case 'y': + case 'Y': + yflag++; + nflag = 0; + break; + + default: + errexit("%c option?\n", ch); + } + } + argc -= optind; + argv += optind; + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + (void)signal(SIGINT, catch); + if (preen) + (void)signal(SIGQUIT, catchquit); + if (argc) { + while (argc-- > 0) + (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0); + exit(0); + } + ret = checkfstab(preen, maxrun, docheck, checkfilesys); + if (returntosingle) + exit(2); + exit(ret); +} + +argtoi(flag, req, str, base) + int flag; + char *req, *str; + int base; +{ + char *cp; + int ret; + + ret = (int)strtol(str, &cp, base); + if (cp == str || *cp) + errexit("-%c flag requires a %s\n", flag, req); + return (ret); +} + +/* + * Determine whether a filesystem should be checked. + */ +docheck(fsp) + register struct fstab *fsp; +{ + + if (strcmp(fsp->fs_vfstype, "ufs") || + (strcmp(fsp->fs_type, FSTAB_RW) && + strcmp(fsp->fs_type, FSTAB_RO)) || + fsp->fs_passno == 0) + return (0); + return (1); +} + +/* + * Check the specified filesystem. + */ +/* ARGSUSED */ +checkfilesys(filesys, mntpt, auxdata, child) + char *filesys, *mntpt; + long auxdata; +{ + daddr_t n_ffree, n_bfree; + struct dups *dp; + struct zlncnt *zlnp; + int cylno; + + if (preen && child) + (void)signal(SIGQUIT, voidquit); + cdevname = filesys; + if (debug && preen) + pwarn("starting\n"); + if (setup(filesys) == 0) { + if (preen) + pfatal("CAN'T CHECK FILE SYSTEM."); + return (0); + } + /* + * 1: scan inodes tallying blocks used + */ + if (preen == 0) { + printf("** Last Mounted on %s\n", sblock.fs_fsmnt); + if (hotroot) + printf("** Root file system\n"); + printf("** Phase 1 - Check Blocks and Sizes\n"); + } + pass1(); + + /* + * 1b: locate first references to duplicates, if any + */ + if (duplist) { + if (preen) + pfatal("INTERNAL ERROR: dups with -p"); + printf("** Phase 1b - Rescan For More DUPS\n"); + pass1b(); + } + + /* + * 2: traverse directories from root to mark all connected directories + */ + if (preen == 0) + printf("** Phase 2 - Check Pathnames\n"); + pass2(); + + /* + * 3: scan inodes looking for disconnected directories + */ + if (preen == 0) + printf("** Phase 3 - Check Connectivity\n"); + pass3(); + + /* + * 4: scan inodes looking for disconnected files; check reference counts + */ + if (preen == 0) + printf("** Phase 4 - Check Reference Counts\n"); + pass4(); + + /* + * 5: check and repair resource counts in cylinder groups + */ + if (preen == 0) + printf("** Phase 5 - Check Cyl groups\n"); + pass5(); + + /* + * print out summary statistics + */ + n_ffree = sblock.fs_cstotal.cs_nffree; + n_bfree = sblock.fs_cstotal.cs_nbfree; + pwarn("%ld files, %ld used, %ld free ", + n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree); + printf("(%ld frags, %ld blocks, %d.%d%% fragmentation)\n", + n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_dsize, + ((n_ffree * 1000 + sblock.fs_dsize / 2) / sblock.fs_dsize) % 10); + if (debug && + (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree)) + printf("%ld files missing\n", n_files); + if (debug) { + n_blks += sblock.fs_ncg * + (cgdmin(&sblock, 0) - cgsblock(&sblock, 0)); + n_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0); + n_blks += howmany(sblock.fs_cssize, sblock.fs_fsize); + if (n_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree)) + printf("%ld blocks missing\n", n_blks); + if (duplist != NULL) { + printf("The following duplicate blocks remain:"); + for (dp = duplist; dp; dp = dp->next) + printf(" %ld,", dp->dup); + printf("\n"); + } + if (zlnhead != NULL) { + printf("The following zero link count inodes remain:"); + for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) + printf(" %lu,", zlnp->zlncnt); + printf("\n"); + } + } + zlnhead = (struct zlncnt *)0; + duplist = (struct dups *)0; + muldup = (struct dups *)0; + inocleanup(); + if (fsmodified) { + (void)time(&sblock.fs_time); + sbdirty(); + } + if (cvtlevel && sblk.b_dirty) { + /* + * Write out the duplicate super blocks + */ + for (cylno = 0; cylno < sblock.fs_ncg; cylno++) + bwrite(fswritefd, (char *)&sblock, + fsbtodb(&sblock, cgsblock(&sblock, cylno)), SBSIZE); + } + ckfini(); + free(blockmap); + free(statemap); + free((char *)lncntp); + if (!fsmodified) + return (0); + if (!preen) + printf("\n***** FILE SYSTEM WAS MODIFIED *****\n"); + if (hotroot) { + struct statfs stfs_buf; + /* + * We modified the root. Do a mount update on + * it, unless it is read-write, so we can continue. + */ + if (statfs("/", &stfs_buf) == 0) { + long flags = stfs_buf.f_flags; + struct ufs_args args; + int ret; + + if (flags & MNT_RDONLY) { + args.fspec = 0; + args.export.ex_flags = 0; + args.export.ex_root = 0; + flags |= MNT_UPDATE | MNT_RELOAD; + ret = mount(MOUNT_UFS, "/", flags, &args); + if (ret == 0) + return(0); + } + } + if (!preen) + printf("\n***** REBOOT NOW *****\n"); + sync(); + return (4); + } + return (0); +} diff --git a/bsdfsck/pass1.c b/bsdfsck/pass1.c new file mode 100644 index 00000000..cc15c199 --- /dev/null +++ b/bsdfsck/pass1.c @@ -0,0 +1,324 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass1.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: pass1.c,v 1.1 1994/08/23 19:29:23 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +static daddr_t badblk; +static daddr_t dupblk; +int pass1check(); +struct dinode *getnextinode(); + +pass1() +{ + ino_t inumber; + int c, i, cgd; + struct inodesc idesc; + + /* + * Set file system reserved blocks in used block map. + */ + for (c = 0; c < sblock.fs_ncg; c++) { + cgd = cgdmin(&sblock, c); + if (c == 0) { + i = cgbase(&sblock, c); + cgd += howmany(sblock.fs_cssize, sblock.fs_fsize); + } else + i = cgsblock(&sblock, c); + for (; i < cgd; i++) + setbmap(i); + } + /* + * Find all allocated blocks. + */ + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = ADDR; + idesc.id_func = pass1check; + inumber = 0; + n_files = n_blks = 0; + resetinodebuf(); + for (c = 0; c < sblock.fs_ncg; c++) { + for (i = 0; i < sblock.fs_ipg; i++, inumber++) { + if (inumber < ROOTINO) + continue; + checkinode(inumber, &idesc); + } + } + freeinodebuf(); +} + +checkinode(inumber, idesc) + ino_t inumber; + register struct inodesc *idesc; +{ + register struct dinode *dp; + struct zlncnt *zlnp; + int ndb, j; + mode_t mode; + char *symbuf; + + dp = getnextinode(inumber); + mode = dp->di_mode & IFMT; + if (mode == 0) { + if (bcmp((char *)dp->di_db, (char *)zino.di_db, + NDADDR * sizeof(daddr_t)) || + bcmp((char *)dp->di_ib, (char *)zino.di_ib, + NIADDR * sizeof(daddr_t)) || + dp->di_mode || dp->di_size) { + pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber); + if (reply("CLEAR") == 1) { + dp = ginode(inumber); + clearinode(dp); + inodirty(); + } + } + statemap[inumber] = USTATE; + return; + } + lastino = inumber; + if (/* dp->di_size < 0 || */ + dp->di_size + sblock.fs_bsize - 1 < dp->di_size) { + if (debug) + printf("bad size %qu:", dp->di_size); + goto unknown; + } + if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) { + dp = ginode(inumber); + dp->di_size = sblock.fs_fsize; + dp->di_mode = IFREG|0600; + inodirty(); + } + ndb = howmany(dp->di_size, sblock.fs_bsize); + if (ndb < 0) { + if (debug) + printf("bad size %qu ndb %d:", + dp->di_size, ndb); + goto unknown; + } + if (mode == IFBLK || mode == IFCHR) + ndb++; + if (mode == IFLNK) { + /* + * Note that the old fastlink format always had di_blocks set + * to 0. Other than that we no longer use the `spare' field + * (which is now the extended uid) for sanity checking, the + * new format is the same as the old. We simply ignore the + * conversion altogether. - mycroft, 19MAY1994 + */ + if (doinglevel2 && + dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && + dp->di_blocks != 0) { + symbuf = alloca(secsize); + if (bread(fsreadfd, symbuf, + fsbtodb(&sblock, dp->di_db[0]), + (long)secsize) != 0) + errexit("cannot read symlink"); + if (debug) { + symbuf[dp->di_size] = 0; + printf("convert symlink %d(%s) of size %d\n", + inumber, symbuf, (long)dp->di_size); + } + dp = ginode(inumber); + bcopy(symbuf, (caddr_t)dp->di_shortlink, + (long)dp->di_size); + dp->di_blocks = 0; + inodirty(); + } + /* + * Fake ndb value so direct/indirect block checks below + * will detect any garbage after symlink string. + */ + if (dp->di_size < sblock.fs_maxsymlinklen || + (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)) { + ndb = howmany(dp->di_size, sizeof(daddr_t)); + if (ndb > NDADDR) { + j = ndb - NDADDR; + for (ndb = 1; j > 1; j--) + ndb *= NINDIR(&sblock); + ndb += NDADDR; + } + } + } + for (j = ndb; j < NDADDR; j++) + if (dp->di_db[j] != 0) { + if (debug) + printf("bad direct addr: %ld\n", dp->di_db[j]); + goto unknown; + } + for (j = 0, ndb -= NDADDR; ndb > 0; j++) + ndb /= NINDIR(&sblock); + for (; j < NIADDR; j++) + if (dp->di_ib[j] != 0) { + if (debug) + printf("bad indirect addr: %ld\n", + dp->di_ib[j]); + goto unknown; + } + if (ftypeok(dp) == 0) + goto unknown; + n_files++; + lncntp[inumber] = dp->di_nlink; + if (dp->di_nlink <= 0) { + zlnp = (struct zlncnt *)malloc(sizeof *zlnp); + if (zlnp == NULL) { + pfatal("LINK COUNT TABLE OVERFLOW"); + if (reply("CONTINUE") == 0) + errexit(""); + } else { + zlnp->zlncnt = inumber; + zlnp->next = zlnhead; + zlnhead = zlnp; + } + } + if (mode == IFDIR) { + if (dp->di_size == 0) + statemap[inumber] = DCLEAR; + else + statemap[inumber] = DSTATE; + cacheino(dp, inumber); + } else + statemap[inumber] = FSTATE; + typemap[inumber] = IFTODT(mode); + if (doinglevel2 && + (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) { + dp = ginode(inumber); + dp->di_uid = dp->di_ouid; + dp->di_ouid = -1; + dp->di_gid = dp->di_ogid; + dp->di_ogid = -1; + inodirty(); + } + badblk = dupblk = 0; + idesc->id_number = inumber; + (void)ckinode(dp, idesc); + idesc->id_entryno *= btodb(sblock.fs_fsize); + if (dp->di_blocks != idesc->id_entryno) { + pwarn("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)", + inumber, dp->di_blocks, idesc->id_entryno); + if (preen) + printf(" (CORRECTED)\n"); + else if (reply("CORRECT") == 0) + return; + dp = ginode(inumber); + dp->di_blocks = idesc->id_entryno; + inodirty(); + } + return; +unknown: + pfatal("UNKNOWN FILE TYPE I=%lu", inumber); + statemap[inumber] = FCLEAR; + if (reply("CLEAR") == 1) { + statemap[inumber] = USTATE; + dp = ginode(inumber); + clearinode(dp); + inodirty(); + } +} + +pass1check(idesc) + register struct inodesc *idesc; +{ + int res = KEEPON; + int anyout, nfrags; + daddr_t blkno = idesc->id_blkno; + register struct dups *dlp; + struct dups *new; + + if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) { + blkerror(idesc->id_number, "BAD", blkno); + if (badblk++ >= MAXBAD) { + pwarn("EXCESSIVE BAD BLKS I=%lu", + idesc->id_number); + if (preen) + printf(" (SKIPPING)\n"); + else if (reply("CONTINUE") == 0) + errexit(""); + return (STOP); + } + } + for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { + if (anyout && chkrange(blkno, 1)) { + res = SKIP; + } else if (!testbmap(blkno)) { + n_blks++; + setbmap(blkno); + } else { + blkerror(idesc->id_number, "DUP", blkno); + if (dupblk++ >= MAXDUP) { + pwarn("EXCESSIVE DUP BLKS I=%lu", + idesc->id_number); + if (preen) + printf(" (SKIPPING)\n"); + else if (reply("CONTINUE") == 0) + errexit(""); + return (STOP); + } + new = (struct dups *)malloc(sizeof(struct dups)); + if (new == NULL) { + pfatal("DUP TABLE OVERFLOW."); + if (reply("CONTINUE") == 0) + errexit(""); + return (STOP); + } + new->dup = blkno; + if (muldup == 0) { + duplist = muldup = new; + new->next = 0; + } else { + new->next = muldup->next; + muldup->next = new; + } + for (dlp = duplist; dlp != muldup; dlp = dlp->next) + if (dlp->dup == blkno) + break; + if (dlp == muldup && dlp->dup != blkno) + muldup = new; + } + /* + * count the number of blocks found in id_entryno + */ + idesc->id_entryno++; + } + return (res); +} diff --git a/bsdfsck/pass1b.c b/bsdfsck/pass1b.c new file mode 100644 index 00000000..d40e2254 --- /dev/null +++ b/bsdfsck/pass1b.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass1b.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: pass1b.c,v 1.1 1994/08/23 19:29:23 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include "fsck.h" + +int pass1bcheck(); +static struct dups *duphead; + +pass1b() +{ + register int c, i; + register struct dinode *dp; + struct inodesc idesc; + ino_t inumber; + + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = ADDR; + idesc.id_func = pass1bcheck; + duphead = duplist; + inumber = 0; + for (c = 0; c < sblock.fs_ncg; c++) { + for (i = 0; i < sblock.fs_ipg; i++, inumber++) { + if (inumber < ROOTINO) + continue; + dp = ginode(inumber); + if (dp == NULL) + continue; + idesc.id_number = inumber; + if (statemap[inumber] != USTATE && + (ckinode(dp, &idesc) & STOP)) + return; + } + } +} + +pass1bcheck(idesc) + register struct inodesc *idesc; +{ + register struct dups *dlp; + int nfrags, res = KEEPON; + daddr_t blkno = idesc->id_blkno; + + for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { + if (chkrange(blkno, 1)) + res = SKIP; + for (dlp = duphead; dlp; dlp = dlp->next) { + if (dlp->dup == blkno) { + blkerror(idesc->id_number, "DUP", blkno); + dlp->dup = duphead->dup; + duphead->dup = blkno; + duphead = duphead->next; + } + if (dlp == muldup) + break; + } + if (muldup == 0 || duphead == muldup->next) + return (STOP); + } + return (res); +} diff --git a/bsdfsck/pass2.c b/bsdfsck/pass2.c new file mode 100644 index 00000000..df3af93c --- /dev/null +++ b/bsdfsck/pass2.c @@ -0,0 +1,431 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass2.c 8.2 (Berkeley) 2/27/94";*/ +static char *rcsid = "$Id: pass2.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +#define MINDIRSIZE (sizeof (struct dirtemplate)) + +int pass2check(), blksort(); + +pass2() +{ + register struct dinode *dp; + register struct inoinfo **inpp, *inp; + struct inoinfo **inpend; + struct inodesc curino; + struct dinode dino; + char pathbuf[MAXPATHLEN + 1]; + + switch (statemap[ROOTINO]) { + + case USTATE: + pfatal("ROOT INODE UNALLOCATED"); + if (reply("ALLOCATE") == 0) + errexit(""); + if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit("CANNOT ALLOCATE ROOT INODE\n"); + break; + + case DCLEAR: + pfatal("DUPS/BAD IN ROOT INODE"); + if (reply("REALLOCATE")) { + freeino(ROOTINO); + if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit("CANNOT ALLOCATE ROOT INODE\n"); + break; + } + if (reply("CONTINUE") == 0) + errexit(""); + break; + + case FSTATE: + case FCLEAR: + pfatal("ROOT INODE NOT DIRECTORY"); + if (reply("REALLOCATE")) { + freeino(ROOTINO); + if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit("CANNOT ALLOCATE ROOT INODE\n"); + break; + } + if (reply("FIX") == 0) + errexit(""); + dp = ginode(ROOTINO); + dp->di_mode &= ~IFMT; + dp->di_mode |= IFDIR; + inodirty(); + break; + + case DSTATE: + break; + + default: + errexit("BAD STATE %d FOR ROOT INODE", statemap[ROOTINO]); + } + statemap[ROOTINO] = DFOUND; + /* + * Sort the directory list into disk block order. + */ + qsort((char *)inpsort, (size_t)inplast, sizeof *inpsort, blksort); + /* + * Check the integrity of each directory. + */ + bzero((char *)&curino, sizeof(struct inodesc)); + curino.id_type = DATA; + curino.id_func = pass2check; + dp = &dino; + inpend = &inpsort[inplast]; + for (inpp = inpsort; inpp < inpend; inpp++) { + inp = *inpp; + if (inp->i_isize == 0) + continue; + if (inp->i_isize < MINDIRSIZE) { + direrror(inp->i_number, "DIRECTORY TOO SHORT"); + inp->i_isize = roundup(MINDIRSIZE, DIRBLKSIZ); + if (reply("FIX") == 1) { + dp = ginode(inp->i_number); + dp->di_size = inp->i_isize; + inodirty(); + dp = &dino; + } + } else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) { + getpathname(pathbuf, inp->i_number, inp->i_number); + pwarn("DIRECTORY %s: LENGTH %d NOT MULTIPLE OF %d", + pathbuf, inp->i_isize, DIRBLKSIZ); + if (preen) + printf(" (ADJUSTED)\n"); + inp->i_isize = roundup(inp->i_isize, DIRBLKSIZ); + if (preen || reply("ADJUST") == 1) { + dp = ginode(inp->i_number); + dp->di_size = roundup(inp->i_isize, DIRBLKSIZ); + inodirty(); + dp = &dino; + } + } + bzero((char *)&dino, sizeof(struct dinode)); + dino.di_mode = IFDIR; + dp->di_size = inp->i_isize; + bcopy((char *)&inp->i_blks[0], (char *)&dp->di_db[0], + (size_t)inp->i_numblks); + curino.id_number = inp->i_number; + curino.id_parent = inp->i_parent; + (void)ckinode(dp, &curino); + } + /* + * Now that the parents of all directories have been found, + * make another pass to verify the value of `..' + */ + for (inpp = inpsort; inpp < inpend; inpp++) { + inp = *inpp; + if (inp->i_parent == 0 || inp->i_isize == 0) + continue; + if (statemap[inp->i_parent] == DFOUND && + statemap[inp->i_number] == DSTATE) + statemap[inp->i_number] = DFOUND; + if (inp->i_dotdot == inp->i_parent || + inp->i_dotdot == (ino_t)-1) + continue; + if (inp->i_dotdot == 0) { + inp->i_dotdot = inp->i_parent; + fileerror(inp->i_parent, inp->i_number, "MISSING '..'"); + if (reply("FIX") == 0) + continue; + (void)makeentry(inp->i_number, inp->i_parent, ".."); + lncntp[inp->i_parent]--; + continue; + } + fileerror(inp->i_parent, inp->i_number, + "BAD INODE NUMBER FOR '..'"); + if (reply("FIX") == 0) + continue; + lncntp[inp->i_dotdot]++; + lncntp[inp->i_parent]--; + inp->i_dotdot = inp->i_parent; + (void)changeino(inp->i_number, "..", inp->i_parent); + } + /* + * Mark all the directories that can be found from the root. + */ + propagate(); +} + +pass2check(idesc) + struct inodesc *idesc; +{ + register struct direct *dirp = idesc->id_dirp; + register struct inoinfo *inp; + int n, entrysize, ret = 0; + struct dinode *dp; + char *errmsg; + struct direct proto; + char namebuf[MAXPATHLEN + 1]; + char pathbuf[MAXPATHLEN + 1]; + + /* + * If converting, set directory entry type. + */ + if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) { + dirp->d_type = typemap[dirp->d_ino]; + ret |= ALTERED; + } + /* + * check for "." + */ + if (idesc->id_entryno != 0) + goto chk1; + if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) { + if (dirp->d_ino != idesc->id_number) { + direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'"); + dirp->d_ino = idesc->id_number; + if (reply("FIX") == 1) + ret |= ALTERED; + } + if (newinofmt && dirp->d_type != DT_DIR) { + direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'"); + dirp->d_type = DT_DIR; + if (reply("FIX") == 1) + ret |= ALTERED; + } + goto chk1; + } + direrror(idesc->id_number, "MISSING '.'"); + proto.d_ino = idesc->id_number; + if (newinofmt) + proto.d_type = DT_DIR; + else + proto.d_type = 0; + proto.d_namlen = 1; + (void)strcpy(proto.d_name, "."); + entrysize = DIRSIZ(0, &proto); + if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) { + pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", + dirp->d_name); + } else if (dirp->d_reclen < entrysize) { + pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n"); + } else if (dirp->d_reclen < 2 * entrysize) { + proto.d_reclen = dirp->d_reclen; + bcopy((char *)&proto, (char *)dirp, (size_t)entrysize); + if (reply("FIX") == 1) + ret |= ALTERED; + } else { + n = dirp->d_reclen - entrysize; + proto.d_reclen = entrysize; + bcopy((char *)&proto, (char *)dirp, (size_t)entrysize); + idesc->id_entryno++; + lncntp[dirp->d_ino]--; + dirp = (struct direct *)((char *)(dirp) + entrysize); + bzero((char *)dirp, (size_t)n); + dirp->d_reclen = n; + if (reply("FIX") == 1) + ret |= ALTERED; + } +chk1: + if (idesc->id_entryno > 1) + goto chk2; + inp = getinoinfo(idesc->id_number); + proto.d_ino = inp->i_parent; + if (newinofmt) + proto.d_type = DT_DIR; + else + proto.d_type = 0; + proto.d_namlen = 2; + (void)strcpy(proto.d_name, ".."); + entrysize = DIRSIZ(0, &proto); + if (idesc->id_entryno == 0) { + n = DIRSIZ(0, dirp); + if (dirp->d_reclen < n + entrysize) + goto chk2; + proto.d_reclen = dirp->d_reclen - n; + dirp->d_reclen = n; + idesc->id_entryno++; + lncntp[dirp->d_ino]--; + dirp = (struct direct *)((char *)(dirp) + n); + bzero((char *)dirp, (size_t)proto.d_reclen); + dirp->d_reclen = proto.d_reclen; + } + if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) { + inp->i_dotdot = dirp->d_ino; + if (newinofmt && dirp->d_type != DT_DIR) { + direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'"); + dirp->d_type = DT_DIR; + if (reply("FIX") == 1) + ret |= ALTERED; + } + goto chk2; + } + if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) { + fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); + pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n", + dirp->d_name); + inp->i_dotdot = (ino_t)-1; + } else if (dirp->d_reclen < entrysize) { + fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); + pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n"); + inp->i_dotdot = (ino_t)-1; + } else if (inp->i_parent != 0) { + /* + * We know the parent, so fix now. + */ + inp->i_dotdot = inp->i_parent; + fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); + proto.d_reclen = dirp->d_reclen; + bcopy((char *)&proto, (char *)dirp, (size_t)entrysize); + if (reply("FIX") == 1) + ret |= ALTERED; + } + idesc->id_entryno++; + if (dirp->d_ino != 0) + lncntp[dirp->d_ino]--; + return (ret|KEEPON); +chk2: + if (dirp->d_ino == 0) + return (ret|KEEPON); + if (dirp->d_namlen <= 2 && + dirp->d_name[0] == '.' && + idesc->id_entryno >= 2) { + if (dirp->d_namlen == 1) { + direrror(idesc->id_number, "EXTRA '.' ENTRY"); + dirp->d_ino = 0; + if (reply("FIX") == 1) + ret |= ALTERED; + return (KEEPON | ret); + } + if (dirp->d_name[1] == '.') { + direrror(idesc->id_number, "EXTRA '..' ENTRY"); + dirp->d_ino = 0; + if (reply("FIX") == 1) + ret |= ALTERED; + return (KEEPON | ret); + } + } + idesc->id_entryno++; + n = 0; + if (dirp->d_ino > maxino) { + fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE"); + n = reply("REMOVE"); + } else { +again: + switch (statemap[dirp->d_ino]) { + case USTATE: + if (idesc->id_entryno <= 2) + break; + fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED"); + n = reply("REMOVE"); + break; + + case DCLEAR: + case FCLEAR: + if (idesc->id_entryno <= 2) + break; + if (statemap[dirp->d_ino] == FCLEAR) + errmsg = "DUP/BAD"; + else if (!preen) + errmsg = "ZERO LENGTH DIRECTORY"; + else { + n = 1; + break; + } + fileerror(idesc->id_number, dirp->d_ino, errmsg); + if ((n = reply("REMOVE")) == 1) + break; + dp = ginode(dirp->d_ino); + statemap[dirp->d_ino] = + (dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE; + lncntp[dirp->d_ino] = dp->di_nlink; + goto again; + + case DSTATE: + if (statemap[idesc->id_number] == DFOUND) + statemap[dirp->d_ino] = DFOUND; + /* fall through */ + + case DFOUND: + inp = getinoinfo(dirp->d_ino); + if (inp->i_parent != 0 && idesc->id_entryno > 2) { + getpathname(pathbuf, idesc->id_number, + idesc->id_number); + getpathname(namebuf, dirp->d_ino, dirp->d_ino); + pwarn("%s %s %s\n", pathbuf, + "IS AN EXTRANEOUS HARD LINK TO DIRECTORY", + namebuf); + if (preen) + printf(" (IGNORED)\n"); + else if ((n = reply("REMOVE")) == 1) + break; + } + if (idesc->id_entryno > 2) + inp->i_parent = idesc->id_number; + /* fall through */ + + case FSTATE: + if (newinofmt && dirp->d_type != typemap[dirp->d_ino]) { + fileerror(idesc->id_number, dirp->d_ino, + "BAD TYPE VALUE"); + dirp->d_type = typemap[dirp->d_ino]; + if (reply("FIX") == 1) + ret |= ALTERED; + } + lncntp[dirp->d_ino]--; + break; + + default: + errexit("BAD STATE %d FOR INODE I=%d", + statemap[dirp->d_ino], dirp->d_ino); + } + } + if (n == 0) + return (ret|KEEPON); + dirp->d_ino = 0; + return (ret|KEEPON|ALTERED); +} + +/* + * Routine to sort disk blocks. + */ +blksort(inpp1, inpp2) + struct inoinfo **inpp1, **inpp2; +{ + + return ((*inpp1)->i_blks[0] - (*inpp2)->i_blks[0]); +} diff --git a/bsdfsck/pass3.c b/bsdfsck/pass3.c new file mode 100644 index 00000000..12c40700 --- /dev/null +++ b/bsdfsck/pass3.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass3.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: pass3.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include "fsck.h" + +pass3() +{ + register struct inoinfo **inpp, *inp; + ino_t orphan; + int loopcnt; + + for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) { + inp = *inpp; + if (inp->i_number == ROOTINO || + !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE)) + continue; + if (statemap[inp->i_number] == DCLEAR) + continue; + for (loopcnt = 0; ; loopcnt++) { + orphan = inp->i_number; + if (inp->i_parent == 0 || + statemap[inp->i_parent] != DSTATE || + loopcnt > numdirs) + break; + inp = getinoinfo(inp->i_parent); + } + (void)linkup(orphan, inp->i_dotdot); + inp->i_parent = inp->i_dotdot = lfdir; + lncntp[lfdir]--; + statemap[orphan] = DFOUND; + propagate(); + } +} diff --git a/bsdfsck/pass4.c b/bsdfsck/pass4.c new file mode 100644 index 00000000..b7623f4e --- /dev/null +++ b/bsdfsck/pass4.c @@ -0,0 +1,134 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass4.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: pass4.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +int pass4check(); + +pass4() +{ + register ino_t inumber; + register struct zlncnt *zlnp; + struct dinode *dp; + struct inodesc idesc; + int n; + + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = ADDR; + idesc.id_func = pass4check; + for (inumber = ROOTINO; inumber <= lastino; inumber++) { + idesc.id_number = inumber; + switch (statemap[inumber]) { + + case FSTATE: + case DFOUND: + n = lncntp[inumber]; + if (n) + adjust(&idesc, (short)n); + else { + for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) + if (zlnp->zlncnt == inumber) { + zlnp->zlncnt = zlnhead->zlncnt; + zlnp = zlnhead; + zlnhead = zlnhead->next; + free((char *)zlnp); + clri(&idesc, "UNREF", 1); + break; + } + } + break; + + case DSTATE: + clri(&idesc, "UNREF", 1); + break; + + case DCLEAR: + dp = ginode(inumber); + if (dp->di_size == 0) { + clri(&idesc, "ZERO LENGTH", 1); + break; + } + /* fall through */ + case FCLEAR: + clri(&idesc, "BAD/DUP", 1); + break; + + case USTATE: + break; + + default: + errexit("BAD STATE %d FOR INODE I=%d", + statemap[inumber], inumber); + } + } +} + +pass4check(idesc) + register struct inodesc *idesc; +{ + register struct dups *dlp; + int nfrags, res = KEEPON; + daddr_t blkno = idesc->id_blkno; + + for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { + if (chkrange(blkno, 1)) { + res = SKIP; + } else if (testbmap(blkno)) { + for (dlp = duplist; dlp; dlp = dlp->next) { + if (dlp->dup != blkno) + continue; + dlp->dup = duplist->dup; + dlp = duplist; + duplist = duplist->next; + free((char *)dlp); + break; + } + if (dlp == 0) { + clrbmap(blkno); + n_blks--; + } + } + } + return (res); +} diff --git a/bsdfsck/pass5.c b/bsdfsck/pass5.c new file mode 100644 index 00000000..66e9efea --- /dev/null +++ b/bsdfsck/pass5.c @@ -0,0 +1,320 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)pass5.c 8.2 (Berkeley) 2/2/94";*/ +static char *rcsid = "$Id: pass5.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include "fsck.h" + +pass5() +{ + int c, blk, frags, basesize, sumsize, mapsize, savednrpos; + register struct fs *fs = &sblock; + register struct cg *cg = &cgrp; + daddr_t dbase, dmax; + register daddr_t d; + register long i, j; + struct csum *cs; + struct csum cstotal; + struct inodesc idesc[3]; + char buf[MAXBSIZE]; + register struct cg *newcg = (struct cg *)buf; + struct ocg *ocg = (struct ocg *)buf; + + bzero((char *)newcg, (size_t)fs->fs_cgsize); + newcg->cg_niblk = fs->fs_ipg; + if (cvtlevel > 3) { + if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) { + if (preen) + pwarn("DELETING CLUSTERING MAPS\n"); + if (preen || reply("DELETE CLUSTERING MAPS")) { + fs->fs_contigsumsize = 0; + doinglevel1 = 1; + sbdirty(); + } + } + if (fs->fs_maxcontig > 1) { + char *doit = 0; + + if (fs->fs_contigsumsize < 1) { + doit = "CREAT"; + } else if (fs->fs_contigsumsize < fs->fs_maxcontig && + fs->fs_contigsumsize < FS_MAXCONTIG) { + doit = "EXPAND"; + } + if (doit) { + i = fs->fs_contigsumsize; + fs->fs_contigsumsize = + MIN(fs->fs_maxcontig, FS_MAXCONTIG); + if (CGSIZE(fs) > fs->fs_bsize) { + pwarn("CANNOT %s CLUSTER MAPS\n", doit); + fs->fs_contigsumsize = i; + } else if (preen || + reply("CREATE CLUSTER MAPS")) { + if (preen) + pwarn("%sING CLUSTER MAPS\n", + doit); + fs->fs_cgsize = + fragroundup(fs, CGSIZE(fs)); + doinglevel1 = 1; + sbdirty(); + } + } + } + } + switch ((int)fs->fs_postblformat) { + + case FS_42POSTBLFMT: + basesize = (char *)(&ocg->cg_btot[0]) - (char *)(&ocg->cg_link); + sumsize = &ocg->cg_iused[0] - (char *)(&ocg->cg_btot[0]); + mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] - + (u_char *)&ocg->cg_iused[0]; + ocg->cg_magic = CG_MAGIC; + savednrpos = fs->fs_nrpos; + fs->fs_nrpos = 8; + break; + + case FS_DYNAMICPOSTBLFMT: + newcg->cg_btotoff = + &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); + newcg->cg_boff = + newcg->cg_btotoff + fs->fs_cpg * sizeof(long); + newcg->cg_iusedoff = newcg->cg_boff + + fs->fs_cpg * fs->fs_nrpos * sizeof(short); + newcg->cg_freeoff = + newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY); + if (fs->fs_contigsumsize <= 0) { + newcg->cg_nextfreeoff = newcg->cg_freeoff + + howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY); + } else { + newcg->cg_clustersumoff = newcg->cg_freeoff + + howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY) - + sizeof(long); + newcg->cg_clustersumoff = + roundup(newcg->cg_clustersumoff, sizeof(long)); + newcg->cg_clusteroff = newcg->cg_clustersumoff + + (fs->fs_contigsumsize + 1) * sizeof(long); + newcg->cg_nextfreeoff = newcg->cg_clusteroff + + howmany(fs->fs_cpg * fs->fs_spc / NSPB(fs), NBBY); + } + newcg->cg_magic = CG_MAGIC; + basesize = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); + sumsize = newcg->cg_iusedoff - newcg->cg_btotoff; + mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff; + break; + + default: + errexit("UNKNOWN ROTATIONAL TABLE FORMAT %d\n", + fs->fs_postblformat); + } + bzero((char *)&idesc[0], sizeof idesc); + for (i = 0; i < 3; i++) { + idesc[i].id_type = ADDR; + if (doinglevel2) + idesc[i].id_fix = FIX; + } + bzero((char *)&cstotal, sizeof(struct csum)); + j = blknum(fs, fs->fs_size + fs->fs_frag - 1); + for (i = fs->fs_size; i < j; i++) + setbmap(i); + for (c = 0; c < fs->fs_ncg; c++) { + getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize); + if (!cg_chkmagic(cg)) + pfatal("CG %d: BAD MAGIC NUMBER\n", c); + dbase = cgbase(fs, c); + dmax = dbase + fs->fs_fpg; + if (dmax > fs->fs_size) + dmax = fs->fs_size; + newcg->cg_time = cg->cg_time; + newcg->cg_cgx = c; + if (c == fs->fs_ncg - 1) + newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg; + else + newcg->cg_ncyl = fs->fs_cpg; + newcg->cg_ndblk = dmax - dbase; + if (fs->fs_contigsumsize > 0) + newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag; + newcg->cg_cs.cs_ndir = 0; + newcg->cg_cs.cs_nffree = 0; + newcg->cg_cs.cs_nbfree = 0; + newcg->cg_cs.cs_nifree = fs->fs_ipg; + if (cg->cg_rotor < newcg->cg_ndblk) + newcg->cg_rotor = cg->cg_rotor; + else + newcg->cg_rotor = 0; + if (cg->cg_frotor < newcg->cg_ndblk) + newcg->cg_frotor = cg->cg_frotor; + else + newcg->cg_frotor = 0; + if (cg->cg_irotor < newcg->cg_niblk) + newcg->cg_irotor = cg->cg_irotor; + else + newcg->cg_irotor = 0; + bzero((char *)&newcg->cg_frsum[0], sizeof newcg->cg_frsum); + bzero((char *)&cg_blktot(newcg)[0], + (size_t)(sumsize + mapsize)); + if (fs->fs_postblformat == FS_42POSTBLFMT) + ocg->cg_magic = CG_MAGIC; + j = fs->fs_ipg * c; + for (i = 0; i < fs->fs_ipg; j++, i++) { + switch (statemap[j]) { + + case USTATE: + break; + + case DSTATE: + case DCLEAR: + case DFOUND: + newcg->cg_cs.cs_ndir++; + /* fall through */ + + case FSTATE: + case FCLEAR: + newcg->cg_cs.cs_nifree--; + setbit(cg_inosused(newcg), i); + break; + + default: + if (j < ROOTINO) + break; + errexit("BAD STATE %d FOR INODE I=%d", + statemap[j], j); + } + } + if (c == 0) + for (i = 0; i < ROOTINO; i++) { + setbit(cg_inosused(newcg), i); + newcg->cg_cs.cs_nifree--; + } + for (i = 0, d = dbase; + d < dmax; + d += fs->fs_frag, i += fs->fs_frag) { + frags = 0; + for (j = 0; j < fs->fs_frag; j++) { + if (testbmap(d + j)) + continue; + setbit(cg_blksfree(newcg), i + j); + frags++; + } + if (frags == fs->fs_frag) { + newcg->cg_cs.cs_nbfree++; + j = cbtocylno(fs, i); + cg_blktot(newcg)[j]++; + cg_blks(fs, newcg, j)[cbtorpos(fs, i)]++; + if (fs->fs_contigsumsize > 0) + setbit(cg_clustersfree(newcg), + i / fs->fs_frag); + } else if (frags > 0) { + newcg->cg_cs.cs_nffree += frags; + blk = blkmap(fs, cg_blksfree(newcg), i); + ffs_fragacct(fs, blk, newcg->cg_frsum, 1); + } + } + if (fs->fs_contigsumsize > 0) { + long *sump = cg_clustersum(newcg); + u_char *mapp = cg_clustersfree(newcg); + int map = *mapp++; + int bit = 1; + int run = 0; + + for (i = 0; i < newcg->cg_nclusterblks; i++) { + if ((map & bit) != 0) { + run++; + } else if (run != 0) { + if (run > fs->fs_contigsumsize) + run = fs->fs_contigsumsize; + sump[run]++; + run = 0; + } + if ((i & (NBBY - 1)) != (NBBY - 1)) { + bit <<= 1; + } else { + map = *mapp++; + bit = 1; + } + } + if (run != 0) { + if (run > fs->fs_contigsumsize) + run = fs->fs_contigsumsize; + sump[run]++; + } + } + cstotal.cs_nffree += newcg->cg_cs.cs_nffree; + cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; + cstotal.cs_nifree += newcg->cg_cs.cs_nifree; + cstotal.cs_ndir += newcg->cg_cs.cs_ndir; + cs = &fs->fs_cs(fs, c); + if (bcmp((char *)&newcg->cg_cs, (char *)cs, sizeof *cs) != 0 && + dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) { + bcopy((char *)&newcg->cg_cs, (char *)cs, sizeof *cs); + sbdirty(); + } + if (doinglevel1) { + bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize); + cgdirty(); + continue; + } + if (bcmp(cg_inosused(newcg), + cg_inosused(cg), mapsize) != 0 && + dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) { + bcopy(cg_inosused(newcg), cg_inosused(cg), + (size_t)mapsize); + cgdirty(); + } + if ((bcmp((char *)newcg, (char *)cg, basesize) != 0 || + bcmp((char *)&cg_blktot(newcg)[0], + (char *)&cg_blktot(cg)[0], sumsize) != 0) && + dofix(&idesc[2], "SUMMARY INFORMATION BAD")) { + bcopy((char *)newcg, (char *)cg, (size_t)basesize); + bcopy((char *)&cg_blktot(newcg)[0], + (char *)&cg_blktot(cg)[0], (size_t)sumsize); + cgdirty(); + } + } + if (fs->fs_postblformat == FS_42POSTBLFMT) + fs->fs_nrpos = savednrpos; + if (bcmp((char *)&cstotal, (char *)&fs->fs_cstotal, sizeof *cs) != 0 + && dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) { + bcopy((char *)&cstotal, (char *)&fs->fs_cstotal, sizeof *cs); + fs->fs_ronly = 0; + fs->fs_fmod = 0; + sbdirty(); + } +} diff --git a/bsdfsck/setup.c b/bsdfsck/setup.c new file mode 100644 index 00000000..475192cb --- /dev/null +++ b/bsdfsck/setup.c @@ -0,0 +1,467 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)setup.c 8.2 (Berkeley) 2/21/94";*/ +static char *rcsid = "$Id: setup.c,v 1.1 1994/08/23 19:29:25 mib Exp $"; +#endif /* not lint */ + +#define DKTYPENAMES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +struct bufarea asblk; +#define altsblock (*asblk.b_un.b_fs) +#define POWEROF2(num) (((num) & ((num) - 1)) == 0) + +struct disklabel *getdisklabel(); + +setup(dev) + char *dev; +{ + long cg, size, asked, i, j; + long bmapsize; + struct disklabel *lp; + off_t sizepb; + struct stat statb; + struct fs proto; + + havesb = 0; + fswritefd = -1; + if (stat(dev, &statb) < 0) { + printf("Can't stat %s: %s\n", dev, strerror(errno)); + return (0); + } + if ((statb.st_mode & S_IFMT) != S_IFCHR) { + pfatal("%s is not a character device", dev); + if (reply("CONTINUE") == 0) + return (0); + } + if ((fsreadfd = open(dev, O_RDONLY)) < 0) { + printf("Can't open %s: %s\n", dev, strerror(errno)); + return (0); + } + if (preen == 0) + printf("** %s", dev); + if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) { + fswritefd = -1; + if (preen) + pfatal("NO WRITE ACCESS"); + printf(" (NO WRITE)"); + } + if (preen == 0) + printf("\n"); + fsmodified = 0; + lfdir = 0; + initbarea(&sblk); + initbarea(&asblk); + sblk.b_un.b_buf = malloc(SBSIZE); + asblk.b_un.b_buf = malloc(SBSIZE); + if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) + errexit("cannot allocate space for superblock\n"); + if (lp = getdisklabel((char *)NULL, fsreadfd)) + dev_bsize = secsize = lp->d_secsize; + else + dev_bsize = secsize = DEV_BSIZE; + /* + * Read in the superblock, looking for alternates if necessary + */ + if (readsb(1) == 0) { + if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0) + return(0); + if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0) + return (0); + for (cg = 0; cg < proto.fs_ncg; cg++) { + bflag = fsbtodb(&proto, cgsblock(&proto, cg)); + if (readsb(0) != 0) + break; + } + if (cg >= proto.fs_ncg) { + printf("%s %s\n%s %s\n%s %s\n", + "SEARCH FOR ALTERNATE SUPER-BLOCK", + "FAILED. YOU MUST USE THE", + "-b OPTION TO FSCK TO SPECIFY THE", + "LOCATION OF AN ALTERNATE", + "SUPER-BLOCK TO SUPPLY NEEDED", + "INFORMATION; SEE fsck(8)."); + return(0); + } + pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); + } + maxfsblock = sblock.fs_size; + maxino = sblock.fs_ncg * sblock.fs_ipg; + /* + * Check and potentially fix certain fields in the super block. + */ + if (sblock.fs_optim != FS_OPTTIME && sblock.fs_optim != FS_OPTSPACE) { + pfatal("UNDEFINED OPTIMIZATION IN SUPERBLOCK"); + if (reply("SET TO DEFAULT") == 1) { + sblock.fs_optim = FS_OPTTIME; + sbdirty(); + } + } + if ((sblock.fs_minfree < 0 || sblock.fs_minfree > 99)) { + pfatal("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK", + sblock.fs_minfree); + if (reply("SET TO DEFAULT") == 1) { + sblock.fs_minfree = 10; + sbdirty(); + } + } + if (sblock.fs_interleave < 1 || + sblock.fs_interleave > sblock.fs_nsect) { + pwarn("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK", + sblock.fs_interleave); + sblock.fs_interleave = 1; + if (preen) + printf(" (FIXED)\n"); + if (preen || reply("SET TO DEFAULT") == 1) { + sbdirty(); + dirty(&asblk); + } + } + if (sblock.fs_npsect < sblock.fs_nsect || + sblock.fs_npsect > sblock.fs_nsect*2) { + pwarn("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK", + sblock.fs_npsect); + sblock.fs_npsect = sblock.fs_nsect; + if (preen) + printf(" (FIXED)\n"); + if (preen || reply("SET TO DEFAULT") == 1) { + sbdirty(); + dirty(&asblk); + } + } + if (sblock.fs_inodefmt >= FS_44INODEFMT) { + newinofmt = 1; + } else { + sblock.fs_qbmask = ~sblock.fs_bmask; + sblock.fs_qfmask = ~sblock.fs_fmask; + newinofmt = 0; + } + /* + * Convert to new inode format. + */ + if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) { + if (preen) + pwarn("CONVERTING TO NEW INODE FORMAT\n"); + else if (!reply("CONVERT TO NEW INODE FORMAT")) + return(0); + doinglevel2++; + sblock.fs_inodefmt = FS_44INODEFMT; + sizepb = sblock.fs_bsize; + sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1; + for (i = 0; i < NIADDR; i++) { + sizepb *= NINDIR(&sblock); + sblock.fs_maxfilesize += sizepb; + } + sblock.fs_maxsymlinklen = MAXSYMLINKLEN; + sblock.fs_qbmask = ~sblock.fs_bmask; + sblock.fs_qfmask = ~sblock.fs_fmask; + sbdirty(); + dirty(&asblk); + } + /* + * Convert to new cylinder group format. + */ + if (cvtlevel >= 1 && sblock.fs_postblformat == FS_42POSTBLFMT) { + if (preen) + pwarn("CONVERTING TO NEW CYLINDER GROUP FORMAT\n"); + else if (!reply("CONVERT TO NEW CYLINDER GROUP FORMAT")) + return(0); + doinglevel1++; + sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT; + sblock.fs_nrpos = 8; + sblock.fs_postbloff = + (char *)(&sblock.fs_opostbl[0][0]) - + (char *)(&sblock.fs_link); + sblock.fs_rotbloff = &sblock.fs_space[0] - + (u_char *)(&sblock.fs_link); + sblock.fs_cgsize = + fragroundup(&sblock, CGSIZE(&sblock)); + sbdirty(); + dirty(&asblk); + } + if (asblk.b_dirty && !bflag) { + bcopy((char *)&sblock, (char *)&altsblock, + (size_t)sblock.fs_sbsize); + flush(fswritefd, &asblk); + } + /* + * read in the summary info. + */ + asked = 0; + for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) { + size = sblock.fs_cssize - i < sblock.fs_bsize ? + sblock.fs_cssize - i : sblock.fs_bsize; + sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size); + if (bread(fsreadfd, (char *)sblock.fs_csp[j], + fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), + size) != 0 && !asked) { + pfatal("BAD SUMMARY INFORMATION"); + if (reply("CONTINUE") == 0) + errexit(""); + asked++; + } + } + /* + * allocate and initialize the necessary maps + */ + bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short)); + blockmap = calloc((unsigned)bmapsize, sizeof (char)); + if (blockmap == NULL) { + printf("cannot alloc %u bytes for blockmap\n", + (unsigned)bmapsize); + goto badsb; + } + statemap = calloc((unsigned)(maxino + 1), sizeof(char)); + if (statemap == NULL) { + printf("cannot alloc %u bytes for statemap\n", + (unsigned)(maxino + 1)); + goto badsb; + } + typemap = calloc((unsigned)(maxino + 1), sizeof(char)); + if (typemap == NULL) { + printf("cannot alloc %u bytes for typemap\n", + (unsigned)(maxino + 1)); + goto badsb; + } + lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short)); + if (lncntp == NULL) { + printf("cannot alloc %u bytes for lncntp\n", + (unsigned)(maxino + 1) * sizeof(short)); + goto badsb; + } + numdirs = sblock.fs_cstotal.cs_ndir; + inplast = 0; + listmax = numdirs + 10; + inpsort = (struct inoinfo **)calloc((unsigned)listmax, + sizeof(struct inoinfo *)); + inphead = (struct inoinfo **)calloc((unsigned)numdirs, + sizeof(struct inoinfo *)); + if (inpsort == NULL || inphead == NULL) { + printf("cannot alloc %u bytes for inphead\n", + (unsigned)numdirs * sizeof(struct inoinfo *)); + goto badsb; + } + bufinit(); + return (1); + +badsb: + ckfini(); + return (0); +} + +/* + * Read in the super block and its summary info. + */ +readsb(listerr) + int listerr; +{ + daddr_t super = bflag ? bflag : SBOFF / dev_bsize; + + if (bread(fsreadfd, (char *)&sblock, super, (long)SBSIZE) != 0) + return (0); + sblk.b_bno = super; + sblk.b_size = SBSIZE; + /* + * run a few consistency checks of the super block + */ + if (sblock.fs_magic != FS_MAGIC) + { badsb(listerr, "MAGIC NUMBER WRONG"); return (0); } + if (sblock.fs_ncg < 1) + { badsb(listerr, "NCG OUT OF RANGE"); return (0); } + if (sblock.fs_cpg < 1) + { badsb(listerr, "CPG OUT OF RANGE"); return (0); } + if (sblock.fs_ncg * sblock.fs_cpg < sblock.fs_ncyl || + (sblock.fs_ncg - 1) * sblock.fs_cpg >= sblock.fs_ncyl) + { badsb(listerr, "NCYL LESS THAN NCG*CPG"); return (0); } + if (sblock.fs_sbsize > SBSIZE) + { badsb(listerr, "SIZE PREPOSTEROUSLY LARGE"); return (0); } + /* + * Compute block size that the filesystem is based on, + * according to fsbtodb, and adjust superblock block number + * so we can tell if this is an alternate later. + */ + super *= dev_bsize; + dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1); + sblk.b_bno = super / dev_bsize; + if (bflag) { + havesb = 1; + return (1); + } + /* + * Set all possible fields that could differ, then do check + * of whole super block against an alternate super block. + * When an alternate super-block is specified this check is skipped. + */ + getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize); + if (asblk.b_errs) + return (0); + altsblock.fs_link = sblock.fs_link; + altsblock.fs_rlink = sblock.fs_rlink; + altsblock.fs_time = sblock.fs_time; + altsblock.fs_cstotal = sblock.fs_cstotal; + altsblock.fs_cgrotor = sblock.fs_cgrotor; + altsblock.fs_fmod = sblock.fs_fmod; + altsblock.fs_clean = sblock.fs_clean; + altsblock.fs_ronly = sblock.fs_ronly; + altsblock.fs_flags = sblock.fs_flags; + altsblock.fs_maxcontig = sblock.fs_maxcontig; + altsblock.fs_minfree = sblock.fs_minfree; + altsblock.fs_optim = sblock.fs_optim; + altsblock.fs_rotdelay = sblock.fs_rotdelay; + altsblock.fs_maxbpg = sblock.fs_maxbpg; + bcopy((char *)sblock.fs_csp, (char *)altsblock.fs_csp, + sizeof sblock.fs_csp); + bcopy((char *)sblock.fs_fsmnt, (char *)altsblock.fs_fsmnt, + sizeof sblock.fs_fsmnt); + bcopy((char *)sblock.fs_sparecon, (char *)altsblock.fs_sparecon, + sizeof sblock.fs_sparecon); + /* + * The following should not have to be copied. + */ + altsblock.fs_fsbtodb = sblock.fs_fsbtodb; + altsblock.fs_interleave = sblock.fs_interleave; + altsblock.fs_npsect = sblock.fs_npsect; + altsblock.fs_nrpos = sblock.fs_nrpos; + altsblock.fs_qbmask = sblock.fs_qbmask; + altsblock.fs_qfmask = sblock.fs_qfmask; + altsblock.fs_state = sblock.fs_state; + altsblock.fs_maxfilesize = sblock.fs_maxfilesize; + if (bcmp((char *)&sblock, (char *)&altsblock, (int)sblock.fs_sbsize)) { + badsb(listerr, + "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE"); + return (0); + } + havesb = 1; + return (1); +} + +badsb(listerr, s) + int listerr; + char *s; +{ + + if (!listerr) + return; + if (preen) + printf("%s: ", cdevname); + pfatal("BAD SUPER BLOCK: %s\n", s); +} + +/* + * Calculate a prototype superblock based on information in the disk label. + * When done the cgsblock macro can be calculated and the fs_ncg field + * can be used. Do NOT attempt to use other macros without verifying that + * their needed information is available! + */ +calcsb(dev, devfd, fs) + char *dev; + int devfd; + register struct fs *fs; +{ + register struct disklabel *lp; + register struct partition *pp; + register char *cp; + int i; + + cp = index(dev, '\0') - 1; + if (cp == (char *)-1 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) { + pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev); + return (0); + } + lp = getdisklabel(dev, devfd); + if (isdigit(*cp)) + pp = &lp->d_partitions[0]; + else + pp = &lp->d_partitions[*cp - 'a']; + if (pp->p_fstype != FS_BSDFFS) { + pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n", + dev, pp->p_fstype < FSMAXTYPES ? + fstypenames[pp->p_fstype] : "unknown"); + return (0); + } + bzero((char *)fs, sizeof(struct fs)); + fs->fs_fsize = pp->p_fsize; + fs->fs_frag = pp->p_frag; + fs->fs_cpg = pp->p_cpg; + fs->fs_size = pp->p_size; + fs->fs_ntrak = lp->d_ntracks; + fs->fs_nsect = lp->d_nsectors; + fs->fs_spc = lp->d_secpercyl; + fs->fs_nspf = fs->fs_fsize / lp->d_secsize; + fs->fs_sblkno = roundup( + howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize), + fs->fs_frag); + fs->fs_cgmask = 0xffffffff; + for (i = fs->fs_ntrak; i > 1; i >>= 1) + fs->fs_cgmask <<= 1; + if (!POWEROF2(fs->fs_ntrak)) + fs->fs_cgmask <<= 1; + fs->fs_cgoffset = roundup( + howmany(fs->fs_nsect, NSPF(fs)), fs->fs_frag); + fs->fs_fpg = (fs->fs_cpg * fs->fs_spc) / NSPF(fs); + fs->fs_ncg = howmany(fs->fs_size / fs->fs_spc, fs->fs_cpg); + for (fs->fs_fsbtodb = 0, i = NSPF(fs); i > 1; i >>= 1) + fs->fs_fsbtodb++; + dev_bsize = lp->d_secsize; + return (1); +} + +struct disklabel * +getdisklabel(s, fd) + char *s; + int fd; +{ + static struct disklabel lab; + + if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (s == NULL) + return ((struct disklabel *)NULL); + pwarn("ioctl (GCINFO): %s\n", strerror(errno)); + errexit("%s: can't read disk label\n", s); + } + return (&lab); +} diff --git a/bsdfsck/utilities.c b/bsdfsck/utilities.c new file mode 100644 index 00000000..5c31061c --- /dev/null +++ b/bsdfsck/utilities.c @@ -0,0 +1,567 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)utilities.c 8.1 (Berkeley) 6/5/93";*/ +static char *rcsid = "$Id: utilities.c,v 1.1 1994/08/23 19:29:26 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fsck.h" + +long diskreads, totalreads; /* Disk cache statistics */ + +ftypeok(dp) + struct dinode *dp; +{ + switch (dp->di_mode & IFMT) { + + case IFDIR: + case IFREG: + case IFBLK: + case IFCHR: + case IFLNK: + case IFSOCK: + case IFIFO: + return (1); + + default: + if (debug) + printf("bad file type 0%o\n", dp->di_mode); + return (0); + } +} + +reply(question) + char *question; +{ + int persevere; + char c; + + if (preen) + pfatal("INTERNAL ERROR: GOT TO reply()"); + persevere = !strcmp(question, "CONTINUE"); + printf("\n"); + if (!persevere && (nflag || fswritefd < 0)) { + printf("%s? no\n\n", question); + return (0); + } + if (yflag || (persevere && nflag)) { + printf("%s? yes\n\n", question); + return (1); + } + do { + printf("%s? [yn] ", question); + (void) fflush(stdout); + c = getc(stdin); + while (c != '\n' && getc(stdin) != '\n') + if (feof(stdin)) + return (0); + } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N'); + printf("\n"); + if (c == 'y' || c == 'Y') + return (1); + return (0); +} + +/* + * Malloc buffers and set up cache. + */ +bufinit() +{ + register struct bufarea *bp; + long bufcnt, i; + char *bufp; + + pbp = pdirbp = (struct bufarea *)0; + bufp = malloc((unsigned int)sblock.fs_bsize); + if (bufp == 0) + errexit("cannot allocate buffer pool\n"); + cgblk.b_un.b_buf = bufp; + initbarea(&cgblk); + bufhead.b_next = bufhead.b_prev = &bufhead; + bufcnt = MAXBUFSPACE / sblock.fs_bsize; + if (bufcnt < MINBUFS) + bufcnt = MINBUFS; + for (i = 0; i < bufcnt; i++) { + bp = (struct bufarea *)malloc(sizeof(struct bufarea)); + bufp = malloc((unsigned int)sblock.fs_bsize); + if (bp == NULL || bufp == NULL) { + if (i >= MINBUFS) + break; + errexit("cannot allocate buffer pool\n"); + } + bp->b_un.b_buf = bufp; + bp->b_prev = &bufhead; + bp->b_next = bufhead.b_next; + bufhead.b_next->b_prev = bp; + bufhead.b_next = bp; + initbarea(bp); + } + bufhead.b_size = i; /* save number of buffers */ +} + +/* + * Manage a cache of directory blocks. + */ +struct bufarea * +getdatablk(blkno, size) + daddr_t blkno; + long size; +{ + register struct bufarea *bp; + + for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next) + if (bp->b_bno == fsbtodb(&sblock, blkno)) + goto foundit; + for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev) + if ((bp->b_flags & B_INUSE) == 0) + break; + if (bp == &bufhead) + errexit("deadlocked buffer pool\n"); + getblk(bp, blkno, size); + /* fall through */ +foundit: + totalreads++; + bp->b_prev->b_next = bp->b_next; + bp->b_next->b_prev = bp->b_prev; + bp->b_prev = &bufhead; + bp->b_next = bufhead.b_next; + bufhead.b_next->b_prev = bp; + bufhead.b_next = bp; + bp->b_flags |= B_INUSE; + return (bp); +} + +void +getblk(bp, blk, size) + register struct bufarea *bp; + daddr_t blk; + long size; +{ + daddr_t dblk; + + dblk = fsbtodb(&sblock, blk); + if (bp->b_bno != dblk) { + flush(fswritefd, bp); + diskreads++; + bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size); + bp->b_bno = dblk; + bp->b_size = size; + } +} + +flush(fd, bp) + int fd; + register struct bufarea *bp; +{ + register int i, j; + + if (!bp->b_dirty) + return; + if (bp->b_errs != 0) + pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n", + (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ", + bp->b_bno); + bp->b_dirty = 0; + bp->b_errs = 0; + bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size); + if (bp != &sblk) + return; + for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) { + bwrite(fswritefd, (char *)sblock.fs_csp[j], + fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), + sblock.fs_cssize - i < sblock.fs_bsize ? + sblock.fs_cssize - i : sblock.fs_bsize); + } +} + +rwerror(mesg, blk) + char *mesg; + daddr_t blk; +{ + + if (preen == 0) + printf("\n"); + pfatal("CANNOT %s: BLK %ld", mesg, blk); + if (reply("CONTINUE") == 0) + errexit("Program terminated\n"); +} + +ckfini() +{ + register struct bufarea *bp, *nbp; + int cnt = 0; + + if (fswritefd < 0) { + (void)close(fsreadfd); + return; + } + flush(fswritefd, &sblk); + if (havesb && sblk.b_bno != SBOFF / dev_bsize && + !preen && reply("UPDATE STANDARD SUPERBLOCK")) { + sblk.b_bno = SBOFF / dev_bsize; + sbdirty(); + flush(fswritefd, &sblk); + } + flush(fswritefd, &cgblk); + free(cgblk.b_un.b_buf); + for (bp = bufhead.b_prev; bp && bp != &bufhead; bp = nbp) { + cnt++; + flush(fswritefd, bp); + nbp = bp->b_prev; + free(bp->b_un.b_buf); + free((char *)bp); + } + if (bufhead.b_size != cnt) + errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt); + pbp = pdirbp = (struct bufarea *)0; + if (debug) + printf("cache missed %ld of %ld (%d%%)\n", diskreads, + totalreads, (int)(diskreads * 100 / totalreads)); + (void)close(fsreadfd); + (void)close(fswritefd); +} + +bread(fd, buf, blk, size) + int fd; + char *buf; + daddr_t blk; + long size; +{ + char *cp; + int i, errs; + off_t offset; + + offset = blk; + offset *= dev_bsize; + if (lseek(fd, offset, 0) < 0) + rwerror("SEEK", blk); + else if (read(fd, buf, (int)size) == size) + return (0); + rwerror("READ", blk); + if (lseek(fd, offset, 0) < 0) + rwerror("SEEK", blk); + errs = 0; + bzero(buf, (size_t)size); + printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:"); + for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) { + if (read(fd, cp, (int)secsize) != secsize) { + (void)lseek(fd, offset + i + secsize, 0); + if (secsize != dev_bsize && dev_bsize != 1) + printf(" %ld (%ld),", + (blk * dev_bsize + i) / secsize, + blk + i / dev_bsize); + else + printf(" %ld,", blk + i / dev_bsize); + errs++; + } + } + printf("\n"); + return (errs); +} + +bwrite(fd, buf, blk, size) + int fd; + char *buf; + daddr_t blk; + long size; +{ + int i; + char *cp; + off_t offset; + + if (fd < 0) + return; + offset = blk; + offset *= dev_bsize; + if (lseek(fd, offset, 0) < 0) + rwerror("SEEK", blk); + else if (write(fd, buf, (int)size) == size) { + fsmodified = 1; + return; + } + rwerror("WRITE", blk); + if (lseek(fd, offset, 0) < 0) + rwerror("SEEK", blk); + printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:"); + for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize) + if (write(fd, cp, (int)dev_bsize) != dev_bsize) { + (void)lseek(fd, offset + i + dev_bsize, 0); + printf(" %ld,", blk + i / dev_bsize); + } + printf("\n"); + return; +} + +/* + * allocate a data block with the specified number of fragments + */ +allocblk(frags) + long frags; +{ + register int i, j, k; + + if (frags <= 0 || frags > sblock.fs_frag) + return (0); + for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) { + for (j = 0; j <= sblock.fs_frag - frags; j++) { + if (testbmap(i + j)) + continue; + for (k = 1; k < frags; k++) + if (testbmap(i + j + k)) + break; + if (k < frags) { + j += k; + continue; + } + for (k = 0; k < frags; k++) + setbmap(i + j + k); + n_blks += frags; + return (i + j); + } + } + return (0); +} + +/* + * Free a previously allocated block + */ +freeblk(blkno, frags) + daddr_t blkno; + long frags; +{ + struct inodesc idesc; + + idesc.id_blkno = blkno; + idesc.id_numfrags = frags; + (void)pass4check(&idesc); +} + +/* + * Find a pathname + */ +getpathname(namebuf, curdir, ino) + char *namebuf; + ino_t curdir, ino; +{ + int len; + register char *cp; + struct inodesc idesc; + static int busy = 0; + extern int findname(); + + if (curdir == ino && ino == ROOTINO) { + (void)strcpy(namebuf, "/"); + return; + } + if (busy || + (statemap[curdir] != DSTATE && statemap[curdir] != DFOUND)) { + (void)strcpy(namebuf, "?"); + return; + } + busy = 1; + bzero((char *)&idesc, sizeof(struct inodesc)); + idesc.id_type = DATA; + idesc.id_fix = IGNORE; + cp = &namebuf[MAXPATHLEN - 1]; + *cp = '\0'; + if (curdir != ino) { + idesc.id_parent = curdir; + goto namelookup; + } + while (ino != ROOTINO) { + idesc.id_number = ino; + idesc.id_func = findino; + idesc.id_name = ".."; + if ((ckinode(ginode(ino), &idesc) & FOUND) == 0) + break; + namelookup: + idesc.id_number = idesc.id_parent; + idesc.id_parent = ino; + idesc.id_func = findname; + idesc.id_name = namebuf; + if ((ckinode(ginode(idesc.id_number), &idesc)&FOUND) == 0) + break; + len = strlen(namebuf); + cp -= len; + bcopy(namebuf, cp, (size_t)len); + *--cp = '/'; + if (cp < &namebuf[MAXNAMLEN]) + break; + ino = idesc.id_number; + } + busy = 0; + if (ino != ROOTINO) + *--cp = '?'; + bcopy(cp, namebuf, (size_t)(&namebuf[MAXPATHLEN] - cp)); +} + +void +catch() +{ + if (!doinglevel2) + ckfini(); + exit(12); +} + +/* + * When preening, allow a single quit to signal + * a special exit after filesystem checks complete + * so that reboot sequence may be interrupted. + */ +void +catchquit() +{ + extern returntosingle; + + printf("returning to single-user after filesystem check\n"); + returntosingle = 1; + (void)signal(SIGQUIT, SIG_DFL); +} + +/* + * Ignore a single quit signal; wait and flush just in case. + * Used by child processes in preen. + */ +void +voidquit() +{ + + sleep(1); + (void)signal(SIGQUIT, SIG_IGN); + (void)signal(SIGQUIT, SIG_DFL); +} + +/* + * determine whether an inode should be fixed. + */ +dofix(idesc, msg) + register struct inodesc *idesc; + char *msg; +{ + + switch (idesc->id_fix) { + + case DONTKNOW: + if (idesc->id_type == DATA) + direrror(idesc->id_number, msg); + else + pwarn(msg); + if (preen) { + printf(" (SALVAGED)\n"); + idesc->id_fix = FIX; + return (ALTERED); + } + if (reply("SALVAGE") == 0) { + idesc->id_fix = NOFIX; + return (0); + } + idesc->id_fix = FIX; + return (ALTERED); + + case FIX: + return (ALTERED); + + case NOFIX: + case IGNORE: + return (0); + + default: + errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix); + } + /* NOTREACHED */ +} + +/* VARARGS1 */ +errexit(s1, s2, s3, s4) + char *s1; +{ + printf(s1, s2, s3, s4); + exit(8); +} + +/* + * An unexpected inconsistency occured. + * Die if preening, otherwise just print message and continue. + */ +/* VARARGS1 */ +pfatal(s, a1, a2, a3) + char *s; +{ + + if (preen) { + printf("%s: ", cdevname); + printf(s, a1, a2, a3); + printf("\n"); + printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n", + cdevname); + exit(8); + } + printf(s, a1, a2, a3); +} + +/* + * Pwarn just prints a message when not preening, + * or a warning (preceded by filename) when preening. + */ +/* VARARGS1 */ +pwarn(s, a1, a2, a3, a4, a5, a6) + char *s; +{ + + if (preen) + printf("%s: ", cdevname); + printf(s, a1, a2, a3, a4, a5, a6); +} + +#ifndef lint +/* + * Stub for routines from kernel. + */ +panic(s) + char *s; +{ + + pfatal("INTERNAL INCONSISTENCY:"); + errexit(s); +} +#endif diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile new file mode 100644 index 00000000..4cc571a1 --- /dev/null +++ b/ufs-utils/Makefile @@ -0,0 +1,15 @@ +# from: @(#)Makefile 8.2 (Berkeley) 3/27/94 +# $Id: Makefile,v 1.1 1994/08/23 19:30:43 mib Exp $ + +PROG= newfs +SRCS= dkcksum.c getmntopts.c newfs.c mkfs.c +MAN8= newfs.0 + +MOUNT= ${.CURDIR}/../mount +CFLAGS+=-DMFS -I${MOUNT} +.PATH: ${MOUNT} ${.CURDIR}/../disklabel + +LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs +MLINKS= newfs.8 mount_mfs.8 newfs.8 mfs.8 + +.include diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c new file mode 100644 index 00000000..d35dd10b --- /dev/null +++ b/ufs-utils/mkfs.c @@ -0,0 +1,1229 @@ +/* + * Copyright (c) 1980, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ +static char *rcsid = "$Id: mkfs.c,v 1.1 1994/08/23 19:30:42 mib Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef STANDALONE +#include +#include +#endif + +/* + * make file system for cylinder-group style file systems + */ + +/* + * We limit the size of the inode map to be no more than a + * third of the cylinder group space, since we must leave at + * least an equal amount of space for the block map. + * + * N.B.: MAXIPG must be a multiple of INOPB(fs). + */ +#define MAXIPG(fs) roundup((fs)->fs_bsize * NBBY / 3, INOPB(fs)) + +#define UMASK 0755 +#define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) +#define POWEROF2(num) (((num) & ((num) - 1)) == 0) + +/* + * variables set up by front end. + */ +extern int mfs; /* run as the memory based filesystem */ +extern int Nflag; /* run mkfs without writing file system */ +extern int Oflag; /* format as an 4.3BSD file system */ +extern int fssize; /* file system size */ +extern int ntracks; /* # tracks/cylinder */ +extern int nsectors; /* # sectors/track */ +extern int nphyssectors; /* # sectors/track including spares */ +extern int secpercyl; /* sectors per cylinder */ +extern int sectorsize; /* bytes/sector */ +extern int rpm; /* revolutions/minute of drive */ +extern int interleave; /* hardware sector interleave */ +extern int trackskew; /* sector 0 skew, per track */ +extern int headswitch; /* head switch time, usec */ +extern int trackseek; /* track-to-track seek, usec */ +extern int fsize; /* fragment size */ +extern int bsize; /* block size */ +extern int cpg; /* cylinders/cylinder group */ +extern int cpgflg; /* cylinders/cylinder group flag was given */ +extern int minfree; /* free space threshold */ +extern int opt; /* optimization preference (space or time) */ +extern int density; /* number of bytes per inode */ +extern int maxcontig; /* max contiguous blocks to allocate */ +extern int rotdelay; /* rotational delay between blocks */ +extern int maxbpg; /* maximum blocks per file in a cyl group */ +extern int nrpos; /* # of distinguished rotational positions */ +extern int bbsize; /* boot block size */ +extern int sbsize; /* superblock size */ +extern u_long memleft; /* virtual memory available */ +extern caddr_t membase; /* start address of memory based filesystem */ +extern caddr_t malloc(), calloc(); + +union { + struct fs fs; + char pad[SBSIZE]; +} fsun; +#define sblock fsun.fs +struct csum *fscs; + +union { + struct cg cg; + char pad[MAXBSIZE]; +} cgun; +#define acg cgun.cg + +struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; + +int fsi, fso; +daddr_t alloc(); + +mkfs(pp, fsys, fi, fo) + struct partition *pp; + char *fsys; + int fi, fo; +{ + register long i, mincpc, mincpg, inospercg; + long cylno, rpos, blk, j, warn = 0; + long used, mincpgcnt, bpcg; + long mapcramped, inodecramped; + long postblsize, rotblsize, totalsbsize; + int ppid, status; + time_t utime; + quad_t sizepb; + void started(); + +#ifndef STANDALONE + time(&utime); +#endif + if (mfs) { + ppid = getpid(); + (void) signal(SIGUSR1, started); + if (i = fork()) { + if (i == -1) { + perror("mfs"); + exit(10); + } + if (waitpid(i, &status, 0) != -1 && WIFEXITED(status)) + exit(WEXITSTATUS(status)); + exit(11); + /* NOTREACHED */ + } + (void)malloc(0); + if (fssize * sectorsize > memleft) + fssize = (memleft - 16384) / sectorsize; + if ((membase = malloc(fssize * sectorsize)) == 0) + exit(12); + } + fsi = fi; + fso = fo; + if (Oflag) { + sblock.fs_inodefmt = FS_42INODEFMT; + sblock.fs_maxsymlinklen = 0; + } else { + sblock.fs_inodefmt = FS_44INODEFMT; + sblock.fs_maxsymlinklen = MAXSYMLINKLEN; + } + /* + * Validate the given file system size. + * Verify that its last block can actually be accessed. + */ + if (fssize <= 0) + printf("preposterous size %d\n", fssize), exit(13); + wtfs(fssize - 1, sectorsize, (char *)&sblock); + /* + * collect and verify the sector and track info + */ + sblock.fs_nsect = nsectors; + sblock.fs_ntrak = ntracks; + if (sblock.fs_ntrak <= 0) + printf("preposterous ntrak %d\n", sblock.fs_ntrak), exit(14); + if (sblock.fs_nsect <= 0) + printf("preposterous nsect %d\n", sblock.fs_nsect), exit(15); + /* + * collect and verify the block and fragment sizes + */ + sblock.fs_bsize = bsize; + sblock.fs_fsize = fsize; + if (!POWEROF2(sblock.fs_bsize)) { + printf("block size must be a power of 2, not %d\n", + sblock.fs_bsize); + exit(16); + } + if (!POWEROF2(sblock.fs_fsize)) { + printf("fragment size must be a power of 2, not %d\n", + sblock.fs_fsize); + exit(17); + } + if (sblock.fs_fsize < sectorsize) { + printf("fragment size %d is too small, minimum is %d\n", + sblock.fs_fsize, sectorsize); + exit(18); + } + if (sblock.fs_bsize < MINBSIZE) { + printf("block size %d is too small, minimum is %d\n", + sblock.fs_bsize, MINBSIZE); + exit(19); + } + if (sblock.fs_bsize < sblock.fs_fsize) { + printf("block size (%d) cannot be smaller than fragment size (%d)\n", + sblock.fs_bsize, sblock.fs_fsize); + exit(20); + } + sblock.fs_bmask = ~(sblock.fs_bsize - 1); + sblock.fs_fmask = ~(sblock.fs_fsize - 1); + sblock.fs_qbmask = ~sblock.fs_bmask; + sblock.fs_qfmask = ~sblock.fs_fmask; + for (sblock.fs_bshift = 0, i = sblock.fs_bsize; i > 1; i >>= 1) + sblock.fs_bshift++; + for (sblock.fs_fshift = 0, i = sblock.fs_fsize; i > 1; i >>= 1) + sblock.fs_fshift++; + sblock.fs_frag = numfrags(&sblock, sblock.fs_bsize); + for (sblock.fs_fragshift = 0, i = sblock.fs_frag; i > 1; i >>= 1) + sblock.fs_fragshift++; + if (sblock.fs_frag > MAXFRAG) { + printf("fragment size %d is too small, minimum with block size %d is %d\n", + sblock.fs_fsize, sblock.fs_bsize, + sblock.fs_bsize / MAXFRAG); + exit(21); + } + sblock.fs_nrpos = nrpos; + sblock.fs_nindir = sblock.fs_bsize / sizeof(daddr_t); + sblock.fs_inopb = sblock.fs_bsize / sizeof(struct dinode); + sblock.fs_nspf = sblock.fs_fsize / sectorsize; + for (sblock.fs_fsbtodb = 0, i = NSPF(&sblock); i > 1; i >>= 1) + sblock.fs_fsbtodb++; + sblock.fs_sblkno = + roundup(howmany(bbsize + sbsize, sblock.fs_fsize), sblock.fs_frag); + sblock.fs_cblkno = (daddr_t)(sblock.fs_sblkno + + roundup(howmany(sbsize, sblock.fs_fsize), sblock.fs_frag)); + sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag; + sblock.fs_cgoffset = roundup( + howmany(sblock.fs_nsect, NSPF(&sblock)), sblock.fs_frag); + for (sblock.fs_cgmask = 0xffffffff, i = sblock.fs_ntrak; i > 1; i >>= 1) + sblock.fs_cgmask <<= 1; + if (!POWEROF2(sblock.fs_ntrak)) + sblock.fs_cgmask <<= 1; + sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1; + for (sizepb = sblock.fs_bsize, i = 0; i < NIADDR; i++) { + sizepb *= NINDIR(&sblock); + sblock.fs_maxfilesize += sizepb; + } + /* + * Validate specified/determined secpercyl + * and calculate minimum cylinders per group. + */ + sblock.fs_spc = secpercyl; + for (sblock.fs_cpc = NSPB(&sblock), i = sblock.fs_spc; + sblock.fs_cpc > 1 && (i & 1) == 0; + sblock.fs_cpc >>= 1, i >>= 1) + /* void */; + mincpc = sblock.fs_cpc; + bpcg = sblock.fs_spc * sectorsize; + inospercg = roundup(bpcg / sizeof(struct dinode), INOPB(&sblock)); + if (inospercg > MAXIPG(&sblock)) + inospercg = MAXIPG(&sblock); + used = (sblock.fs_iblkno + inospercg / INOPF(&sblock)) * NSPF(&sblock); + mincpgcnt = howmany(sblock.fs_cgoffset * (~sblock.fs_cgmask) + used, + sblock.fs_spc); + mincpg = roundup(mincpgcnt, mincpc); + /* + * Ensure that cylinder group with mincpg has enough space + * for block maps. + */ + sblock.fs_cpg = mincpg; + sblock.fs_ipg = inospercg; + if (maxcontig > 1) + sblock.fs_contigsumsize = MIN(maxcontig, FS_MAXCONTIG); + mapcramped = 0; + while (CGSIZE(&sblock) > sblock.fs_bsize) { + mapcramped = 1; + if (sblock.fs_bsize < MAXBSIZE) { + sblock.fs_bsize <<= 1; + if ((i & 1) == 0) { + i >>= 1; + } else { + sblock.fs_cpc <<= 1; + mincpc <<= 1; + mincpg = roundup(mincpgcnt, mincpc); + sblock.fs_cpg = mincpg; + } + sblock.fs_frag <<= 1; + sblock.fs_fragshift += 1; + if (sblock.fs_frag <= MAXFRAG) + continue; + } + if (sblock.fs_fsize == sblock.fs_bsize) { + printf("There is no block size that"); + printf(" can support this disk\n"); + exit(22); + } + sblock.fs_frag >>= 1; + sblock.fs_fragshift -= 1; + sblock.fs_fsize <<= 1; + sblock.fs_nspf <<= 1; + } + /* + * Ensure that cylinder group with mincpg has enough space for inodes. + */ + inodecramped = 0; + used *= sectorsize; + inospercg = roundup((mincpg * bpcg - used) / density, INOPB(&sblock)); + sblock.fs_ipg = inospercg; + while (inospercg > MAXIPG(&sblock)) { + inodecramped = 1; + if (mincpc == 1 || sblock.fs_frag == 1 || + sblock.fs_bsize == MINBSIZE) + break; + printf("With a block size of %d %s %d\n", sblock.fs_bsize, + "minimum bytes per inode is", + (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); + sblock.fs_bsize >>= 1; + sblock.fs_frag >>= 1; + sblock.fs_fragshift -= 1; + mincpc >>= 1; + sblock.fs_cpg = roundup(mincpgcnt, mincpc); + if (CGSIZE(&sblock) > sblock.fs_bsize) { + sblock.fs_bsize <<= 1; + break; + } + mincpg = sblock.fs_cpg; + inospercg = + roundup((mincpg * bpcg - used) / density, INOPB(&sblock)); + sblock.fs_ipg = inospercg; + } + if (inodecramped) { + if (inospercg > MAXIPG(&sblock)) { + printf("Minimum bytes per inode is %d\n", + (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); + } else if (!mapcramped) { + printf("With %d bytes per inode, ", density); + printf("minimum cylinders per group is %d\n", mincpg); + } + } + if (mapcramped) { + printf("With %d sectors per cylinder, ", sblock.fs_spc); + printf("minimum cylinders per group is %d\n", mincpg); + } + if (inodecramped || mapcramped) { + if (sblock.fs_bsize != bsize) + printf("%s to be changed from %d to %d\n", + "This requires the block size", + bsize, sblock.fs_bsize); + if (sblock.fs_fsize != fsize) + printf("\t%s to be changed from %d to %d\n", + "and the fragment size", + fsize, sblock.fs_fsize); + exit(23); + } + /* + * Calculate the number of cylinders per group + */ + sblock.fs_cpg = cpg; + if (sblock.fs_cpg % mincpc != 0) { + printf("%s groups must have a multiple of %d cylinders\n", + cpgflg ? "Cylinder" : "Warning: cylinder", mincpc); + sblock.fs_cpg = roundup(sblock.fs_cpg, mincpc); + if (!cpgflg) + cpg = sblock.fs_cpg; + } + /* + * Must ensure there is enough space for inodes. + */ + sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density, + INOPB(&sblock)); + while (sblock.fs_ipg > MAXIPG(&sblock)) { + inodecramped = 1; + sblock.fs_cpg -= mincpc; + sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density, + INOPB(&sblock)); + } + /* + * Must ensure there is enough space to hold block map. + */ + while (CGSIZE(&sblock) > sblock.fs_bsize) { + mapcramped = 1; + sblock.fs_cpg -= mincpc; + sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density, + INOPB(&sblock)); + } + sblock.fs_fpg = (sblock.fs_cpg * sblock.fs_spc) / NSPF(&sblock); + if ((sblock.fs_cpg * sblock.fs_spc) % NSPB(&sblock) != 0) { + printf("panic (fs_cpg * fs_spc) % NSPF != 0"); + exit(24); + } + if (sblock.fs_cpg < mincpg) { + printf("cylinder groups must have at least %d cylinders\n", + mincpg); + exit(25); + } else if (sblock.fs_cpg != cpg) { + if (!cpgflg) + printf("Warning: "); + else if (!mapcramped && !inodecramped) + exit(26); + if (mapcramped && inodecramped) + printf("Block size and bytes per inode restrict"); + else if (mapcramped) + printf("Block size restricts"); + else + printf("Bytes per inode restrict"); + printf(" cylinders per group to %d.\n", sblock.fs_cpg); + if (cpgflg) + exit(27); + } + sblock.fs_cgsize = fragroundup(&sblock, CGSIZE(&sblock)); + /* + * Now have size for file system and nsect and ntrak. + * Determine number of cylinders and blocks in the file system. + */ + sblock.fs_size = fssize = dbtofsb(&sblock, fssize); + sblock.fs_ncyl = fssize * NSPF(&sblock) / sblock.fs_spc; + if (fssize * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) { + sblock.fs_ncyl++; + warn = 1; + } + if (sblock.fs_ncyl < 1) { + printf("file systems must have at least one cylinder\n"); + exit(28); + } + /* + * Determine feasability/values of rotational layout tables. + * + * The size of the rotational layout tables is limited by the + * size of the superblock, SBSIZE. The amount of space available + * for tables is calculated as (SBSIZE - sizeof (struct fs)). + * The size of these tables is inversely proportional to the block + * size of the file system. The size increases if sectors per track + * are not powers of two, because more cylinders must be described + * by the tables before the rotational pattern repeats (fs_cpc). + */ + sblock.fs_interleave = interleave; + sblock.fs_trackskew = trackskew; + sblock.fs_npsect = nphyssectors; + sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT; + sblock.fs_sbsize = fragroundup(&sblock, sizeof(struct fs)); + if (sblock.fs_ntrak == 1) { + sblock.fs_cpc = 0; + goto next; + } + postblsize = sblock.fs_nrpos * sblock.fs_cpc * sizeof(short); + rotblsize = sblock.fs_cpc * sblock.fs_spc / NSPB(&sblock); + totalsbsize = sizeof(struct fs) + rotblsize; + if (sblock.fs_nrpos == 8 && sblock.fs_cpc <= 16) { + /* use old static table space */ + sblock.fs_postbloff = (char *)(&sblock.fs_opostbl[0][0]) - + (char *)(&sblock.fs_link); + sblock.fs_rotbloff = &sblock.fs_space[0] - + (u_char *)(&sblock.fs_link); + } else { + /* use dynamic table space */ + sblock.fs_postbloff = &sblock.fs_space[0] - + (u_char *)(&sblock.fs_link); + sblock.fs_rotbloff = sblock.fs_postbloff + postblsize; + totalsbsize += postblsize; + } + if (totalsbsize > SBSIZE || + sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) { + printf("%s %s %d %s %d.%s", + "Warning: insufficient space in super block for\n", + "rotational layout tables with nsect", sblock.fs_nsect, + "and ntrak", sblock.fs_ntrak, + "\nFile system performance may be impaired.\n"); + sblock.fs_cpc = 0; + goto next; + } + sblock.fs_sbsize = fragroundup(&sblock, totalsbsize); + /* + * calculate the available blocks for each rotational position + */ + for (cylno = 0; cylno < sblock.fs_cpc; cylno++) + for (rpos = 0; rpos < sblock.fs_nrpos; rpos++) + fs_postbl(&sblock, cylno)[rpos] = -1; + for (i = (rotblsize - 1) * sblock.fs_frag; + i >= 0; i -= sblock.fs_frag) { + cylno = cbtocylno(&sblock, i); + rpos = cbtorpos(&sblock, i); + blk = fragstoblks(&sblock, i); + if (fs_postbl(&sblock, cylno)[rpos] == -1) + fs_rotbl(&sblock)[blk] = 0; + else + fs_rotbl(&sblock)[blk] = + fs_postbl(&sblock, cylno)[rpos] - blk; + fs_postbl(&sblock, cylno)[rpos] = blk; + } +next: + /* + * Compute/validate number of cylinder groups. + */ + sblock.fs_ncg = sblock.fs_ncyl / sblock.fs_cpg; + if (sblock.fs_ncyl % sblock.fs_cpg) + sblock.fs_ncg++; + sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(&sblock); + i = MIN(~sblock.fs_cgmask, sblock.fs_ncg - 1); + if (cgdmin(&sblock, i) - cgbase(&sblock, i) >= sblock.fs_fpg) { + printf("inode blocks/cyl group (%d) >= data blocks (%d)\n", + cgdmin(&sblock, i) - cgbase(&sblock, i) / sblock.fs_frag, + sblock.fs_fpg / sblock.fs_frag); + printf("number of cylinders per cylinder group (%d) %s.\n", + sblock.fs_cpg, "must be increased"); + exit(29); + } + j = sblock.fs_ncg - 1; + if ((i = fssize - j * sblock.fs_fpg) < sblock.fs_fpg && + cgdmin(&sblock, j) - cgbase(&sblock, j) > i) { + if (j == 0) { + printf("Filesystem must have at least %d sectors\n", + NSPF(&sblock) * + (cgdmin(&sblock, 0) + 3 * sblock.fs_frag)); + exit(30); + } + printf("Warning: inode blocks/cyl group (%d) >= data blocks (%d) in last\n", + (cgdmin(&sblock, j) - cgbase(&sblock, j)) / sblock.fs_frag, + i / sblock.fs_frag); + printf(" cylinder group. This implies %d sector(s) cannot be allocated.\n", + i * NSPF(&sblock)); + sblock.fs_ncg--; + sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; + sblock.fs_size = fssize = sblock.fs_ncyl * sblock.fs_spc / + NSPF(&sblock); + warn = 0; + } + if (warn && !mfs) { + printf("Warning: %d sector(s) in last cylinder unallocated\n", + sblock.fs_spc - + (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) + * sblock.fs_spc)); + } + /* + * fill in remaining fields of the super block + */ + sblock.fs_csaddr = cgdmin(&sblock, 0); + sblock.fs_cssize = + fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum)); + i = sblock.fs_bsize / sizeof(struct csum); + sblock.fs_csmask = ~(i - 1); + for (sblock.fs_csshift = 0; i > 1; i >>= 1) + sblock.fs_csshift++; + fscs = (struct csum *)calloc(1, sblock.fs_cssize); + sblock.fs_magic = FS_MAGIC; + sblock.fs_rotdelay = rotdelay; + sblock.fs_minfree = minfree; + sblock.fs_maxcontig = maxcontig; + sblock.fs_headswitch = headswitch; + sblock.fs_trkseek = trackseek; + sblock.fs_maxbpg = maxbpg; + sblock.fs_rps = rpm / 60; + sblock.fs_optim = opt; + sblock.fs_cgrotor = 0; + sblock.fs_cstotal.cs_ndir = 0; + sblock.fs_cstotal.cs_nbfree = 0; + sblock.fs_cstotal.cs_nifree = 0; + sblock.fs_cstotal.cs_nffree = 0; + sblock.fs_fmod = 0; + sblock.fs_ronly = 0; + /* + * Dump out summary information about file system. + */ + if (!mfs) { + printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", + fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, + "cylinders", sblock.fs_ntrak, sblock.fs_nsect); +#define B2MBFACTOR (1 / (1024.0 * 1024.0)) + printf("\t%.1fMB in %d cyl groups (%d c/g, %.2fMB/g, %d i/g)\n", + (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, + sblock.fs_ncg, sblock.fs_cpg, + (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR, + sblock.fs_ipg); +#undef B2MBFACTOR + } + /* + * Now build the cylinders group blocks and + * then print out indices of cylinder groups. + */ + if (!mfs) + printf("super-block backups (for fsck -b #) at:"); + for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { + initcg(cylno, utime); + if (mfs) + continue; + if (cylno % 8 == 0) + printf("\n"); + printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); + } + if (!mfs) + printf("\n"); + if (Nflag && !mfs) + exit(0); + /* + * Now construct the initial file system, + * then write out the super-block. + */ + fsinit(utime); + sblock.fs_time = utime; + wtfs((int)SBOFF / sectorsize, sbsize, (char *)&sblock); + for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) + wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), + sblock.fs_cssize - i < sblock.fs_bsize ? + sblock.fs_cssize - i : sblock.fs_bsize, + ((char *)fscs) + i); + /* + * Write out the duplicate super blocks + */ + for (cylno = 0; cylno < sblock.fs_ncg; cylno++) + wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), + sbsize, (char *)&sblock); + /* + * Update information about this partion in pack + * label, to that it may be updated on disk. + */ + pp->p_fstype = FS_BSDFFS; + pp->p_fsize = sblock.fs_fsize; + pp->p_frag = sblock.fs_frag; + pp->p_cpg = sblock.fs_cpg; + /* + * Notify parent process of success. + * Dissociate from session and tty. + */ + if (mfs) { + kill(ppid, SIGUSR1); + (void) setsid(); + (void) close(0); + (void) close(1); + (void) close(2); + (void) chdir("/"); + } +} + +/* + * Initialize a cylinder group. + */ +initcg(cylno, utime) + int cylno; + time_t utime; +{ + daddr_t cbase, d, dlower, dupper, dmax, blkno; + long i, j, s; + register struct csum *cs; + + /* + * Determine block bounds for cylinder group. + * Allow space for super block summary information in first + * cylinder group. + */ + cbase = cgbase(&sblock, cylno); + dmax = cbase + sblock.fs_fpg; + if (dmax > sblock.fs_size) + dmax = sblock.fs_size; + dlower = cgsblock(&sblock, cylno) - cbase; + dupper = cgdmin(&sblock, cylno) - cbase; + if (cylno == 0) + dupper += howmany(sblock.fs_cssize, sblock.fs_fsize); + cs = fscs + cylno; + bzero(&acg, sblock.fs_cgsize); + acg.cg_time = utime; + acg.cg_magic = CG_MAGIC; + acg.cg_cgx = cylno; + if (cylno == sblock.fs_ncg - 1) + acg.cg_ncyl = sblock.fs_ncyl % sblock.fs_cpg; + else + acg.cg_ncyl = sblock.fs_cpg; + acg.cg_niblk = sblock.fs_ipg; + acg.cg_ndblk = dmax - cbase; + if (sblock.fs_contigsumsize > 0) + acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; + acg.cg_btotoff = &acg.cg_space[0] - (u_char *)(&acg.cg_link); + acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(long); + acg.cg_iusedoff = acg.cg_boff + + sblock.fs_cpg * sblock.fs_nrpos * sizeof(short); + acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, NBBY); + if (sblock.fs_contigsumsize <= 0) { + acg.cg_nextfreeoff = acg.cg_freeoff + + howmany(sblock.fs_cpg * sblock.fs_spc / NSPF(&sblock), NBBY); + } else { + acg.cg_clustersumoff = acg.cg_freeoff + howmany + (sblock.fs_cpg * sblock.fs_spc / NSPF(&sblock), NBBY) - + sizeof(long); + acg.cg_clustersumoff = + roundup(acg.cg_clustersumoff, sizeof(long)); + acg.cg_clusteroff = acg.cg_clustersumoff + + (sblock.fs_contigsumsize + 1) * sizeof(long); + acg.cg_nextfreeoff = acg.cg_clusteroff + howmany + (sblock.fs_cpg * sblock.fs_spc / NSPB(&sblock), NBBY); + } + if (acg.cg_nextfreeoff - (long)(&acg.cg_link) > sblock.fs_cgsize) { + printf("Panic: cylinder group too big\n"); + exit(37); + } + acg.cg_cs.cs_nifree += sblock.fs_ipg; + if (cylno == 0) + for (i = 0; i < ROOTINO; i++) { + setbit(cg_inosused(&acg), i); + acg.cg_cs.cs_nifree--; + } + for (i = 0; i < sblock.fs_ipg / INOPF(&sblock); i += sblock.fs_frag) + wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i), + sblock.fs_bsize, (char *)zino); + if (cylno > 0) { + /* + * In cylno 0, beginning space is reserved + * for boot and super blocks. + */ + for (d = 0; d < dlower; d += sblock.fs_frag) { + blkno = d / sblock.fs_frag; + setblock(&sblock, cg_blksfree(&acg), blkno); + if (sblock.fs_contigsumsize > 0) + setbit(cg_clustersfree(&acg), blkno); + acg.cg_cs.cs_nbfree++; + cg_blktot(&acg)[cbtocylno(&sblock, d)]++; + cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) + [cbtorpos(&sblock, d)]++; + } + sblock.fs_dsize += dlower; + } + sblock.fs_dsize += acg.cg_ndblk - dupper; + if (i = dupper % sblock.fs_frag) { + acg.cg_frsum[sblock.fs_frag - i]++; + for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { + setbit(cg_blksfree(&acg), dupper); + acg.cg_cs.cs_nffree++; + } + } + for (d = dupper; d + sblock.fs_frag <= dmax - cbase; ) { + blkno = d / sblock.fs_frag; + setblock(&sblock, cg_blksfree(&acg), blkno); + if (sblock.fs_contigsumsize > 0) + setbit(cg_clustersfree(&acg), blkno); + acg.cg_cs.cs_nbfree++; + cg_blktot(&acg)[cbtocylno(&sblock, d)]++; + cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) + [cbtorpos(&sblock, d)]++; + d += sblock.fs_frag; + } + if (d < dmax - cbase) { + acg.cg_frsum[dmax - cbase - d]++; + for (; d < dmax - cbase; d++) { + setbit(cg_blksfree(&acg), d); + acg.cg_cs.cs_nffree++; + } + } + if (sblock.fs_contigsumsize > 0) { + long *sump = cg_clustersum(&acg); + u_char *mapp = cg_clustersfree(&acg); + int map = *mapp++; + int bit = 1; + int run = 0; + + for (i = 0; i < acg.cg_nclusterblks; i++) { + if ((map & bit) != 0) { + run++; + } else if (run != 0) { + if (run > sblock.fs_contigsumsize) + run = sblock.fs_contigsumsize; + sump[run]++; + run = 0; + } + if ((i & (NBBY - 1)) != (NBBY - 1)) { + bit <<= 1; + } else { + map = *mapp++; + bit = 1; + } + } + if (run != 0) { + if (run > sblock.fs_contigsumsize) + run = sblock.fs_contigsumsize; + sump[run]++; + } + } + sblock.fs_cstotal.cs_ndir += acg.cg_cs.cs_ndir; + sblock.fs_cstotal.cs_nffree += acg.cg_cs.cs_nffree; + sblock.fs_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree; + sblock.fs_cstotal.cs_nifree += acg.cg_cs.cs_nifree; + *cs = acg.cg_cs; + wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), + sblock.fs_bsize, (char *)&acg); +} + +/* + * initialize the file system + */ +struct dinode node; + +#ifdef LOSTDIR +#define PREDEFDIR 3 +#else +#define PREDEFDIR 2 +#endif + +struct direct root_dir[] = { + { ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, + { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, +#ifdef LOSTDIR + { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found" }, +#endif +}; +struct odirect { + u_long d_ino; + u_short d_reclen; + u_short d_namlen; + u_char d_name[MAXNAMLEN + 1]; +} oroot_dir[] = { + { ROOTINO, sizeof(struct direct), 1, "." }, + { ROOTINO, sizeof(struct direct), 2, ".." }, +#ifdef LOSTDIR + { LOSTFOUNDINO, sizeof(struct direct), 10, "lost+found" }, +#endif +}; +#ifdef LOSTDIR +struct direct lost_found_dir[] = { + { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, + { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, + { 0, DIRBLKSIZ, 0, 0, 0 }, +}; +struct odirect olost_found_dir[] = { + { LOSTFOUNDINO, sizeof(struct direct), 1, "." }, + { ROOTINO, sizeof(struct direct), 2, ".." }, + { 0, DIRBLKSIZ, 0, 0 }, +}; +#endif +char buf[MAXBSIZE]; + +fsinit(utime) + time_t utime; +{ + int i; + + /* + * initialize the node + */ + node.di_atime.ts_sec = utime; + node.di_mtime.ts_sec = utime; + node.di_ctime.ts_sec = utime; +#ifdef LOSTDIR + /* + * create the lost+found directory + */ + if (Oflag) { + (void)makedir((struct direct *)olost_found_dir, 2); + for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ) + bcopy(&olost_found_dir[2], &buf[i], + DIRSIZ(0, &olost_found_dir[2])); + } else { + (void)makedir(lost_found_dir, 2); + for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ) + bcopy(&lost_found_dir[2], &buf[i], + DIRSIZ(0, &lost_found_dir[2])); + } + node.di_mode = IFDIR | UMASK; + node.di_nlink = 2; + node.di_size = sblock.fs_bsize; + node.di_db[0] = alloc(node.di_size, node.di_mode); + node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); + wtfs(fsbtodb(&sblock, node.di_db[0]), node.di_size, buf); + iput(&node, LOSTFOUNDINO); +#endif + /* + * create the root directory + */ + if (mfs) + node.di_mode = IFDIR | 01777; + else + node.di_mode = IFDIR | UMASK; + node.di_nlink = PREDEFDIR; + if (Oflag) + node.di_size = makedir((struct direct *)oroot_dir, PREDEFDIR); + else + node.di_size = makedir(root_dir, PREDEFDIR); + node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode); + node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); + wtfs(fsbtodb(&sblock, node.di_db[0]), sblock.fs_fsize, buf); + iput(&node, ROOTINO); +} + +/* + * construct a set of directory entries in "buf". + * return size of directory. + */ +makedir(protodir, entries) + register struct direct *protodir; + int entries; +{ + char *cp; + int i, spcleft; + + spcleft = DIRBLKSIZ; + for (cp = buf, i = 0; i < entries - 1; i++) { + protodir[i].d_reclen = DIRSIZ(0, &protodir[i]); + bcopy(&protodir[i], cp, protodir[i].d_reclen); + cp += protodir[i].d_reclen; + spcleft -= protodir[i].d_reclen; + } + protodir[i].d_reclen = spcleft; + bcopy(&protodir[i], cp, DIRSIZ(0, &protodir[i])); + return (DIRBLKSIZ); +} + +/* + * allocate a block or frag + */ +daddr_t +alloc(size, mode) + int size; + int mode; +{ + int i, frag; + daddr_t d, blkno; + + rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, + (char *)&acg); + if (acg.cg_magic != CG_MAGIC) { + printf("cg 0: bad magic number\n"); + return (0); + } + if (acg.cg_cs.cs_nbfree == 0) { + printf("first cylinder group ran out of space\n"); + return (0); + } + for (d = 0; d < acg.cg_ndblk; d += sblock.fs_frag) + if (isblock(&sblock, cg_blksfree(&acg), d / sblock.fs_frag)) + goto goth; + printf("internal error: can't find block in cyl 0\n"); + return (0); +goth: + blkno = fragstoblks(&sblock, d); + clrblock(&sblock, cg_blksfree(&acg), blkno); + if (sblock.fs_contigsumsize > 0) + clrbit(cg_clustersfree(&acg), blkno); + acg.cg_cs.cs_nbfree--; + sblock.fs_cstotal.cs_nbfree--; + fscs[0].cs_nbfree--; + if (mode & IFDIR) { + acg.cg_cs.cs_ndir++; + sblock.fs_cstotal.cs_ndir++; + fscs[0].cs_ndir++; + } + cg_blktot(&acg)[cbtocylno(&sblock, d)]--; + cg_blks(&sblock, &acg, cbtocylno(&sblock, d))[cbtorpos(&sblock, d)]--; + if (size != sblock.fs_bsize) { + frag = howmany(size, sblock.fs_fsize); + fscs[0].cs_nffree += sblock.fs_frag - frag; + sblock.fs_cstotal.cs_nffree += sblock.fs_frag - frag; + acg.cg_cs.cs_nffree += sblock.fs_frag - frag; + acg.cg_frsum[sblock.fs_frag - frag]++; + for (i = frag; i < sblock.fs_frag; i++) + setbit(cg_blksfree(&acg), d + i); + } + wtfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, + (char *)&acg); + return (d); +} + +/* + * Allocate an inode on the disk + */ +iput(ip, ino) + register struct dinode *ip; + register ino_t ino; +{ + struct dinode buf[MAXINOPB]; + daddr_t d; + int c; + + c = ino_to_cg(&sblock, ino); + rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, + (char *)&acg); + if (acg.cg_magic != CG_MAGIC) { + printf("cg 0: bad magic number\n"); + exit(31); + } + acg.cg_cs.cs_nifree--; + setbit(cg_inosused(&acg), ino); + wtfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, + (char *)&acg); + sblock.fs_cstotal.cs_nifree--; + fscs[0].cs_nifree--; + if (ino >= sblock.fs_ipg * sblock.fs_ncg) { + printf("fsinit: inode value out of range (%d).\n", ino); + exit(32); + } + d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino)); + rdfs(d, sblock.fs_bsize, buf); + buf[ino_to_fsbo(&sblock, ino)] = *ip; + wtfs(d, sblock.fs_bsize, buf); +} + +/* + * Notify parent process that the filesystem has created itself successfully. + */ +void +started() +{ + + exit(0); +} + +/* + * Replace libc function with one suited to our needs. + */ +caddr_t +malloc(size) + register u_long size; +{ + char *base, *i; + static u_long pgsz; + struct rlimit rlp; + + if (pgsz == 0) { + base = sbrk(0); + pgsz = getpagesize() - 1; + i = (char *)((u_long)(base + pgsz) &~ pgsz); + base = sbrk(i - base); + if (getrlimit(RLIMIT_DATA, &rlp) < 0) + perror("getrlimit"); + rlp.rlim_cur = rlp.rlim_max; + if (setrlimit(RLIMIT_DATA, &rlp) < 0) + perror("setrlimit"); + memleft = rlp.rlim_max - (u_long)base; + } + size = (size + pgsz) &~ pgsz; + if (size > memleft) + size = memleft; + memleft -= size; + if (size == 0) + return (0); + return ((caddr_t)sbrk(size)); +} + +/* + * Replace libc function with one suited to our needs. + */ +caddr_t +realloc(ptr, size) + char *ptr; + u_long size; +{ + void *p; + + if ((p = malloc(size)) == NULL) + return (NULL); + bcopy(ptr, p, size); + free(ptr); + return (p); +} + +/* + * Replace libc function with one suited to our needs. + */ +char * +calloc(size, numelm) + u_long size, numelm; +{ + caddr_t base; + + size *= numelm; + base = malloc(size); + bzero(base, size); + return (base); +} + +/* + * Replace libc function with one suited to our needs. + */ +free(ptr) + char *ptr; +{ + + /* do not worry about it for now */ +} + +/* + * read a block from the file system + */ +rdfs(bno, size, bf) + daddr_t bno; + int size; + char *bf; +{ + int n; + + if (mfs) { + bcopy(membase + bno * sectorsize, bf, size); + return; + } + if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) { + printf("seek error: %ld\n", bno); + perror("rdfs"); + exit(33); + } + n = read(fsi, bf, size); + if (n != size) { + printf("read error: %ld\n", bno); + perror("rdfs"); + exit(34); + } +} + +/* + * write a block to the file system + */ +wtfs(bno, size, bf) + daddr_t bno; + int size; + char *bf; +{ + int n; + + if (mfs) { + bcopy(bf, membase + bno * sectorsize, size); + return; + } + if (Nflag) + return; + if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) { + printf("seek error: %ld\n", bno); + perror("wtfs"); + exit(35); + } + n = write(fso, bf, size); + if (n != size) { + printf("write error: %ld\n", bno); + perror("wtfs"); + exit(36); + } +} + +/* + * check if a block is available + */ +isblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + int h; +{ + unsigned char mask; + + switch (fs->fs_frag) { + case 8: + return (cp[h] == 0xff); + case 4: + mask = 0x0f << ((h & 0x1) << 2); + return ((cp[h >> 1] & mask) == mask); + case 2: + mask = 0x03 << ((h & 0x3) << 1); + return ((cp[h >> 2] & mask) == mask); + case 1: + mask = 0x01 << (h & 0x7); + return ((cp[h >> 3] & mask) == mask); + default: +#ifdef STANDALONE + printf("isblock bad fs_frag %d\n", fs->fs_frag); +#else + fprintf(stderr, "isblock bad fs_frag %d\n", fs->fs_frag); +#endif + return (0); + } +} + +/* + * take a block out of the map + */ +clrblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + int h; +{ + switch ((fs)->fs_frag) { + case 8: + cp[h] = 0; + return; + case 4: + cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2)); + return; + case 2: + cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1)); + return; + case 1: + cp[h >> 3] &= ~(0x01 << (h & 0x7)); + return; + default: +#ifdef STANDALONE + printf("clrblock bad fs_frag %d\n", fs->fs_frag); +#else + fprintf(stderr, "clrblock bad fs_frag %d\n", fs->fs_frag); +#endif + return; + } +} + +/* + * put a block into the map + */ +setblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + int h; +{ + switch (fs->fs_frag) { + case 8: + cp[h] = 0xff; + return; + case 4: + cp[h >> 1] |= (0x0f << ((h & 0x1) << 2)); + return; + case 2: + cp[h >> 2] |= (0x03 << ((h & 0x3) << 1)); + return; + case 1: + cp[h >> 3] |= (0x01 << (h & 0x7)); + return; + default: +#ifdef STANDALONE + printf("setblock bad fs_frag %d\n", fs->fs_frag); +#else + fprintf(stderr, "setblock bad fs_frag %d\n", fs->fs_frag); +#endif + return; + } +} diff --git a/ufs-utils/newfs.c b/ufs-utils/newfs.c new file mode 100644 index 00000000..f468ef24 --- /dev/null +++ b/ufs-utils/newfs.c @@ -0,0 +1,679 @@ +/* + * Copyright (c) 1983, 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1983, 1989, 1993, 1994\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +/*static char sccsid[] = "from: @(#)newfs.c 8.8 (Berkeley) 4/18/94";*/ +static char *rcsid = "$Id: newfs.c,v 1.1 1994/08/23 19:30:43 mib Exp $"; +#endif /* not lint */ + +/* + * newfs: friendly front end to mkfs + */ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#if __STDC__ +#include +#else +#include +#endif + +#include "mntopts.h" + +struct mntopt mopts[] = { + MOPT_STDOPTS, + MOPT_ASYNC, + { NULL }, +}; + +#if __STDC__ +void fatal(const char *fmt, ...); +#else +void fatal(); +#endif + +#define COMPAT /* allow non-labeled disks */ + +/* + * The following two constants set the default block and fragment sizes. + * Both constants must be a power of 2 and meet the following constraints: + * MINBSIZE <= DESBLKSIZE <= MAXBSIZE + * sectorsize <= DESFRAGSIZE <= DESBLKSIZE + * DESBLKSIZE / DESFRAGSIZE <= 8 + */ +#define DFL_FRAGSIZE 1024 +#define DFL_BLKSIZE 8192 + +/* + * Cylinder groups may have up to many cylinders. The actual + * number used depends upon how much information can be stored + * on a single cylinder. The default is to use 16 cylinders + * per group. + */ +#define DESCPG 16 /* desired fs_cpg */ + +/* + * ROTDELAY gives the minimum number of milliseconds to initiate + * another disk transfer on the same cylinder. It is used in + * determining the rotationally optimal layout for disk blocks + * within a file; the default of fs_rotdelay is 4ms. + */ +#define ROTDELAY 4 + +/* + * MAXBLKPG determines the maximum number of data blocks which are + * placed in a single cylinder group. The default is one indirect + * block worth of data blocks. + */ +#define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) + +/* + * Each file system has a number of inodes statically allocated. + * We allocate one inode slot per NFPI fragments, expecting this + * to be far more than we will ever need. + */ +#define NFPI 4 + +/* + * For each cylinder we keep track of the availability of blocks at different + * rotational positions, so that we can lay out the data to be picked + * up with minimum rotational latency. NRPOS is the default number of + * rotational positions that we distinguish. With NRPOS of 8 the resolution + * of our summary information is 2ms for a typical 3600 rpm drive. + */ +#define NRPOS 8 /* number distinct rotational positions */ + + +int mfs; /* run as the memory based filesystem */ +int Nflag; /* run without writing file system */ +int Oflag; /* format as an 4.3BSD file system */ +int fssize; /* file system size */ +int ntracks; /* # tracks/cylinder */ +int nsectors; /* # sectors/track */ +int nphyssectors; /* # sectors/track including spares */ +int secpercyl; /* sectors per cylinder */ +int trackspares = -1; /* spare sectors per track */ +int cylspares = -1; /* spare sectors per cylinder */ +int sectorsize; /* bytes/sector */ +#ifdef tahoe +int realsectorsize; /* bytes/sector in hardware */ +#endif +int rpm; /* revolutions/minute of drive */ +int interleave; /* hardware sector interleave */ +int trackskew = -1; /* sector 0 skew, per track */ +int headswitch; /* head switch time, usec */ +int trackseek; /* track-to-track seek, usec */ +int fsize = 0; /* fragment size */ +int bsize = 0; /* block size */ +int cpg = DESCPG; /* cylinders/cylinder group */ +int cpgflg; /* cylinders/cylinder group flag was given */ +int minfree = MINFREE; /* free space threshold */ +int opt = DEFAULTOPT; /* optimization preference (space or time) */ +int density; /* number of bytes per inode */ +int maxcontig = 0; /* max contiguous blocks to allocate */ +int rotdelay = ROTDELAY; /* rotational delay between blocks */ +int maxbpg; /* maximum blocks per file in a cyl group */ +int nrpos = NRPOS; /* # of distinguished rotational positions */ +int bbsize = BBSIZE; /* boot block size */ +int sbsize = SBSIZE; /* superblock size */ +int mntflags = MNT_ASYNC; /* flags to be passed to mount */ +u_long memleft; /* virtual memory available */ +caddr_t membase; /* start address of memory based filesystem */ +#ifdef COMPAT +char *disktype; +int unlabeled; +#endif + +char device[MAXPATHLEN]; +char *progname; + +int +main(argc, argv) + int argc; + char *argv[]; +{ + extern char *optarg; + extern int optind; + register int ch; + register struct partition *pp; + register struct disklabel *lp; + struct disklabel *getdisklabel(); + struct partition oldpartition; + struct stat st; + struct statfs *mp; + int fsi, fso, len, n; + char *cp, *s1, *s2, *special, *opstring, buf[BUFSIZ]; + + if (progname = rindex(*argv, '/')) + ++progname; + else + progname = *argv; + + if (strstr(progname, "mfs")) { + mfs = 1; + Nflag++; + } + + opstring = mfs ? + "NT:a:b:c:d:e:f:i:m:o:s:" : + "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:"; + while ((ch = getopt(argc, argv, opstring)) != EOF) + switch (ch) { + case 'N': + Nflag = 1; + break; + case 'O': + Oflag = 1; + break; + case 'S': + if ((sectorsize = atoi(optarg)) <= 0) + fatal("%s: bad sector size", optarg); + break; +#ifdef COMPAT + case 'T': + disktype = optarg; + break; +#endif + case 'a': + if ((maxcontig = atoi(optarg)) <= 0) + fatal("%s: bad maximum contiguous blocks\n", + optarg); + break; + case 'b': + if ((bsize = atoi(optarg)) < MINBSIZE) + fatal("%s: bad block size", optarg); + break; + case 'c': + if ((cpg = atoi(optarg)) <= 0) + fatal("%s: bad cylinders/group", optarg); + cpgflg++; + break; + case 'd': + if ((rotdelay = atoi(optarg)) < 0) + fatal("%s: bad rotational delay\n", optarg); + break; + case 'e': + if ((maxbpg = atoi(optarg)) <= 0) + fatal("%s: bad blocks per file in a cylinder group\n", + optarg); + break; + case 'f': + if ((fsize = atoi(optarg)) <= 0) + fatal("%s: bad fragment size", optarg); + break; + case 'i': + if ((density = atoi(optarg)) <= 0) + fatal("%s: bad bytes per inode\n", optarg); + break; + case 'k': + if ((trackskew = atoi(optarg)) < 0) + fatal("%s: bad track skew", optarg); + break; + case 'l': + if ((interleave = atoi(optarg)) <= 0) + fatal("%s: bad interleave", optarg); + break; + case 'm': + if ((minfree = atoi(optarg)) < 0 || minfree > 99) + fatal("%s: bad free space %%\n", optarg); + break; + case 'n': + if ((nrpos = atoi(optarg)) <= 0) + fatal("%s: bad rotational layout count\n", + optarg); + break; + case 'o': + if (mfs) + getmntopts(optarg, mopts, &mntflags); + else { + if (strcmp(optarg, "space") == 0) + opt = FS_OPTSPACE; + else if (strcmp(optarg, "time") == 0) + opt = FS_OPTTIME; + else + fatal("%s: unknown optimization preference: use `space' or `time'."); + } + break; + case 'p': + if ((trackspares = atoi(optarg)) < 0) + fatal("%s: bad spare sectors per track", + optarg); + break; + case 'r': + if ((rpm = atoi(optarg)) <= 0) + fatal("%s: bad revolutions/minute\n", optarg); + break; + case 's': + if ((fssize = atoi(optarg)) <= 0) + fatal("%s: bad file system size", optarg); + break; + case 't': + if ((ntracks = atoi(optarg)) <= 0) + fatal("%s: bad total tracks", optarg); + break; + case 'u': + if ((nsectors = atoi(optarg)) <= 0) + fatal("%s: bad sectors/track", optarg); + break; + case 'x': + if ((cylspares = atoi(optarg)) < 0) + fatal("%s: bad spare sectors per cylinder", + optarg); + break; + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (argc != 2 && (mfs || argc != 1)) + usage(); + + special = argv[0]; + cp = rindex(special, '/'); + if (cp == 0) { + /* + * No path prefix; try /dev/r%s then /dev/%s. + */ + (void)sprintf(device, "%sr%s", _PATH_DEV, special); + if (stat(device, &st) == -1) + (void)sprintf(device, "%s%s", _PATH_DEV, special); + special = device; + } + if (Nflag) { + fso = -1; + } else { + fso = open(special, O_WRONLY); + if (fso < 0) + fatal("%s: %s", special, strerror(errno)); + + /* Bail if target special is mounted */ + n = getmntinfo(&mp, MNT_NOWAIT); + if (n == 0) + fatal("%s: getmntinfo: %s", special, strerror(errno)); + + len = sizeof(_PATH_DEV) - 1; + s1 = special; + if (strncmp(_PATH_DEV, s1, len) == 0) + s1 += len; + + while (--n >= 0) { + s2 = mp->f_mntfromname; + if (strncmp(_PATH_DEV, s2, len) == 0) { + s2 += len - 1; + *s2 = 'r'; + } + if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) + fatal("%s is mounted on %s", + special, mp->f_mntonname); + ++mp; + } + } + if (mfs && disktype != NULL) { + lp = (struct disklabel *)getdiskbyname(disktype); + if (lp == NULL) + fatal("%s: unknown disk type", disktype); + pp = &lp->d_partitions[1]; + } else { + fsi = open(special, O_RDONLY); + if (fsi < 0) + fatal("%s: %s", special, strerror(errno)); + if (fstat(fsi, &st) < 0) + fatal("%s: %s", special, strerror(errno)); + if ((st.st_mode & S_IFMT) != S_IFCHR && !mfs) + printf("%s: %s: not a character-special device\n", + progname, special); + cp = index(argv[0], '\0') - 1; + if (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) + fatal("%s: can't figure out file system partition", + argv[0]); +#ifdef COMPAT + if (!mfs && disktype == NULL) + disktype = argv[1]; +#endif + lp = getdisklabel(special, fsi); + if (isdigit(*cp)) + pp = &lp->d_partitions[0]; + else + pp = &lp->d_partitions[*cp - 'a']; + if (pp->p_size == 0) + fatal("%s: `%c' partition is unavailable", + argv[0], *cp); + if (pp->p_fstype == FS_BOOT) + fatal("%s: `%c' partition overlaps boot program", + argv[0], *cp); + } + if (fssize == 0) + fssize = pp->p_size; + if (fssize > pp->p_size && !mfs) + fatal("%s: maximum file system size on the `%c' partition is %d", + argv[0], *cp, pp->p_size); + if (rpm == 0) { + rpm = lp->d_rpm; + if (rpm <= 0) + rpm = 3600; + } + if (ntracks == 0) { + ntracks = lp->d_ntracks; + if (ntracks <= 0) + fatal("%s: no default #tracks", argv[0]); + } + if (nsectors == 0) { + nsectors = lp->d_nsectors; + if (nsectors <= 0) + fatal("%s: no default #sectors/track", argv[0]); + } + if (sectorsize == 0) { + sectorsize = lp->d_secsize; + if (sectorsize <= 0) + fatal("%s: no default sector size", argv[0]); + } + if (trackskew == -1) { + trackskew = lp->d_trackskew; + if (trackskew < 0) + trackskew = 0; + } + if (interleave == 0) { + interleave = lp->d_interleave; + if (interleave <= 0) + interleave = 1; + } + if (fsize == 0) { + fsize = pp->p_fsize; + if (fsize <= 0) + fsize = MAX(DFL_FRAGSIZE, lp->d_secsize); + } + if (bsize == 0) { + bsize = pp->p_frag * pp->p_fsize; + if (bsize <= 0) + bsize = MIN(DFL_BLKSIZE, 8 * fsize); + } + /* + * Maxcontig sets the default for the maximum number of blocks + * that may be allocated sequentially. With filesystem clustering + * it is possible to allocate contiguous blocks up to the maximum + * transfer size permitted by the controller or buffering. + */ + if (maxcontig == 0) + maxcontig = MAX(1, MIN(MAXPHYS, MAXBSIZE) / bsize - 1); + if (density == 0) + density = NFPI * fsize; + if (minfree < MINFREE && opt != FS_OPTSPACE) { + fprintf(stderr, "Warning: changing optimization to space "); + fprintf(stderr, "because minfree is less than %d%%\n", MINFREE); + opt = FS_OPTSPACE; + } + if (trackspares == -1) { + trackspares = lp->d_sparespertrack; + if (trackspares < 0) + trackspares = 0; + } + nphyssectors = nsectors + trackspares; + if (cylspares == -1) { + cylspares = lp->d_sparespercyl; + if (cylspares < 0) + cylspares = 0; + } + secpercyl = nsectors * ntracks - cylspares; + if (secpercyl != lp->d_secpercyl) + fprintf(stderr, "%s (%d) %s (%lu)\n", + "Warning: calculated sectors per cylinder", secpercyl, + "disagrees with disk label", lp->d_secpercyl); + if (maxbpg == 0) + maxbpg = MAXBLKPG(bsize); + headswitch = lp->d_headswitch; + trackseek = lp->d_trkseek; +#ifdef notdef /* label may be 0 if faked up by kernel */ + bbsize = lp->d_bbsize; + sbsize = lp->d_sbsize; +#endif + oldpartition = *pp; +#ifdef tahoe + realsectorsize = sectorsize; + if (sectorsize != DEV_BSIZE) { /* XXX */ + int secperblk = DEV_BSIZE / sectorsize; + + sectorsize = DEV_BSIZE; + nsectors /= secperblk; + nphyssectors /= secperblk; + secpercyl /= secperblk; + fssize /= secperblk; + pp->p_size /= secperblk; + } +#endif + mkfs(pp, special, fsi, fso); +#ifdef tahoe + if (realsectorsize != DEV_BSIZE) + pp->p_size *= DEV_BSIZE / realsectorsize; +#endif + if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition))) + rewritelabel(special, fso, lp); + if (!Nflag) + close(fso); + close(fsi); +#ifdef MFS + if (mfs) { + struct mfs_args args; + + sprintf(buf, "mfs:%d", getpid()); + args.fspec = buf; + args.export.ex_root = -2; + if (mntflags & MNT_RDONLY) + args.export.ex_flags = MNT_EXRDONLY; + else + args.export.ex_flags = 0; + args.base = membase; + args.size = fssize * sectorsize; + if (mount(MOUNT_MFS, argv[1], mntflags, &args) < 0) + fatal("%s: %s", argv[1], strerror(errno)); + } +#endif + exit(0); +} + +#ifdef COMPAT +char lmsg[] = "%s: can't read disk label; disk type must be specified"; +#else +char lmsg[] = "%s: can't read disk label"; +#endif + +struct disklabel * +getdisklabel(s, fd) + char *s; + int fd; +{ + static struct disklabel lab; + + if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { +#ifdef COMPAT + if (disktype) { + struct disklabel *lp, *getdiskbyname(); + + unlabeled++; + lp = getdiskbyname(disktype); + if (lp == NULL) + fatal("%s: unknown disk type", disktype); + return (lp); + } +#endif + warn("ioctl (GDINFO)"); + fatal(lmsg, s); + } + return (&lab); +} + +rewritelabel(s, fd, lp) + char *s; + int fd; + register struct disklabel *lp; +{ +#ifdef COMPAT + if (unlabeled) + return; +#endif + lp->d_checksum = 0; + lp->d_checksum = dkcksum(lp); + if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) { + warn("ioctl (WDINFO)"); + fatal("%s: can't rewrite disk label", s); + } +#if vax + if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) { + register i; + int cfd; + daddr_t alt; + char specname[64]; + char blk[1024]; + char *cp; + + /* + * Make name for 'c' partition. + */ + strcpy(specname, s); + cp = specname + strlen(specname) - 1; + if (!isdigit(*cp)) + *cp = 'c'; + cfd = open(specname, O_WRONLY); + if (cfd < 0) + fatal("%s: %s", specname, strerror(errno)); + bzero(blk, sizeof(blk)); + *(struct disklabel *)(blk + LABELOFFSET) = *lp; + alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors; + for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) { + if (lseek(cfd, (off_t)(alt + i) * lp->d_secsize, + L_SET) == -1) + fatal("lseek to badsector area: %s", + strerror(errno)); + if (write(cfd, blk, lp->d_secsize) < lp->d_secsize) + warn("alternate label %d write", i/2); + } + close(cfd); + } +#endif +} + +/*VARARGS*/ +void +#if __STDC__ +fatal(const char *fmt, ...) +#else +fatal(fmt, va_alist) + char *fmt; + va_dcl +#endif +{ + va_list ap; + +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + if (fcntl(STDERR_FILENO, F_GETFL) < 0) { + openlog(progname, LOG_CONS, LOG_DAEMON); + vsyslog(LOG_ERR, fmt, ap); + closelog(); + } else { + vwarnx(fmt, ap); + } + va_end(ap); + exit(1); + /*NOTREACHED*/ +} + +usage() +{ + if (mfs) { + fprintf(stderr, + "usage: %s [ -fsoptions ] special-device mount-point\n", + progname); + } else + fprintf(stderr, + "usage: %s [ -fsoptions ] special-device%s\n", + progname, +#ifdef COMPAT + " [device-type]"); +#else + ""); +#endif + fprintf(stderr, "where fsoptions are:\n"); + fprintf(stderr, + "\t-N do not create file system, just print out parameters\n"); + fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n"); + fprintf(stderr, "\t-S sector size\n"); +#ifdef COMPAT + fprintf(stderr, "\t-T disktype\n"); +#endif + fprintf(stderr, "\t-a maximum contiguous blocks\n"); + fprintf(stderr, "\t-b block size\n"); + fprintf(stderr, "\t-c cylinders/group\n"); + fprintf(stderr, "\t-d rotational delay between contiguous blocks\n"); + fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n"); + fprintf(stderr, "\t-f frag size\n"); + fprintf(stderr, "\t-i number of bytes per inode\n"); + fprintf(stderr, "\t-k sector 0 skew, per track\n"); + fprintf(stderr, "\t-l hardware sector interleave\n"); + fprintf(stderr, "\t-m minimum free space %%\n"); + fprintf(stderr, "\t-n number of distinguished rotational positions\n"); + fprintf(stderr, "\t-o optimization preference (`space' or `time')\n"); + fprintf(stderr, "\t-p spare sectors per track\n"); + fprintf(stderr, "\t-s file system size (sectors)\n"); + fprintf(stderr, "\t-r revolutions/minute\n"); + fprintf(stderr, "\t-t tracks/cylinder\n"); + fprintf(stderr, "\t-u sectors/track\n"); + fprintf(stderr, "\t-x spare sectors per cylinder\n"); + exit(1); +} -- cgit v1.2.3 From 1d1418f596f97783a3cb09c74f766831fadd119c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 19:39:52 +0000 Subject: Formerly Makefile.~2~ --- bsdfsck/Makefile | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index b1e25a2f..b8d9f2a3 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -1,14 +1,35 @@ -# from: @(#)Makefile 8.1 (Berkeley) 6/5/93 -# $Id: Makefile,v 1.1 1994/08/23 19:29:26 mib Exp $ +# +# Copyright (C) 1994 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 +# published by the Free Software Foundation; either version 2, 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. -PROG= fsck -MAN8= fsck.0 -SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ - pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c -.PATH: ${.CURDIR}/../../sys/ufs/ffs +dir := fsck +makemode := utility -.if make(install) -SUBDIR+= SMM.doc -.endif +SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ + pass5.c preen.c setup.c utilities.c +OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ + pass5.o preen.o setup.o utilities.o +target = fsck -.include +include ../Makeconf + +all: fsck.native + +fsck.native: $(addprefix native-,$(OBJS)) + rsh $(mighost) -n cd `pwd` \; gcc $^ -o $@ + +native-%.o: %.c + rsh $(mighost) -n cd `pwd` \; gcc -c $^ -o $@ -- cgit v1.2.3 From e660b21e7c5f3fb483480aea7f33d4e68389a7e4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 19:44:53 +0000 Subject: Initial revision --- bsdfsck/fsck.h | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 bsdfsck/fsck.h diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h new file mode 100644 index 00000000..ea173b25 --- /dev/null +++ b/bsdfsck/fsck.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 + * $Id: fsck.h,v 1.1 1994/08/23 19:44:53 mib Exp $ + */ + +#define MAXDUP 10 /* limit on dup blks (per inode) */ +#define MAXBAD 10 /* limit on bad blks (per inode) */ +#define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */ +#define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */ + +#ifndef BUFSIZ +#define BUFSIZ 1024 +#endif + +#define USTATE 01 /* inode not allocated */ +#define FSTATE 02 /* inode is file */ +#define DSTATE 03 /* inode is directory */ +#define DFOUND 04 /* directory found during descent */ +#define DCLEAR 05 /* directory is to be cleared */ +#define FCLEAR 06 /* file is to be cleared */ + +/* + * buffer cache structure. + */ +struct bufarea { + struct bufarea *b_next; /* free list queue */ + struct bufarea *b_prev; /* free list queue */ + daddr_t b_bno; + int b_size; + int b_errs; + int b_flags; + union { + char *b_buf; /* buffer space */ + daddr_t *b_indir; /* indirect block */ + struct fs *b_fs; /* super block */ + struct cg *b_cg; /* cylinder group */ + struct dinode *b_dinode; /* inode block */ + } b_un; + char b_dirty; +}; + +#define B_INUSE 1 + +#define MINBUFS 5 /* minimum number of buffers required */ +struct bufarea bufhead; /* head of list of other blks in filesys */ +struct bufarea sblk; /* file system superblock */ +struct bufarea cgblk; /* cylinder group blocks */ +struct bufarea *pdirbp; /* current directory contents */ +struct bufarea *pbp; /* current inode block */ +struct bufarea *getdatablk(); + +#define dirty(bp) (bp)->b_dirty = 1 +#define initbarea(bp) \ + (bp)->b_dirty = 0; \ + (bp)->b_bno = (daddr_t)-1; \ + (bp)->b_flags = 0; + +#define sbdirty() sblk.b_dirty = 1 +#define cgdirty() cgblk.b_dirty = 1 +#define sblock (*sblk.b_un.b_fs) +#define cgrp (*cgblk.b_un.b_cg) + +enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE}; + +struct inodesc { + enum fixstate id_fix; /* policy on fixing errors */ + int (*id_func)(); /* function to be applied to blocks of inode */ + ino_t id_number; /* inode number described */ + ino_t id_parent; /* for DATA nodes, their parent */ + daddr_t id_blkno; /* current block number being examined */ + int id_numfrags; /* number of frags contained in block */ + quad_t id_filesize; /* for DATA nodes, the size of the directory */ + int id_loc; /* for DATA nodes, current location in dir */ + int id_entryno; /* for DATA nodes, current entry number */ + struct direct *id_dirp; /* for DATA nodes, ptr to current entry */ + char *id_name; /* for DATA nodes, name to find or enter */ + char id_type; /* type of descriptor, DATA or ADDR */ +}; +/* file types */ +#define DATA 1 +#define ADDR 2 + +/* + * Linked list of duplicate blocks. + * + * The list is composed of two parts. The first part of the + * list (from duplist through the node pointed to by muldup) + * contains a single copy of each duplicate block that has been + * found. The second part of the list (from muldup to the end) + * contains duplicate blocks that have been found more than once. + * 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 + * 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: + * + * w -> y -> x -> z -> y -> w -> y + * ^ ^ + * | | + * duplist muldup + */ +struct dups { + struct dups *next; + daddr_t dup; +}; +struct dups *duplist; /* head of dup list */ +struct dups *muldup; /* end of unique duplicate dup block numbers */ + +/* + * Linked list of inodes with zero link counts. + */ +struct zlncnt { + struct zlncnt *next; + ino_t zlncnt; +}; +struct zlncnt *zlnhead; /* head of zero link count list */ + +/* + * Inode cache data structures. + */ +struct inoinfo { + struct inoinfo *i_nexthash; /* next entry in hash chain */ + ino_t i_number; /* inode number of this entry */ + ino_t i_parent; /* inode number of parent */ + ino_t i_dotdot; /* inode number of `..' */ + size_t i_isize; /* size of inode */ + u_int i_numblks; /* size of block array in bytes */ + daddr_t i_blks[1]; /* actually longer */ +} **inphead, **inpsort; +long numdirs, listmax, inplast; + +char *cdevname; /* name of device being checked */ +long dev_bsize; /* computed value of DEV_BSIZE */ +long secsize; /* actual disk sector size */ +char nflag; /* assume a no response */ +char yflag; /* assume a yes response */ +int bflag; /* location of alternate super block */ +int debug; /* output debugging info */ +int cvtlevel; /* convert to newer file system format */ +int doinglevel1; /* converting to new cylinder group format */ +int doinglevel2; /* converting to new inode format */ +int newinofmt; /* filesystem has new inode format */ +char preen; /* just fix normal inconsistencies */ +char hotroot; /* checking root device */ +char havesb; /* superblock has been read */ +int fsmodified; /* 1 => write done to file system */ +int fsreadfd; /* file descriptor for reading file system */ +int fswritefd; /* file descriptor for writing file system */ + +daddr_t maxfsblock; /* number of blocks in the file system */ +char *blockmap; /* ptr to primary blk allocation map */ +ino_t maxino; /* number of inodes in file system */ +ino_t lastino; /* last inode in use */ +char *statemap; /* ptr to inode state table */ +char *typemap; /* ptr to inode type table */ +short *lncntp; /* ptr to link count table */ + +ino_t lfdir; /* lost & found directory inode number */ +char *lfname; /* lost & found directory name */ +int lfmode; /* lost & found directory creation mode */ + +daddr_t n_blks; /* number of blocks in use */ +daddr_t n_files; /* number of files in use */ + +#define clearinode(dp) (*(dp) = zino) +struct dinode zino; + +#define setbmap(blkno) setbit(blockmap, blkno) +#define testbmap(blkno) isset(blockmap, blkno) +#define clrbmap(blkno) clrbit(blockmap, blkno) + +#define STOP 0x01 +#define SKIP 0x02 +#define KEEPON 0x04 +#define ALTERED 0x08 +#define FOUND 0x10 + +time_t time(); +struct dinode *ginode(); +struct inoinfo *getinoinfo(); +void getblk(); +ino_t allocino(); +int findino(); -- cgit v1.2.3 From 752921f3d206f80f2f3a1436a32a98a7be81b0b5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 19:53:52 +0000 Subject: Formerly fsck.h.~2~ --- bsdfsck/fsck.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index ea173b25..f26f3d8b 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,9 +31,60 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.1 1994/08/23 19:44:53 mib Exp $ + * $Id: fsck.h,v 1.2 1994/08/23 19:53:52 mib Exp $ */ +/* Begin GNU Hurd */ + +/* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD + 4.4 version that fsck expects. So we provide here the BSD version. */ +#undef DIRSIZ +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRSIZ(oldfmt, dp) \ + ((oldfmt) ? \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) +#else +#define DIRSIZ(oldfmt, dp) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) +#endif + +/* GNU ufs has no need of struct dirtemplate; so provide the + BSD version here. */ +/* + * 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_long dot_ino; + short dot_reclen; + u_char dot_type; + u_char dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_long dotdot_ino; + short dotdot_reclen; + u_char dotdot_type; + u_char dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; +/* + * This is the old format of directories, sanz type element. + */ +struct odirtemplate { + u_long dot_ino; + short dot_reclen; + u_short dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_long dotdot_ino; + short dotdot_reclen; + u_short dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + +/* End GNU Hurd additions */ + + #define MAXDUP 10 /* limit on dup blks (per inode) */ #define MAXBAD 10 /* limit on bad blks (per inode) */ #define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */ -- cgit v1.2.3 From f1424cf76d282077449897e0188a5badd56f1664 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:00:23 +0000 Subject: Formerly main.c.~2~ --- bsdfsck/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsdfsck/main.c b/bsdfsck/main.c index e8f952a1..609cad6b 100644 --- a/bsdfsck/main.c +++ b/bsdfsck/main.c @@ -39,14 +39,14 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)main.c 8.2 (Berkeley) 1/23/94";*/ -static char *rcsid = "$Id: main.c,v 1.1 1994/08/23 19:29:22 mib Exp $"; +static char *rcsid = "$Id: main.c,v 1.2 1994/08/23 20:00:23 mib Exp $"; #endif /* not lint */ #include #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include #include #include -- cgit v1.2.3 From a3264de7fef6cc1a7054fa3c18427ddf069467f5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:02:28 +0000 Subject: entered into RCS --- bsdfsck/pass1b.c | 6 +++--- bsdfsck/pass3.c | 6 +++--- bsdfsck/pass4.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bsdfsck/pass1b.c b/bsdfsck/pass1b.c index d40e2254..f5aadc06 100644 --- a/bsdfsck/pass1b.c +++ b/bsdfsck/pass1b.c @@ -33,13 +33,13 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass1b.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass1b.c,v 1.1 1994/08/23 19:29:23 mib Exp $"; +static char *rcsid = "$Id: pass1b.c,v 1.2 1994/08/23 20:01:24 mib Exp $"; #endif /* not lint */ #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include #include "fsck.h" diff --git a/bsdfsck/pass3.c b/bsdfsck/pass3.c index 12c40700..78fb6a96 100644 --- a/bsdfsck/pass3.c +++ b/bsdfsck/pass3.c @@ -33,13 +33,13 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass3.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass3.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +static char *rcsid = "$Id: pass3.c,v 1.2 1994/08/23 20:02:13 mib Exp $"; #endif /* not lint */ #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include "fsck.h" pass3() diff --git a/bsdfsck/pass4.c b/bsdfsck/pass4.c index b7623f4e..449c96ab 100644 --- a/bsdfsck/pass4.c +++ b/bsdfsck/pass4.c @@ -33,13 +33,13 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass4.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass4.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +static char *rcsid = "$Id: pass4.c,v 1.2 1994/08/23 20:02:28 mib Exp $"; #endif /* not lint */ #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include #include #include "fsck.h" -- cgit v1.2.3 From 8d585b0e63babb0788896123ef287c8b77237c75 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:02:44 +0000 Subject: Formerly pass5.c.~2~ --- bsdfsck/pass5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsdfsck/pass5.c b/bsdfsck/pass5.c index 66e9efea..a802e35a 100644 --- a/bsdfsck/pass5.c +++ b/bsdfsck/pass5.c @@ -33,13 +33,13 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass5.c 8.2 (Berkeley) 2/2/94";*/ -static char *rcsid = "$Id: pass5.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +static char *rcsid = "$Id: pass5.c,v 1.2 1994/08/23 20:02:44 mib Exp $"; #endif /* not lint */ #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include #include "fsck.h" -- cgit v1.2.3 From d76c940cfcc3522fdadb035888447e2a2eab37ab Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:03:11 +0000 Subject: Formerly setup.c.~2~ --- bsdfsck/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsdfsck/setup.c b/bsdfsck/setup.c index 475192cb..7dd54d52 100644 --- a/bsdfsck/setup.c +++ b/bsdfsck/setup.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)setup.c 8.2 (Berkeley) 2/21/94";*/ -static char *rcsid = "$Id: setup.c,v 1.1 1994/08/23 19:29:25 mib Exp $"; +static char *rcsid = "$Id: setup.c,v 1.2 1994/08/23 20:03:11 mib Exp $"; #endif /* not lint */ #define DKTYPENAMES #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" #include #include #include -- cgit v1.2.3 From 2e34b4a32a58f3ec680188bcf4df5a8cb4b3fa87 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:07:33 +0000 Subject: Formerly fsck.h.~3~ --- bsdfsck/fsck.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index f26f3d8b..ef0bee8f 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.2 1994/08/23 19:53:52 mib Exp $ + * $Id: fsck.h,v 1.3 1994/08/23 20:07:33 mib Exp $ */ /* Begin GNU Hurd */ @@ -82,6 +82,14 @@ struct odirtemplate { char dotdot_name[4]; /* ditto */ }; +/* These shouldn't be used by anyone, but fsck seems to need it */ +#define DEV_BSIZE 512 +#define MAXPATHLEN 1024 + +/* Provide mode from struct dinode * */ +#define DI_MODE(dp) (((dp)->di_modeh << 16) & (dp)->di_model) + + /* End GNU Hurd additions */ -- cgit v1.2.3 From 8ae0a451f75953471948abd0fa3e914805cfc82a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:08:37 +0000 Subject: Formerly dir.c.~2~ --- bsdfsck/dir.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c index e086439e..a97fd40c 100644 --- a/bsdfsck/dir.c +++ b/bsdfsck/dir.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: dir.c,v 1.1 1994/08/23 19:29:21 mib Exp $"; +static char *rcsid = "$Id: dir.c,v 1.2 1994/08/23 20:08:37 mib Exp $"; #endif /* not lint */ #include #include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" #include #include #include "fsck.h" @@ -275,7 +275,7 @@ fileerror(cwd, ino, errmesg) dp = ginode(ino); if (ftypeok(dp)) pfatal("%s=%s\n", - (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf); + (DI_MODE(dp) & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf); else pfatal("NAME=%s\n", pathbuf); } @@ -292,7 +292,7 @@ adjust(idesc, lcnt) clri(idesc, "UNREF", 0); } else { pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname : - ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE")); + ((DI_MODE(dp) & IFMT) == IFDIR ? "DIR" : "FILE")); pinode(idesc->id_number); printf(" COUNT %d SHOULD BE %d", dp->di_nlink, dp->di_nlink - lcnt); @@ -374,7 +374,7 @@ linkup(orphan, parentdir) bzero((char *)&idesc, sizeof(struct inodesc)); dp = ginode(orphan); - lostdir = (dp->di_mode & IFMT) == IFDIR; + lostdir = (DI_MODE(dp) & IFMT) == IFDIR; pwarn("UNREF %s ", lostdir ? "DIR" : "FILE"); pinode(orphan); if (preen && dp->di_size == 0) @@ -416,7 +416,7 @@ linkup(orphan, parentdir) } } dp = ginode(lfdir); - if ((dp->di_mode & IFMT) != IFDIR) { + if ((DI_MODE(dp) & IFMT) != IFDIR) { pfatal("lost+found IS NOT A DIRECTORY"); if (reply("REALLOCATE") == 0) return (0); -- cgit v1.2.3 From 86b23df2df09b24dbad57ebab8f9e4561ace5ec5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:12:34 +0000 Subject: Formerly inode.c.~2~ --- bsdfsck/inode.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c index 10a01afa..f159173f 100644 --- a/bsdfsck/inode.c +++ b/bsdfsck/inode.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: inode.c,v 1.1 1994/08/23 19:29:21 mib Exp $"; +static char *rcsid = "$Id: inode.c,v 1.2 1994/08/23 20:12:34 mib Exp $"; #endif /* not lint */ #include #include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" #ifndef SMALL #include #endif @@ -64,7 +64,7 @@ ckinode(dp, idesc) idesc->id_fix = DONTKNOW; idesc->id_entryno = 0; idesc->id_filesize = dp->di_size; - mode = dp->di_mode & IFMT; + mode = DI_MODE(dp) & IFMT; if (mode == IFBLK || mode == IFCHR || (mode == IFLNK && (dp->di_size < sblock.fs_maxsymlinklen || (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) @@ -382,7 +382,7 @@ clri(idesc, type, flag) dp = ginode(idesc->id_number); if (flag == 1) { pwarn("%s %s", type, - (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"); + (DI_MODE(dp) & IFMT) == IFDIR ? "DIR" : "FILE"); pinode(idesc->id_number); } if (preen || reply("CLEAR") == 1) { @@ -441,7 +441,7 @@ pinode(ino) else #endif printf("%u ", (unsigned)dp->di_uid); - printf("MODE=%o\n", dp->di_mode); + printf("MODE=%o\n", DI_MODE(dp)); if (preen) printf("%s: ", cdevname); printf("SIZE=%qu ", dp->di_size); @@ -514,7 +514,12 @@ allocino(request, type) statemap[ino] = USTATE; return (0); } +#if 0 dp->di_mode = type; +#else + dp->di_modeh = (type & 0xffff0000) >> 16; + dp->di_model = (type & 0x0000ffff); +#endif (void)time(&dp->di_atime.ts_sec); dp->di_mtime = dp->di_ctime = dp->di_atime; dp->di_size = sblock.fs_fsize; -- cgit v1.2.3 From 29416391d928294f00ce6bf92474e4ce213f9589 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:15:16 +0000 Subject: Formerly pass1.c.~2~ --- bsdfsck/pass1.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bsdfsck/pass1.c b/bsdfsck/pass1.c index cc15c199..44a35fe8 100644 --- a/bsdfsck/pass1.c +++ b/bsdfsck/pass1.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass1.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass1.c,v 1.1 1994/08/23 19:29:23 mib Exp $"; +static char *rcsid = "$Id: pass1.c,v 1.2 1994/08/23 20:15:16 mib Exp $"; #endif /* not lint */ #include #include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" #include #include #include "fsck.h" @@ -99,13 +99,13 @@ checkinode(inumber, idesc) char *symbuf; dp = getnextinode(inumber); - mode = dp->di_mode & IFMT; + mode = DI_MODE(dp) & IFMT; if (mode == 0) { if (bcmp((char *)dp->di_db, (char *)zino.di_db, NDADDR * sizeof(daddr_t)) || bcmp((char *)dp->di_ib, (char *)zino.di_ib, NIADDR * sizeof(daddr_t)) || - dp->di_mode || dp->di_size) { + DI_MODE(dp) || dp->di_size) { pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber); if (reply("CLEAR") == 1) { dp = ginode(inumber); @@ -126,7 +126,12 @@ checkinode(inumber, idesc) if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) { dp = ginode(inumber); dp->di_size = sblock.fs_fsize; +#if 0 dp->di_mode = IFREG|0600; +#else + dp->di_modeh = 0; + dp->di_model = IFREG|0600; +#endif inodirty(); } ndb = howmany(dp->di_size, sblock.fs_bsize); -- cgit v1.2.3 From dcb05babce12bb748acd05f0b429ad25a0ae16f1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:17:45 +0000 Subject: Formerly pass2.c.~2~ --- bsdfsck/pass2.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bsdfsck/pass2.c b/bsdfsck/pass2.c index df3af93c..8d03b734 100644 --- a/bsdfsck/pass2.c +++ b/bsdfsck/pass2.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass2.c 8.2 (Berkeley) 2/27/94";*/ -static char *rcsid = "$Id: pass2.c,v 1.1 1994/08/23 19:29:24 mib Exp $"; +static char *rcsid = "$Id: pass2.c,v 1.2 1994/08/23 20:17:45 mib Exp $"; #endif /* not lint */ #include #include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" #include #include #include "fsck.h" @@ -92,8 +92,13 @@ pass2() if (reply("FIX") == 0) errexit(""); dp = ginode(ROOTINO); +#if 0 dp->di_mode &= ~IFMT; dp->di_mode |= IFDIR; +#else + dp->dp_model &= ~IFMT; + dp->dp_model |= IFDIR; +#endif inodirty(); break; @@ -144,7 +149,12 @@ pass2() } } bzero((char *)&dino, sizeof(struct dinode)); +#if 0 dino.di_mode = IFDIR; +#else + dino.di_modeh = 0; + dino.di_model = IFDIR; +#endif dp->di_size = inp->i_isize; bcopy((char *)&inp->i_blks[0], (char *)&dp->di_db[0], (size_t)inp->i_numblks); @@ -371,7 +381,7 @@ again: break; dp = ginode(dirp->d_ino); statemap[dirp->d_ino] = - (dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE; + (DI_MODE(dp) & IFMT) == IFDIR ? DSTATE : FSTATE; lncntp[dirp->d_ino] = dp->di_nlink; goto again; -- cgit v1.2.3 From 4861b7c4e083ac80712404662fee0accfd7dbb70 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Aug 1994 20:18:15 +0000 Subject: entered into RCS --- bsdfsck/utilities.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bsdfsck/utilities.c b/bsdfsck/utilities.c index 5c31061c..2141e7f8 100644 --- a/bsdfsck/utilities.c +++ b/bsdfsck/utilities.c @@ -33,14 +33,14 @@ #ifndef lint /*static char sccsid[] = "from: @(#)utilities.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: utilities.c,v 1.1 1994/08/23 19:29:26 mib Exp $"; +static char *rcsid = "$Id: utilities.c,v 1.2 1994/08/23 20:18:15 mib Exp $"; #endif /* not lint */ #include #include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" #include #include #include @@ -52,7 +52,7 @@ long diskreads, totalreads; /* Disk cache statistics */ ftypeok(dp) struct dinode *dp; { - switch (dp->di_mode & IFMT) { + switch (DI_MODE(dp) & IFMT) { case IFDIR: case IFREG: @@ -65,7 +65,7 @@ ftypeok(dp) default: if (debug) - printf("bad file type 0%o\n", dp->di_mode); + printf("bad file type 0%o\n", DI_MODE(dp)); return (0); } } -- cgit v1.2.3 From 51879167634d0881ae6fba2208e7b7d5f824e913 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 24 Aug 1994 15:11:08 +0000 Subject: Formerly fsck.h.~4~ --- bsdfsck/fsck.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index ef0bee8f..9f247804 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.3 1994/08/23 20:07:33 mib Exp $ + * $Id: fsck.h,v 1.4 1994/08/24 15:11:08 mib Exp $ */ /* Begin GNU Hurd */ @@ -89,6 +89,7 @@ struct odirtemplate { /* Provide mode from struct dinode * */ #define DI_MODE(dp) (((dp)->di_modeh << 16) & (dp)->di_model) +#define NBBY 8 /* End GNU Hurd additions */ -- cgit v1.2.3 From 87019360208204cfc6951c3985423fbbe8a8eeab Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 24 Aug 1994 15:11:56 +0000 Subject: entered into RCS --- bsdfsck/pass2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsdfsck/pass2.c b/bsdfsck/pass2.c index 8d03b734..184106c1 100644 --- a/bsdfsck/pass2.c +++ b/bsdfsck/pass2.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass2.c 8.2 (Berkeley) 2/27/94";*/ -static char *rcsid = "$Id: pass2.c,v 1.2 1994/08/23 20:17:45 mib Exp $"; +static char *rcsid = "$Id: pass2.c,v 1.3 1994/08/24 15:11:56 mib Exp $"; #endif /* not lint */ #include @@ -96,8 +96,8 @@ pass2() dp->di_mode &= ~IFMT; dp->di_mode |= IFDIR; #else - dp->dp_model &= ~IFMT; - dp->dp_model |= IFDIR; + dp->di_model &= ~IFMT; + dp->di_model |= IFDIR; #endif inodirty(); break; -- cgit v1.2.3 From d8217ba822954c0f6e4088dc9b34ebf578cb2e84 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 25 Aug 1994 15:14:25 +0000 Subject: Formerly Makefile.~4~ --- bsdfsck/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index b8d9f2a3..a4d8e2fb 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -19,9 +19,9 @@ dir := fsck makemode := utility SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ - pass5.c preen.c setup.c utilities.c + pass5.c setup.c utilities.c # preen.c OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ - pass5.o preen.o setup.o utilities.o + pass5.o setup.o utilities.o # preen.o target = fsck include ../Makeconf -- cgit v1.2.3 From defc157175896fb7b5e6542b85125f4311718cc8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 25 Aug 1994 15:17:16 +0000 Subject: Formerly fsck.h.~5~ --- bsdfsck/fsck.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index 9f247804..6b99eb4f 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.4 1994/08/24 15:11:08 mib Exp $ + * $Id: fsck.h,v 1.5 1994/08/25 15:17:16 mib Exp $ */ /* Begin GNU Hurd */ @@ -91,6 +91,14 @@ struct odirtemplate { #define NBBY 8 +#define MAXPHYS (64 * 1024) + +/* The fsck code in setup.c sets the fs_csp table which ufs doesn't want. + So here is the fs_cs macro from ufs for use when that table is real. */ +#undef fs_cs +#define fs_cs(fs, indx) \ + fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask] + /* End GNU Hurd additions */ -- cgit v1.2.3 From 0358e74b41cd8682e1f3d1c71b79a7d2df8e19e4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 25 Aug 1994 15:18:07 +0000 Subject: Formerly main.c.~3~ --- bsdfsck/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bsdfsck/main.c b/bsdfsck/main.c index 609cad6b..3535edca 100644 --- a/bsdfsck/main.c +++ b/bsdfsck/main.c @@ -39,15 +39,15 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)main.c 8.2 (Berkeley) 1/23/94";*/ -static char *rcsid = "$Id: main.c,v 1.2 1994/08/23 20:00:23 mib Exp $"; +static char *rcsid = "$Id: main.c,v 1.3 1994/08/25 15:18:07 mib Exp $"; #endif /* not lint */ #include #include -#include +/*#include */ #include "../ufs/dinode.h" #include "../ufs/fs.h" -#include +/* #include */ #include #include #include @@ -125,10 +125,14 @@ main(argc, argv) (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0); exit(0); } + fprintf (stderr, "You must explicitly name the filesystem to check\n"); + exit (1); +#if 0 ret = checkfstab(preen, maxrun, docheck, checkfilesys); if (returntosingle) exit(2); exit(ret); +#endif } argtoi(flag, req, str, base) @@ -145,6 +149,7 @@ argtoi(flag, req, str, base) return (ret); } +#if 0 /* * Determine whether a filesystem should be checked. */ @@ -159,6 +164,7 @@ docheck(fsp) return (0); return (1); } +#endif /* * Check the specified filesystem. @@ -188,8 +194,10 @@ checkfilesys(filesys, mntpt, auxdata, child) */ if (preen == 0) { printf("** Last Mounted on %s\n", sblock.fs_fsmnt); +#if 0 if (hotroot) printf("** Root file system\n"); +#endif printf("** Phase 1 - Check Blocks and Sizes\n"); } pass1(); @@ -289,6 +297,7 @@ checkfilesys(filesys, mntpt, auxdata, child) return (0); if (!preen) printf("\n***** FILE SYSTEM WAS MODIFIED *****\n"); +#if 0 if (hotroot) { struct statfs stfs_buf; /* @@ -315,5 +324,6 @@ checkfilesys(filesys, mntpt, auxdata, child) sync(); return (4); } +#endif return (0); } -- cgit v1.2.3 From 5f380e7bea94ec1407108ef4573f9eddf1b375c0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 25 Aug 1994 15:22:35 +0000 Subject: entered into RCS --- bsdfsck/setup.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bsdfsck/setup.c b/bsdfsck/setup.c index 7dd54d52..f65ade47 100644 --- a/bsdfsck/setup.c +++ b/bsdfsck/setup.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)setup.c 8.2 (Berkeley) 2/21/94";*/ -static char *rcsid = "$Id: setup.c,v 1.2 1994/08/23 20:03:11 mib Exp $"; +static char *rcsid = "$Id: setup.c,v 1.3 1994/08/25 15:22:35 mib Exp $"; #endif /* not lint */ #define DKTYPENAMES @@ -43,7 +43,7 @@ static char *rcsid = "$Id: setup.c,v 1.2 1994/08/23 20:03:11 mib Exp $"; #include "../ufs/fs.h" #include #include -#include +/* #include */ #include #include #include @@ -62,7 +62,7 @@ setup(dev) { long cg, size, asked, i, j; long bmapsize; - struct disklabel *lp; +/* struct disklabel *lp; */ off_t sizepb; struct stat statb; struct fs proto; @@ -100,9 +100,11 @@ setup(dev) asblk.b_un.b_buf = malloc(SBSIZE); if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errexit("cannot allocate space for superblock\n"); +#if 0 if (lp = getdisklabel((char *)NULL, fsreadfd)) dev_bsize = secsize = lp->d_secsize; else +#endif dev_bsize = secsize = DEV_BSIZE; /* * Read in the superblock, looking for alternates if necessary @@ -391,6 +393,16 @@ badsb(listerr, s) pfatal("BAD SUPER BLOCK: %s\n", s); } +/* XXX */ +calcsb (dev, devfd, fs) + char *dev; + int devfd; + struct fs *fs; +{ + return 0; +} + +#if 0 /* * Calculate a prototype superblock based on information in the disk label. * When done the cgsblock macro can be calculated and the fs_ncg field @@ -465,3 +477,4 @@ getdisklabel(s, fd) } return (&lab); } +#endif -- cgit v1.2.3 From 885d5e9c5de2858aabe8886354657a4570c90716 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Aug 1994 16:04:42 +0000 Subject: Formerly fsck.h.~6~ --- bsdfsck/fsck.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index 6b99eb4f..23542d6d 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.5 1994/08/25 15:17:16 mib Exp $ + * $Id: fsck.h,v 1.6 1994/08/26 16:04:42 mib Exp $ */ /* Begin GNU Hurd */ @@ -99,6 +99,18 @@ struct odirtemplate { #define fs_cs(fs, indx) \ fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask] +#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)))) + +/* missing macros */ + +/* Convert bytes to disk blocks */ +#define btodb(bytes) ((bytes) / DEV_BSIZE) + + + /* End GNU Hurd additions */ -- cgit v1.2.3 From 9a37d9b2eb925a3150de43594ea818df3965b0b0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Aug 1994 16:08:07 +0000 Subject: Formerly Makefile.~5~ --- bsdfsck/Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index a4d8e2fb..b6487f8a 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -26,10 +26,4 @@ target = fsck include ../Makeconf -all: fsck.native - -fsck.native: $(addprefix native-,$(OBJS)) - rsh $(mighost) -n cd `pwd` \; gcc $^ -o $@ - -native-%.o: %.c - rsh $(mighost) -n cd `pwd` \; gcc -c $^ -o $@ +$(OBJS): fsck.h \ No newline at end of file -- cgit v1.2.3 From e03e10773bb1a0a31c3c1af5da2c896b16484d8f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Aug 1994 16:35:02 +0000 Subject: Formerly inode.c.~3~ --- bsdfsck/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c index f159173f..8e1b646f 100644 --- a/bsdfsck/inode.c +++ b/bsdfsck/inode.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: inode.c,v 1.2 1994/08/23 20:12:34 mib Exp $"; +static char *rcsid = "$Id: inode.c,v 1.3 1994/08/26 16:35:02 mib Exp $"; #endif /* not lint */ #include @@ -100,6 +100,13 @@ ckinode(dp, idesc) sizepb *= NINDIR(&sblock); remsize -= sizepb; } + /* GNU Hurd extension. */ + if (dino.di_trans) + { + idesc->id_blkno = dino.di_trans; + idesc->id_numfrags = sblock.fs_frag; + return (*idesc->id_func)(idesc); + } return (KEEPON); } -- cgit v1.2.3 From 6b2ac8ea0a80bc474988a11d36863204363dc2dd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Aug 1994 18:03:07 +0000 Subject: entered into RCS --- bsdfsck/pass5.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/bsdfsck/pass5.c b/bsdfsck/pass5.c index a802e35a..11877f9d 100644 --- a/bsdfsck/pass5.c +++ b/bsdfsck/pass5.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass5.c 8.2 (Berkeley) 2/2/94";*/ -static char *rcsid = "$Id: pass5.c,v 1.2 1994/08/23 20:02:44 mib Exp $"; +static char *rcsid = "$Id: pass5.c,v 1.3 1994/08/26 18:03:07 mib Exp $"; #endif /* not lint */ #include @@ -43,6 +43,44 @@ static char *rcsid = "$Id: pass5.c,v 1.2 1994/08/23 20:02:44 mib Exp $"; #include #include "fsck.h" +/* From ../ufs/subr.c: */ + +/* + * Update the frsum fields to reflect addition or deletion + * of some frags. + */ +void +ffs_fragacct(fs, fragmap, fraglist, cnt) + struct fs *fs; + int fragmap; + long fraglist[]; + int cnt; +{ + int inblk; + register int field, subfield; + register int siz, pos; + + inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1; + fragmap <<= 1; + for (siz = 1; siz < fs->fs_frag; siz++) { + if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0) + continue; + field = around[siz]; + subfield = inside[siz]; + for (pos = siz; pos <= fs->fs_frag; pos++) { + if ((fragmap & field) == subfield) { + fraglist[siz] += cnt; + pos += siz; + field <<= siz; + subfield <<= siz; + } + field <<= 1; + subfield <<= 1; + } + } +} + + pass5() { int c, blk, frags, basesize, sumsize, mapsize, savednrpos; -- cgit v1.2.3 From 7cc7f26c068beba923b9d7074e04772d2f685972 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Aug 1994 18:06:30 +0000 Subject: entered into RCS --- bsdfsck/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bsdfsck/main.c b/bsdfsck/main.c index 3535edca..adf84f74 100644 --- a/bsdfsck/main.c +++ b/bsdfsck/main.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)main.c 8.2 (Berkeley) 1/23/94";*/ -static char *rcsid = "$Id: main.c,v 1.3 1994/08/25 15:18:07 mib Exp $"; +static char *rcsid = "$Id: main.c,v 1.4 1994/08/26 18:06:30 mib Exp $"; #endif /* not lint */ #include @@ -57,6 +57,9 @@ static char *rcsid = "$Id: main.c,v 1.3 1994/08/25 15:18:07 mib Exp $"; void catch(), catchquit(), voidquit(); int returntosingle; +/* GNU Hurd patch */ +#define blockcheck(a) (a) + main(argc, argv) int argc; char *argv[]; @@ -64,7 +67,8 @@ main(argc, argv) int ch; int ret, maxrun = 0; extern int docheck(), checkfilesys(); - extern char *optarg, *blockcheck(); + extern char *optarg; +/* extern char *blockcheck(); */ extern int optind; sync(); -- cgit v1.2.3 From 0057b128c0661dbc6ba01acc49eadcec6a9b8493 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 30 Aug 1994 17:36:23 +0000 Subject: Initial revision --- ufs/inode.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+) create mode 100644 ufs/inode.c diff --git a/ufs/inode.c b/ufs/inode.c new file mode 100644 index 00000000..113f42d9 --- /dev/null +++ b/ufs/inode.c @@ -0,0 +1,510 @@ +/* Inode management routines + Copyright (C) 1994 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 + published by the Free Software Foundation; either version 2, 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 "ufs.h" +#include "dinode.h" +#include "fs.h" +#include + +#define INOHSZ 512 +#if ((INOHSZ&(INOHSZ-1)) == 0) +#define INOHASH(ino) ((ino)&(INOHSZ-1)) +#else +#define INOHASH(ino) (((unsigned)(ino))%INOHSZ) +#endif + +static struct node *nodehash[INOHSZ]; +static error_t read_disknode (struct node *np); + +spin_lock_t gennumberlock = SPIN_LOCK_INITIALIZER; + +/* Initialize the inode hash table. */ +void +inode_init () +{ + int n; + for (n = 0; n < INOHSZ; n++) + nodehash[n] = 0; + mutex_init (&dinmaplock); + mutex_init (&sinmaplock); +} + +/* Fetch inode INUM, set *NPP to the node structure; + gain one user reference and lock the node. */ +error_t +iget (ino_t inum, struct node **npp) +{ + struct disknode *dn; + struct node *np; + error_t err; + + spin_lock (&diskfs_node_refcnt_lock); + for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext) + { + if (np->dn->number != inum) + continue; + + np->references++; + spin_unlock (&diskfs_node_refcnt_lock); + mutex_lock (&np->lock); + *npp = np; + return 0; + } + + dn = malloc (sizeof (struct disknode)); + + dn->number = inum; + dn->dirents = 0; + + mutex_init (&dn->rwlock_master); + condition_init (&dn->rwlock_wakeup); + rwlock_init (&dn->dinlock); + rwlock_init (&dn->sinlock); + rwlock_init (&dn->datalock); + dn->dinloc = 0; + dn->sinloc = 0; + dn->sininfo = 0; + dn->fileinfo = 0; + + np = diskfs_make_node (dn); + mutex_lock (&np->lock); + dn->hnext = nodehash[INOHASH(inum)]; + if (dn->hnext) + dn->hnext->dn->hprevp = &dn->hnext; + dn->hprevp = &nodehash[INOHASH(inum)]; + nodehash[INOHASH(inum)] = np; + spin_unlock (&diskfs_node_refcnt_lock); + + err = read_disknode (np); + if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) + np->allocsize = fragroundup (sblock, np->dn_stat.st_size); + else + np->allocsize = blkroundup (sblock, np->dn_stat.st_size); + + /* XXX */ + assert (np->allocsize || !dinodes[np->dn->number].di_db[0]); + + if (!diskfs_readonly && !np->dn_stat.st_gen) + { + spin_lock (&gennumberlock); + if (++nextgennumber < diskfs_mtime->seconds) + nextgennumber = diskfs_mtime->seconds; + np->dn_stat.st_gen = nextgennumber; + spin_unlock (&gennumberlock); + np->dn_set_ctime = 1; + } + + if (err) + return err; + else + { + *npp = np; + return 0; + } +} + +/* Lookup node INUM (which must have a reference already) and return it + without allocating any new references. */ +struct node * +ifind (ino_t inum) +{ + struct node *np; + + spin_lock (&diskfs_node_refcnt_lock); + for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext) + { + if (np->dn->number != inum) + continue; + + assert (np->references); + spin_unlock (&diskfs_node_refcnt_lock); + return np; + } + assert (0); +} + +/* The last reference to a node has gone away; drop + it from the hash table and clean all state in the dn structure. */ +void +diskfs_node_norefs (struct node *np) +{ + *np->dn->hprevp = np->dn->hnext; + if (np->dn->hnext) + np->dn->hnext->dn->hprevp = np->dn->hprevp; + if (np->dn->dirents) + free (np->dn->dirents); + assert (!np->dn->sininfo && !np->dn->fileinfo); + assert (!np->dn->dinloc && !np->dn->sinloc); + free (np->dn); + free (np); +} + +/* The last hard referencs to a node has gone away; arrange to have + all the weak references dropped that can be. */ +void +diskfs_lost_hardrefs (struct node *np) +{ + drop_pager_softrefs (np); +} + +/* A new hard reference to a node has been created; it's now OK to + have unused weak references. */ +void +diskfs_new_hardrefs (struct node *np) +{ + allow_pager_softrefs (np); +} + +/* Read stat information out of the dinode. */ +static error_t +read_disknode (struct node *np) +{ + struct stat *st = &np->dn_stat; + struct dinode *di = &dinodes[np->dn->number]; + error_t err; + + err = diskfs_catch_exception (); + if (err) + return err; + + st->st_fstype = FSTYPE_UFS; + st->st_fsid = 0; /* XXX should fill this */ + st->st_ino = np->dn->number; + st->st_gen = di->di_gen; + st->st_rdev = di->di_rdev; + st->st_mode = di->di_model | (di->di_modeh << 16); + st->st_nlink = di->di_nlink; + st->st_size = di->di_size; +#ifdef notyet + st->st_atimespec = di->di_atime; + st->st_mtimespec = di->di_mtime; + st->st_ctimespec = di->di_ctime; +#else + st->st_atime = di->di_atime.ts_sec; + st->st_atime_usec = di->di_atime.ts_nsec / 1000; + st->st_mtime = di->di_mtime.ts_sec; + st->st_mtime_usec = di->di_mtime.ts_nsec / 1000; + st->st_ctime = di->di_ctime.ts_sec; + st->st_ctime_usec = di->di_ctime.ts_nsec / 1000; +#endif + st->st_blksize = sblock->fs_bsize; + st->st_blocks = di->di_blocks; + st->st_flags = di->di_flags; + + if (sblock->fs_inodefmt < FS_44INODEFMT) + { + st->st_uid = di->di_ouid; + st->st_gid = di->di_ogid; + st->st_author = 0; + } + else + { + st->st_uid = di->di_uid; + st->st_gid = di->di_gid; + st->st_author = di->di_author; + if (st->st_author == -1) + st->st_author = st->st_uid; + } + + diskfs_end_catch_exception (); + if (!S_ISBLK (st->st_mode) && !S_ISCHR (st->st_mode)) + st->st_rdev = 0; + return 0; +} + +static void +write_node (struct node *np) +{ + struct stat *st = &np->dn_stat; + struct dinode *di = &dinodes[np->dn->number]; + error_t err; + + assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); + if (np->dn_stat_dirty) + { + assert (!diskfs_readonly); + + err = diskfs_catch_exception (); + if (err) + return; + + di->di_gen = st->st_gen; + + if (S_ISBLK (st->st_mode) || S_ISCHR (st->st_mode)) + di->di_rdev = st->st_rdev; + + /* We happen to know that the stat mode bits are the same + as the ufs mode bits. */ + + if (compat_mode == COMPAT_GNU) + { + di->di_model = st->st_mode & 0xffff; + di->di_modeh = (st->st_mode >> 16) & 0xffff; + } + else + { + di->di_model = st->st_mode & 0xffff; + di->di_modeh = 0; + } + + if (compat_mode != COMPAT_BSD42) + { + di->di_uid = st->st_uid; + di->di_gid = st->st_gid; + } + + if (sblock->fs_inodefmt < FS_44INODEFMT) + { + di->di_ouid = st->st_uid & 0xffff; + di->di_ogid = st->st_gid & 0xffff; + } + else if (compat_mode == COMPAT_GNU) + di->di_author = st->st_author; + + di->di_nlink = st->st_nlink; + di->di_size = st->st_size; +#ifdef notyet + di->di_atime = st->st_atimespec; + di->di_mtime = st->st_mtimespec; + di->di_ctime = st->st_ctimespec; +#else + di->di_atime.ts_sec = st->st_atime; + di->di_atime.ts_nsec = st->st_atime_usec * 1000; + di->di_mtime.ts_sec = st->st_mtime; + di->di_mtime.ts_nsec = st->st_mtime_usec * 1000; + di->di_ctime.ts_sec = st->st_ctime; + di->di_ctime.ts_nsec = st->st_ctime_usec * 1000; +#endif + di->di_blocks = st->st_blocks; + di->di_flags = st->st_flags; + + diskfs_end_catch_exception (); + np->dn_stat_dirty = 0; + } +} + +/* See if we should create a symlink by writing it directly into + the block pointer array. Returning EINVAL tells diskfs to do it + the usual way. */ +static error_t +create_symlink_hook (struct node *np, char *target) +{ + int len = strlen (target); + error_t err; + + if (!direct_symlink_extension) + return EINVAL; + + assert (!COMPAT_BSD42); + + if (len >= sblock->fs_maxsymlinklen) + return EINVAL; + + err = diskfs_catch_exception (); + if (err) + return err; + + bcopy (target, dinodes[np->dn->number].di_shortlink, len); + np->dn_stat.st_size = len; + np->dn_set_ctime = 1; + np->dn_set_mtime = 1; + + diskfs_end_catch_exception (); + return 0; +} +error_t (*diskfs_create_symlink_hook)(struct node *, char *) + = create_symlink_hook; + +/* Check if this symlink is stored directly in the block pointer array. + Returning EINVAL tells diskfs to do it the usual way. */ +static error_t +read_symlink_hook (struct node *np, + char *buf) +{ + error_t err; + + if (!direct_symlink_extension + || np->dn_stat.st_size >= sblock->fs_maxsymlinklen) + return EINVAL; + + err = diskfs_catch_exception (); + if (err) + return err; + + bcopy (dinodes[np->dn->number].di_shortlink, buf, np->dn_stat.st_size); + np->dn_set_atime = 1; + + diskfs_end_catch_exception (); + return 0; +} +error_t (*diskfs_read_symlink_hook)(struct node *, char *) + = read_symlink_hook; + + +/* Write all active disknodes into the dinode pager. */ +void +write_all_disknodes () +{ + int n; + struct node *np; + + spin_lock (&diskfs_node_refcnt_lock); + for (n = 0; n < INOHSZ; n++) + for (np = nodehash[n]; np; np = np->dn->hnext) + { + diskfs_set_node_times (np); + write_node (np); + } + spin_unlock (&diskfs_node_refcnt_lock); +} + +void +diskfs_write_disknode (struct node *np, int wait) +{ + write_node (np); + sync_dinode (np, wait); +} + + +/* Implement the diskfs_set_statfs callback from the diskfs library; + see for the interface description. */ +error_t +diskfs_set_statfs (struct fsys_statfsbuf *st) +{ + st->fsys_stb_type = FSTYPE_UFS; + st->fsys_stb_bsize = sblock->fs_bsize; + st->fsys_stb_fsize = sblock->fs_fsize; + st->fsys_stb_blocks = sblock->fs_dsize; + st->fsys_stb_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag + + sblock->fs_cstotal.cs_nffree); + st->fsys_stb_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) + - (sblock->fs_dsize - st->fsys_stb_bfree)); + st->fsys_stb_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ + st->fsys_stb_ffree = sblock->fs_cstotal.cs_nifree; + st->fsys_stb_fsid = 0; + return 0; +} + +/* Implement the diskfs_set_translator callback from the diskfs + library; see for the interface description. */ +error_t +diskfs_set_translator (struct node *np, char *name, u_int namelen, + struct protid *cred) +{ + daddr_t blkno; + error_t err; + char buf[sblock->fs_bsize]; + + if (compat_mode != COMPAT_GNU) + return EOPNOTSUPP; + + if (namelen + sizeof (u_int) > sblock->fs_bsize) + return ENAMETOOLONG; + + err = diskfs_catch_exception (); + if (err) + return err; + + blkno = dinodes[np->dn->number].di_trans; + + if (namelen && !blkno) + { + /* Allocate block for translator */ + err = ffs_alloc (np, 0, 0, sblock->fs_bsize, &blkno, cred); + if (err) + { + diskfs_end_catch_exception (); + return err; + } + dinodes[np->dn->number].di_trans = blkno; + np->dn_set_ctime = 1; + } + else if (!namelen && blkno) + { + /* Clear block for translator going away. */ + ffs_blkfree (np, blkno, sblock->fs_bsize); + dinodes[np->dn->number].di_trans = 0; + np->dn_set_ctime = 1; + } + + diskfs_end_catch_exception (); + + if (namelen) + { + bcopy (&namelen, buf, sizeof (u_int)); + bcopy (name, buf + sizeof (u_int), namelen); + err = dev_write_sync (fsbtodb (sblock, blkno), + (vm_address_t)buf, sblock->fs_bsize); + np->dn_set_ctime = 1; + } + return err; +} + +/* Implement the diskfs_get_translator callback from the diskfs library. + See for the interface description. */ +error_t +diskfs_get_translator (struct node *np, char **namep, u_int *namelen) +{ + error_t err; + daddr_t blkno; + char *buf; + u_int datalen; + + err = diskfs_catch_exception (); + if (err) + return err; + blkno = dinodes[np->dn->number].di_trans; + diskfs_end_catch_exception (); + + assert (blkno); + + err = dev_read_sync (fsbtodb (sblock, blkno), (vm_address_t *)&buf, + sblock->fs_bsize); + if (err) + return err; + + datalen = *(u_int *)buf; + if (datalen > *namelen) + vm_allocate (mach_task_self (), (vm_address_t *) namep, datalen, 1); + bcopy (buf + sizeof (u_int), *namep, datalen); + *namelen = datalen; + return 0; +} + +/* Implement the diskfs_node_translated callback from the diskfs library. + See for the interface description. */ +int +diskfs_node_translated (struct node *np) +{ + int ret; + + if (diskfs_catch_exception ()) + return 0; + + ret = !! dinodes[np->dn->number].di_trans; + diskfs_end_catch_exception (); + return ret; +} + +/* Called when all hard ports have gone away. */ +void +diskfs_shutdown_soft_ports () +{ + /* Should initiate termination of internally held pager ports + (the only things that should be soft) XXX */ +} + -- cgit v1.2.3 From bf2eeb5c23810e91ebed3ab0104e63e88d869382 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 1 Sep 1994 15:39:31 +0000 Subject: entered into RCS --- ufs/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/tables.c b/ufs/tables.c index 81e3c25c..d345b9e4 100644 --- a/ufs/tables.c +++ b/ufs/tables.c @@ -34,7 +34,7 @@ * @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93 */ -#include "ufs.h" +#include #include "fs.h" /* -- cgit v1.2.3 From 178faf94766ba185999f950c9728ecbad7163cbf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 1 Sep 1994 15:41:03 +0000 Subject: Formerly Makefile.~6~ --- bsdfsck/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index b6487f8a..e40ceb67 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -21,9 +21,12 @@ makemode := utility SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c # preen.c OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ - pass5.o setup.o utilities.o # preen.o + pass5.o setup.o utilities.o tables.o # preen.o target = fsck include ../Makeconf -$(OBJS): fsck.h \ No newline at end of file +$(OBJS): fsck.h + +tables.o: ../ufs/tables.c + $(CC) $(CFLAGS) -c -o $@ $< -- cgit v1.2.3 From fc133667ee978c7ead629a2736e42122dd41ad6d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 1 Sep 1994 18:50:58 +0000 Subject: Formerly fsck.h.~7~ --- bsdfsck/fsck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index 23542d6d..c2768e9b 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.6 1994/08/26 16:04:42 mib Exp $ + * $Id: fsck.h,v 1.7 1994/09/01 18:50:58 mib Exp $ */ /* Begin GNU Hurd */ @@ -87,7 +87,7 @@ struct odirtemplate { #define MAXPATHLEN 1024 /* Provide mode from struct dinode * */ -#define DI_MODE(dp) (((dp)->di_modeh << 16) & (dp)->di_model) +#define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model) #define NBBY 8 -- cgit v1.2.3 From f2bd17119a00f994b4de116c2e8524017f7da4b0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 1 Sep 1994 19:15:35 +0000 Subject: Formerly inode.c.~4~ --- bsdfsck/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c index 8e1b646f..6282d1d1 100644 --- a/bsdfsck/inode.c +++ b/bsdfsck/inode.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: inode.c,v 1.3 1994/08/26 16:35:02 mib Exp $"; +static char *rcsid = "$Id: inode.c,v 1.4 1994/09/01 19:15:35 mib Exp $"; #endif /* not lint */ #include @@ -65,9 +65,10 @@ ckinode(dp, idesc) idesc->id_entryno = 0; idesc->id_filesize = dp->di_size; mode = DI_MODE(dp) & IFMT; - if (mode == IFBLK || mode == IFCHR || (mode == IFLNK && - (dp->di_size < sblock.fs_maxsymlinklen || - (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) + if (mode == IFBLK || mode == IFCHR + || (mode == IFLNK && sblock.fs_maxsymlinklen != -1 && + (dp->di_size < sblock.fs_maxsymlinklen + || (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) return (KEEPON); dino = *dp; ndb = howmany(dino.di_size, sblock.fs_bsize); -- cgit v1.2.3 From a6632578d81f1ba501495295bcfe9d65f4986c5d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 1 Sep 1994 19:19:17 +0000 Subject: Formerly pass1.c.~3~ --- bsdfsck/pass1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bsdfsck/pass1.c b/bsdfsck/pass1.c index 44a35fe8..6f254ca8 100644 --- a/bsdfsck/pass1.c +++ b/bsdfsck/pass1.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass1.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass1.c,v 1.2 1994/08/23 20:15:16 mib Exp $"; +static char *rcsid = "$Id: pass1.c,v 1.3 1994/09/01 19:19:17 mib Exp $"; #endif /* not lint */ #include @@ -174,8 +174,9 @@ checkinode(inumber, idesc) * Fake ndb value so direct/indirect block checks below * will detect any garbage after symlink string. */ - if (dp->di_size < sblock.fs_maxsymlinklen || - (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0)) { + if (sblock.fs_maxsymlinklen != -1 && + (dp->di_size < sblock.fs_maxsymlinklen || + (sblock.fs_maxsymlinklen == 0 && dp->di_blocks == 0))) { ndb = howmany(dp->di_size, sizeof(daddr_t)); if (ndb > NDADDR) { j = ndb - NDADDR; -- cgit v1.2.3 From 1a8d2047c10aae430523154ef02db5b255d634e9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 6 Sep 1994 15:29:52 +0000 Subject: Formerly inode.c.~31~ --- ufs/inode.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 113f42d9..bfa50ece 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -95,9 +95,6 @@ iget (ino_t inum, struct node **npp) else np->allocsize = blkroundup (sblock, np->dn_stat.st_size); - /* XXX */ - assert (np->allocsize || !dinodes[np->dn->number].di_db[0]); - if (!diskfs_readonly && !np->dn_stat.st_gen) { spin_lock (&gennumberlock); -- cgit v1.2.3 From c8ca0dcbcd9a118480651e7984a2962fe60f1ee1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 8 Sep 1994 19:48:35 +0000 Subject: Formerly Makefile.~2~ --- ufs-utils/Makefile | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index 4cc571a1..1275854c 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -1,15 +1,29 @@ -# from: @(#)Makefile 8.2 (Berkeley) 3/27/94 -# $Id: Makefile,v 1.1 1994/08/23 19:30:43 mib Exp $ +# +# Copyright (C) 1994 Free Software Foundation +# Written by Michael I. Bushnell. +# +# 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. -PROG= newfs -SRCS= dkcksum.c getmntopts.c newfs.c mkfs.c -MAN8= newfs.0 +dir := newfs +makemode := utility -MOUNT= ${.CURDIR}/../mount -CFLAGS+=-DMFS -I${MOUNT} -.PATH: ${MOUNT} ${.CURDIR}/../disklabel +SRCS = mkfs.c newfs.c +OBJS = mkfs.o newfs.o +target = newfs -LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs -MLINKS= newfs.8 mount_mfs.8 newfs.8 mfs.8 +include ../Makeconf -.include -- cgit v1.2.3 From d6ad89474b35776be032ee8dd4a61ab053ee44ce Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 8 Sep 1994 19:51:43 +0000 Subject: Formerly mkfs.c.~2~ --- ufs-utils/mkfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index d35dd10b..aa747403 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.1 1994/08/23 19:30:42 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.2 1994/09/08 19:51:43 mib Exp $"; #endif /* not lint */ #include @@ -41,10 +41,10 @@ static char *rcsid = "$Id: mkfs.c,v 1.1 1994/08/23 19:30:42 mib Exp $"; #include #include #include -#include -#include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/dir.h" +#include "../ufs/fs.h" +/* #include */ #ifndef STANDALONE #include -- cgit v1.2.3 From 28429e9e664ed99b8b27c38d61d5753e6c60d470 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 8 Sep 1994 20:03:28 +0000 Subject: Formerly mkfs.c.~3~ --- ufs-utils/mkfs.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index aa747403..821d67ae 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.2 1994/09/08 19:51:43 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.3 1994/09/08 20:03:28 mib Exp $"; #endif /* not lint */ #include @@ -46,6 +46,30 @@ static char *rcsid = "$Id: mkfs.c,v 1.2 1994/09/08 19:51:43 mib Exp $"; #include "../ufs/fs.h" /* #include */ +/* Begin additions for GNU Hurd */ + +/* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD + 4.4 version that mkfs expects. So we provide here the BSD version. */ +#undef DIRSIZ +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRSIZ(oldfmt, dp) \ + ((oldfmt) ? \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) +#else +#define DIRSIZ(oldfmt, dp) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) +#endif + +#define NBBY 8 + +#define MAXPHYS (64 * 1024) + +/* Provide mode from struct dinode * */ +#define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model) + +/* End additions for GNU Hurd */ + #ifndef STANDALONE #include #include -- cgit v1.2.3 From 0ef4c872307c8c823a7cab440908b93d5d888f89 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 9 Sep 1994 14:11:41 +0000 Subject: entered into RCS --- ufs-utils/newfs.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/ufs-utils/newfs.c b/ufs-utils/newfs.c index f468ef24..efc7dbea 100644 --- a/ufs-utils/newfs.c +++ b/ufs-utils/newfs.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)newfs.c 8.8 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: newfs.c,v 1.1 1994/08/23 19:30:43 mib Exp $"; +static char *rcsid = "$Id: newfs.c,v 1.2 1994/09/09 14:11:41 mib Exp $"; #endif /* not lint */ /* @@ -48,12 +48,12 @@ static char *rcsid = "$Id: newfs.c,v 1.1 1994/08/23 19:30:43 mib Exp $"; #include #include #include -#include +/* #include */ #include -#include +/* #include */ -#include -#include +#include "../ufs/dir.h" +#include "../ufs/fs.h" #include #include @@ -70,13 +70,21 @@ static char *rcsid = "$Id: newfs.c,v 1.1 1994/08/23 19:30:43 mib Exp $"; #include #endif -#include "mntopts.h" +/* #include "mntopts.h" */ +/* GNU Hurd additions */ +#define MAXPATHLEN 2048 + +/* End GNU Hurd additions */ + + +#if 0 struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_ASYNC, { NULL }, }; +#endif #if __STDC__ void fatal(const char *fmt, ...); @@ -168,7 +176,7 @@ int maxbpg; /* maximum blocks per file in a cyl group */ int nrpos = NRPOS; /* # of distinguished rotational positions */ int bbsize = BBSIZE; /* boot block size */ int sbsize = SBSIZE; /* superblock size */ -int mntflags = MNT_ASYNC; /* flags to be passed to mount */ +/* int mntflags = MNT_ASYNC;*/ /* flags to be passed to mount */ u_long memleft; /* virtual memory available */ caddr_t membase; /* start address of memory based filesystem */ #ifdef COMPAT @@ -190,7 +198,7 @@ main(argc, argv) register struct partition *pp; register struct disklabel *lp; struct disklabel *getdisklabel(); - struct partition oldpartition; +/* struct partition oldpartition; */ struct stat st; struct statfs *mp; int fsi, fso, len, n; @@ -201,10 +209,12 @@ main(argc, argv) else progname = *argv; +#if 0 if (strstr(progname, "mfs")) { mfs = 1; Nflag++; } +#endif opstring = mfs ? "NT:a:b:c:d:e:f:i:m:o:s:" : @@ -275,9 +285,12 @@ main(argc, argv) optarg); break; case 'o': +#if 0 if (mfs) getmntopts(optarg, mopts, &mntflags); - else { + else +#endif + { if (strcmp(optarg, "space") == 0) opt = FS_OPTSPACE; else if (strcmp(optarg, "time") == 0) @@ -340,6 +353,7 @@ main(argc, argv) if (fso < 0) fatal("%s: %s", special, strerror(errno)); +#if 0 /* Bail if target special is mounted */ n = getmntinfo(&mp, MNT_NOWAIT); if (n == 0) @@ -361,7 +375,9 @@ main(argc, argv) special, mp->f_mntonname); ++mp; } +#endif } +#if 0 if (mfs && disktype != NULL) { lp = (struct disklabel *)getdiskbyname(disktype); if (lp == NULL) @@ -396,6 +412,16 @@ main(argc, argv) fatal("%s: `%c' partition overlaps boot program", argv[0], *cp); } +#endif + /* GNU Hurd specific here */ + fsi = open (special, O_RDONLY); + if (fsi < 0) + fatal("%s: %s", special, strerror(errno)); + if (fstat(fsi, &st) < 0) + fatal("%s: %s", special, strerror(errno)); + fssize = st.st_size; + /* End GNU Hurd specific */ + if (fssize == 0) fssize = pp->p_size; if (fssize > pp->p_size && !mfs) -- cgit v1.2.3 From 397fb8089309ad7be90d988b1dda054a1fd7f5a9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 9 Sep 1994 14:33:55 +0000 Subject: entered into RCS --- ufs-utils/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index 1275854c..d90a0a7b 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -21,9 +21,9 @@ dir := newfs makemode := utility -SRCS = mkfs.c newfs.c -OBJS = mkfs.o newfs.o -target = newfs +SRCS = mkfs.c # newfs.c +OBJS = mkfs.o # newfs.o +target = mkfs include ../Makeconf -- cgit v1.2.3 From bc7f507a07779cfeff0fd5e4093eab60f9bb37c9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 9 Sep 1994 16:48:27 +0000 Subject: Formerly mkfs.c.~4~ --- ufs-utils/mkfs.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 132 insertions(+), 7 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 821d67ae..f069e600 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.3 1994/09/08 20:03:28 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.4 1994/09/09 16:48:27 mib Exp $"; #endif /* not lint */ #include @@ -45,8 +45,10 @@ static char *rcsid = "$Id: mkfs.c,v 1.3 1994/09/08 20:03:28 mib Exp $"; #include "../ufs/dir.h" #include "../ufs/fs.h" /* #include */ +#include +#include -/* Begin additions for GNU Hurd */ +/* Begin misc additions for GNU Hurd */ /* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD 4.4 version that mkfs expects. So we provide here the BSD version. */ @@ -68,6 +70,10 @@ static char *rcsid = "$Id: mkfs.c,v 1.3 1994/09/08 20:03:28 mib Exp $"; /* Provide mode from struct dinode * */ #define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model) +#define DEV_BSIZE 512 + +#define btodb(bytes) ((bytes) / DEV_BSIZE) + /* End additions for GNU Hurd */ #ifndef STANDALONE @@ -95,6 +101,7 @@ static char *rcsid = "$Id: mkfs.c,v 1.3 1994/09/08 20:03:28 mib Exp $"; /* * variables set up by front end. */ +#define extern extern int mfs; /* run as the memory based filesystem */ extern int Nflag; /* run mkfs without writing file system */ extern int Oflag; /* format as an 4.3BSD file system */ @@ -125,6 +132,7 @@ extern int sbsize; /* superblock size */ extern u_long memleft; /* virtual memory available */ extern caddr_t membase; /* start address of memory based filesystem */ extern caddr_t malloc(), calloc(); +#undef extern union { struct fs fs; @@ -144,6 +152,119 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; int fsi, fso; daddr_t alloc(); +main (int argc, char **argv) +{ + void usage () + { + fprintf (stderr, + "Usage: %s [-N] special nsect ntrak npseck tskew ileave\n", + argv[0]); + exit (1); + } + /* Usage is + mkfs [-N] special nsect ntrak npsect tskew ileave + + All other parameters are computed from defaults and the device itself. */ + char **args; + int fdo, fdi; + char *device; + struct stat st; + + if (argc == 8) + { + if (argv[1][0] != '-' || argv[1][1] != 'N' || argv[1][2] != '\0') + usage (); + Nflag = 1; + args = &argv[2]; + } + else if (argc != 7) + usage (); + else + args = &argv[1]; + + /* Default computation taken from 4.4 BSD newfs.c */ + + device = args[0]; + fdi = open (device, O_RDONLY); + if (fdi == -1) + { + perror (device); + exit (1); + } + fdo = open (device, O_WRONLY); + if (fdo == -1) + { + perror (device); + exit (1); + } + if (fstat (fdi, &st) == -1) + { + perror ("stat"); + exit (1); + } + + mfs = 0; + Oflag = 0; + fssize = st.st_size / DEV_BSIZE; + + ntracks = atoi (args[2]); + if (ntracks == 0) + { + fprintf (stderr, "Bogus ntracks: %d\n", ntracks); + exit (1); + } + + nsectors = atoi (args[1]); + if (nsectors == 0) + { + fprintf (stderr, "Bogus nsectors: %d\n", nsectors); + exit (1); + } + + nphyssectors = atoi (args[3]); + if (nphyssectors == 0) + { + fprintf (stderr, "Bogus npsect: %d\n", nphyssectors); + exit (1); + } + + secpercyl = nsectors * ntracks; + + sectorsize = DEV_BSIZE; + + rpm = 3600; + + interleave = atoi (args[5]); + + trackskew = atoi (args[4]); + + /* These aren't used by the GNU ufs, so who cares? */ + headswitch = 0; + trackseek = 0; + + fsize = 1024; + bsize = 8192; + + cpg = 16; + cpgflg = 0; + minfree = MINFREE; + opt = DEFAULTOPT ; + density = 4 * fsize; + maxcontig = MAX (1, MIN (MAXPHYS, MAXBSIZE) / bsize - 1); + rotdelay = 4; +#define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) + maxbpg = MAXBLKPG (bsize); + nrpos = 8; + bbsize = BBSIZE; + sbsize = SBSIZE; + + mkfs (0, device, fdi, fdo); + + exit (0); +} + + + mkfs(pp, fsys, fi, fo) struct partition *pp; char *fsys; @@ -638,6 +759,7 @@ next: for (cylno = 0; cylno < sblock.fs_ncg; cylno++) wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), sbsize, (char *)&sblock); +#if 0 /* Not in Hurd (yet) */ /* * Update information about this partion in pack * label, to that it may be updated on disk. @@ -646,6 +768,7 @@ next: pp->p_fsize = sblock.fs_fsize; pp->p_frag = sblock.fs_frag; pp->p_cpg = sblock.fs_cpg; +#endif /* * Notify parent process of success. * Dissociate from session and tty. @@ -880,10 +1003,11 @@ fsinit(utime) bcopy(&lost_found_dir[2], &buf[i], DIRSIZ(0, &lost_found_dir[2])); } - node.di_mode = IFDIR | UMASK; + node.di_model = ifdir | UMASK; + node.di_modeh = 0; node.di_nlink = 2; node.di_size = sblock.fs_bsize; - node.di_db[0] = alloc(node.di_size, node.di_mode); + node.di_db[0] = alloc(node.di_size, DI_MODE (&node)); node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); wtfs(fsbtodb(&sblock, node.di_db[0]), node.di_size, buf); iput(&node, LOSTFOUNDINO); @@ -892,15 +1016,16 @@ fsinit(utime) * create the root directory */ if (mfs) - node.di_mode = IFDIR | 01777; + node.di_model = IFDIR | 01777; else - node.di_mode = IFDIR | UMASK; + node.di_model = IFDIR | UMASK; + node.di_modeh = 0; node.di_nlink = PREDEFDIR; if (Oflag) node.di_size = makedir((struct direct *)oroot_dir, PREDEFDIR); else node.di_size = makedir(root_dir, PREDEFDIR); - node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode); + node.di_db[0] = alloc(sblock.fs_fsize, DI_MODE (&node)); node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); wtfs(fsbtodb(&sblock, node.di_db[0]), sblock.fs_fsize, buf); iput(&node, ROOTINO); -- cgit v1.2.3 From ce8b85a4435d0de91ead90975b05a39e44235c3b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 9 Sep 1994 17:06:40 +0000 Subject: Formerly main.c.~17~ --- ufs/main.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 1ae0d749..98f9c50e 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -29,18 +29,18 @@ static char **save_argv; /* Parse the arguments for ufs when started as a translator. */ char * -trans_parse_args (int argc, char **arg) +trans_parse_args (int argc, char **argv) { - #ifdef notyet - /* Option to set compat_mode should be provided here. */ - + char *devname; /* When started as a translator, we are called with the device name and an optional argument -r, which signifies read-only. */ if (argc < 2 || argc > 3) - usage_trans (); + exit (1); + if (argc == 2) devname = argv[1]; + else if (argc == 3) { if (argv[1][0] == '-' && argv[1][1] == 'r') @@ -54,28 +54,10 @@ trans_parse_args (int argc, char **arg) devname = argv[1]; } else - usage_trans (); - } - - get_privileged_ports (&host_priv_port, &master_device_port); - if (!master_device_port) - { - fprintf (stderr, "%s: Cannot get master device port\n", - argv[0]); - exit (1); + exit (1); } - /* We only need the host port if we are a bootstrap filesystem. */ - if (host_priv_port) - mach_port_deallocate (mach_task_self (), host_priv_port); - - mach_port_insert_right (mach_task_self (), ufs_control_port, - ufs_control_port, MACH_MSG_TYPE_MAKE_SEND); - fsys_startup (bootstrap, ufs_control_port, &ufs_realnode); - mach_port_deallocate (mach_task_self (), ufs_control_port); -#else - task_terminate (mach_task_self ()); - for (;;); -#endif + + return devname; } struct node *diskfs_root_node; -- cgit v1.2.3 From 562b01b6103129dfb9e7264d16899298fec3bb4b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 10 Sep 1994 16:28:00 +0000 Subject: Formerly main.c.~18~ --- ufs/main.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 98f9c50e..ee0e2268 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include char *ufs_version = "0.0 pre-alpha"; @@ -105,14 +107,28 @@ main (int argc, char **argv) task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap) - devname = trans_parse_args (argc, argv); + { + devname = trans_parse_args (argc, argv); + + { + /* XXX let us see errors */ + int fd = open ("/dev/console", O_RDWR); + assert (fd == 0); + fd = dup (0); + assert (fd == 1); + fd = dup (1); + assert (fd == 2); + } + } else { devname = diskfs_parse_bootargs (argc, argv); compat_mode = COMPAT_GNU; } - diskfs_init_diskfs (bootstrap); + /* Initialize the diskfs library. This must come before + any other diskfs call. */ + diskfs_init_diskfs (); err = device_open (diskfs_master_device, (diskfs_readonly ? 0 : D_WRITE) | D_READ, @@ -148,26 +164,38 @@ main (int argc, char **argv) if ((sblock->fs_inodefmt == FS_44INODEFMT || direct_symlink_extension) && compat_mode == COMPAT_BSD42) + /* XXX should syslog to this effect */ compat_mode = COMPAT_BSD44; if (!diskfs_readonly) { sblock->fs_clean = 0; - strcpy (sblock->fs_fsmnt, "Hurd /"); + strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ sblock_dirty = 1; diskfs_set_hypermetadata (1, 0); } + /* Initiialize our pagers so we can begin using them. */ inode_init (); pager_init (); - + + /* Start the first request thread, to handle RPCs and page requests + resulting from warp_root below. */ diskfs_spawn_first_thread (); - + + /* Find our root node. */ warp_root (); - - if (!bootstrap) + + /* 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 + outside world. */ + (void) diskfs_startup_diskfs (bootstrap); + + if (bootstrap == MACH_PORT_NULL) + /* We are the bootstrap filesystem; do special boot-time setup. */ diskfs_start_bootstrap (); + /* Now become a generic request thread. */ diskfs_main_request_loop (); } -- cgit v1.2.3 From cc158c8b21f911617d09ab3bcde369d45d70ebf0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 12 Sep 1994 15:30:33 +0000 Subject: Formerly hyper.c.~9~ --- ufs/hyper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index b39848ee..74415b63 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -107,7 +107,7 @@ diskfs_set_hypermetadata (int wait, int clean) { error_t (*writefn) (daddr_t, vm_address_t, long); writefn = (wait ? dev_write_sync : dev_write); - + spin_lock (&alloclock); if (csum_dirty) { @@ -117,7 +117,7 @@ diskfs_set_hypermetadata (int wait, int clean) csum_dirty = 0; } - if (clean) + if (clean && !diskfs_readonly) { sblock->fs_clean = 1; sblock_dirty = 1; @@ -146,7 +146,7 @@ diskfs_set_hypermetadata (int wait, int clean) sblock_dirty = 0; } - if (clean) + if (clean && !diskfs_readonly) { sblock->fs_clean = 0; sblock_dirty = 1; -- cgit v1.2.3 From e3a1889ecaf82f1c2291f2f939c3d71996b9b0a7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 16 Sep 1994 14:33:29 +0000 Subject: Formerly dir.h.~3~ --- ufs/dir.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ufs/dir.h b/ufs/dir.h index 3fbb511a..c6535342 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -72,7 +72,10 @@ #define DIRBLKSIZ DEV_BSIZE #define MAXNAMLEN 255 -struct direct { +/* Don't call this struct DIRECT because the library defines that + (sometimes) in a possible different way. */ + +struct directory_entry { u_long d_ino; /* inode number of entry */ u_short d_reclen; /* length of this record */ u_char d_type; /* file type, see below */ @@ -98,7 +101,7 @@ struct direct { #define IFTODT(mode) (((mode) & 0170000) >> 12) #define DTTOIF(dirtype) ((dirtype) << 12) -/* Return the type from a struct direct, paying attention to whether +/* Return the type from a struct directory_entry, paying attention to whether this filesystem supports the type extension */ #define DIRECT_TYPE(dp) (direct_symlink_extension ? (dp)->d_type : DT_UNKNOWN) @@ -120,7 +123,7 @@ struct direct { /* In BSD this macro takes a struct direct. Modified by MIB here to take the namelen (as computed by strlen). */ #define DIRSIZ(namelen) \ - ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((namelen)+1 + 3) &~ 3)) + ((sizeof (struct directory_entry) - (MAXNAMLEN+1)) + (((namelen)+1 + 3) &~ 3)) #if 0 /* This is the BSD definition */ #if (BYTE_ORDER == LITTLE_ENDIAN) -- cgit v1.2.3 From 23b0fc0ead7388e0bfcf8cd2e1ad1a6f646187cc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 16 Sep 1994 14:56:55 +0000 Subject: Formerly fsck.h.~8~ --- bsdfsck/fsck.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index c2768e9b..ea6da35a 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,11 +31,14 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.7 1994/09/01 18:50:58 mib Exp $ + * $Id: fsck.h,v 1.8 1994/09/16 14:56:55 mib Exp $ */ /* Begin GNU Hurd */ +/* GNU ufs doesn't define struct direct, but fsck needs it. */ +#define direct directory_entry + /* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD 4.4 version that fsck expects. So we provide here the BSD version. */ #undef DIRSIZ -- cgit v1.2.3 From 0963f46775c7f8eaea3bc6086b2217f8ebab8af8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 16 Sep 1994 15:58:55 +0000 Subject: Formerly inode.c.~32~ --- ufs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index bfa50ece..f3f17086 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -179,7 +179,7 @@ read_disknode (struct node *np) return err; st->st_fstype = FSTYPE_UFS; - st->st_fsid = 0; /* XXX should fill this */ + st->st_fsid = getpid (); st->st_ino = np->dn->number; st->st_gen = di->di_gen; st->st_rdev = di->di_rdev; @@ -392,7 +392,7 @@ diskfs_set_statfs (struct fsys_statfsbuf *st) - (sblock->fs_dsize - st->fsys_stb_bfree)); st->fsys_stb_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ st->fsys_stb_ffree = sblock->fs_cstotal.cs_nifree; - st->fsys_stb_fsid = 0; + st->fsys_stb_fsid = getpid (); return 0; } -- cgit v1.2.3 From 7923c99c3fb6536f4c7d575ff47becfb63e63d2f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 16 Sep 1994 17:24:59 +0000 Subject: Formerly dir.c.~26~ --- ufs/dir.c | 79 ++++++++++++++++++++++++++------------------------------------- 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index a3b0b7f6..d0bf151d 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -65,11 +65,11 @@ struct dirstat /* For stat COMPRESS, this is the address (inside mapbuf) of the first direct in the directory block to be compressed. */ /* For stat HERE_TIS, SHRINK, and TAKE, this is the entry referenced. */ - struct direct *entry; + struct directory_entry *entry; /* For stat HERE_TIS, type REMOVE, this is the address of the immediately previous direct in this directory block, or zero if this is the first. */ - struct direct *preventry; + struct director_entry *preventry; }; size_t diskfs_dirstat_size = sizeof (struct dirstat); @@ -306,7 +306,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, int needed = 0; int countup = 0; vm_address_t currentoff, prevoff; - struct direct *entry; + struct directory_entry *entry; int nentries = 0; if (ds && ds->stat == LOOKING) @@ -319,7 +319,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, currentoff < blockaddr + DIRBLKSIZ; prevoff = currentoff, currentoff += entry->d_reclen) { - entry = (struct direct *)currentoff; + entry = (struct directory_entry *)currentoff; if (!entry->d_reclen || entry->d_reclen % 4 @@ -358,7 +358,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, { ds->type = CREATE; ds->stat = COMPRESS; - ds->entry = (struct direct *) blockaddr; + ds->entry = (struct directory_entry *) blockaddr; ds->idx = idx; countup = 0; } @@ -407,7 +407,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, ds->stat = HERE_TIS; ds->entry = entry; ds->idx = idx; - ds->preventry = (struct direct *) prevoff; + ds->preventry = (struct directory_entry *) prevoff; } *inum = entry->d_ino; @@ -427,13 +427,14 @@ diskfs_direnter(struct node *dp, struct dirstat *ds, struct protid *cred) { - struct direct *new; + struct directory_entry *new; int namelen = strlen (name); int needed = DIRSIZ (namelen); int oldneeded; vm_address_t fromoff, tooff; int totfreed; error_t err; + off_t newsize; assert (ds->type == CREATE); @@ -457,7 +458,7 @@ diskfs_direnter(struct node *dp, oldneeded = DIRSIZ (DIRECT_NAMLEN (ds->entry)); assert (ds->entry->d_reclen - oldneeded >= needed); - new = (struct direct *) ((vm_address_t) ds->entry + oldneeded); + new = (struct directory_entry *) ((vm_address_t) ds->entry + oldneeded); new->d_ino = np->dn->number; new->d_reclen = ds->entry->d_reclen - oldneeded; @@ -479,8 +480,8 @@ diskfs_direnter(struct node *dp, while (fromoff < (vm_address_t) ds->entry + DIRBLKSIZ) { - struct direct *from = (struct direct *)fromoff; - struct direct *to = (struct direct *) tooff; + struct directory_entry *from = (struct directory_entry *)fromoff; + struct directory_entry *to = (struct directory_entry *) tooff; int fromreclen = from->d_reclen; if (from->d_ino != 0) @@ -498,7 +499,7 @@ diskfs_direnter(struct node *dp, totfreed = (vm_address_t) ds->entry + DIRBLKSIZ - tooff; assert (totfreed >= needed); - new = (struct direct *) tooff; + new = (struct directory_entry *) tooff; new->d_ino = np->dn->number; new->d_reclen = totfreed; DIRECT_NAMLEN (new) = namelen; @@ -511,14 +512,15 @@ diskfs_direnter(struct node *dp, /* Extend the file. */ assert (needed <= DIRBLKSIZ); - while (dp->dn_stat.st_size + DIRBLKSIZ > dp->allocsize) - if (err = diskfs_grow (dp, dp->dn_stat.st_size + DIRBLKSIZ, cred)) + newsize = dp->dn_stat.st_size + DIRBLKSIZ; + while (newsize > dp->allocsize) + if (err = diskfs_grow (dp, newsize, cred)) { vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); return err; } - new = (struct direct *) (ds->mapbuf + dp->dn_stat.st_size); + new = (struct directory_entry *) (ds->mapbuf + dp->dn_stat.st_size); dp->dn_stat.st_size += DIRBLKSIZ; dp->dn_set_ctime = 1; @@ -643,7 +645,7 @@ int diskfs_dirempty(struct node *dp, struct protid *cred) { - struct direct *entry; + struct directory_entry *entry; int curoff; vm_address_t buf; memory_object_t memobj; @@ -663,7 +665,7 @@ diskfs_dirempty(struct node *dp, curoff < buf + dp->dn_stat.st_size; curoff += entry->d_reclen) { - entry = (struct direct *) curoff; + entry = (struct directory_entry *) curoff; if (entry->d_ino != 0 && (DIRECT_NAMLEN (entry) > 2 @@ -701,7 +703,7 @@ count_dirents (struct node *dp, int nb, char *buf) { int amt; char *offinblk; - struct direct *entry; + struct directory_entry *entry; int count = 0; error_t err; @@ -717,7 +719,7 @@ count_dirents (struct node *dp, int nb, char *buf) offinblk < buf + DIRBLKSIZ; offinblk += entry->d_reclen) { - entry = (struct direct *) offinblk; + entry = (struct directory_entry *) offinblk; if (entry->d_ino) count++; } @@ -727,16 +729,6 @@ count_dirents (struct node *dp, int nb, char *buf) return 0; } -/* XXX */ -struct olddirect -{ - u_long d_ino; - u_short d_reclen; - u_short d_namlen; - char d_name[MAXNAMLEN + 1]; -}; - - /* Implement the disikfs_get_directs callback as described in . */ error_t @@ -757,10 +749,11 @@ diskfs_get_directs (struct node *dp, error_t err; int i; char *datap; - struct direct *entryp; + struct directory_entry *entryp; int allocsize; int checklen; - + struct dirent *userp; + nblks = dp->dn_stat.st_size/DIRBLKSIZ; if (!dp->dn->dirents) @@ -827,7 +820,7 @@ diskfs_get_directs (struct node *dp, } for (i = 0, bufp = buf; i < entry - curentry && bufp - buf < DIRBLKSIZ; - bufp += ((struct direct *)bufp)->d_reclen, i++) + bufp += ((struct directory_entry *)bufp)->d_reclen, i++) ; /* Make sure we didn't run off the end. */ assert (bufp - buf < DIRBLKSIZ); @@ -852,26 +845,18 @@ diskfs_get_directs (struct node *dp, bufp = buf; } - entryp = (struct direct *)bufp; + entryp = (struct directory_entry *)bufp; if (entryp->d_ino) { + userp = (struct dirent *) datap; + + userp->d_fileno = entryp->d_fileno; + userp->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); + userp->d_namlen = DIRECT_NAMLEN (entryp); + bcopy (entryp->d_name, userp->d_name, DIRECT_NAMLEN (entryp) + 1); #ifdef notyet - bcopy (bufp, datap, DIRSIZ (DIRECT_NAMLEN (entryp))); - if (!direct_symlink_extension) - { - /* Fix up fields into new format */ - ((struct direct *)datap)->d_namlen = DIRECT_NAMLEN (entryp); - ((struct direct *)datap)->d_type = DT_UNKNOWN; - } - ((struct direct *)datap)->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); -#else - struct olddirect *userd; - userd = (struct olddirect *)datap; - userd->d_ino = entryp->d_ino; - userd->d_namlen = DIRECT_NAMLEN (entryp); - userd->d_reclen = DIRSIZ (userd->d_namlen); - bcopy (entryp->d_name, userd->d_name, DIRECT_NAMLEN (entryp) + 1); + userp->d_type = entryp->d_type; #endif i++; datap += DIRSIZ (DIRECT_NAMLEN (entryp)); -- cgit v1.2.3 From 1ea101365f74d5df1372e0360d46cd16a13bc602 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 16 Sep 1994 18:48:26 +0000 Subject: Formerly dir.c.~27~ --- ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index d0bf151d..35760842 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -330,7 +330,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { fprintf (stderr, "Bad directory entry: inode: %d offset: %d\n", - dp->dn->number, currentoff - blockaddr); + dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ); return ENOENT; } -- cgit v1.2.3 From 8f5be4556fc63e831b3ebcf6de5d3515f5b311ed Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 19 Sep 1994 22:14:36 +0000 Subject: Formerly dir.c.~28~ --- ufs/dir.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 35760842..e4d54cdf 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -20,6 +20,9 @@ #include #include +#include + +#undef d_ino enum slot_status { @@ -69,7 +72,7 @@ struct dirstat /* For stat HERE_TIS, type REMOVE, this is the address of the immediately previous direct in this directory block, or zero if this is the first. */ - struct director_entry *preventry; + struct directory_entry *preventry; }; size_t diskfs_dirstat_size = sizeof (struct dirstat); @@ -434,7 +437,7 @@ diskfs_direnter(struct node *dp, vm_address_t fromoff, tooff; int totfreed; error_t err; - off_t newsize; + off_t oldsize; assert (ds->type == CREATE); @@ -512,17 +515,17 @@ diskfs_direnter(struct node *dp, /* Extend the file. */ assert (needed <= DIRBLKSIZ); - newsize = dp->dn_stat.st_size + DIRBLKSIZ; - while (newsize > dp->allocsize) - if (err = diskfs_grow (dp, newsize, cred)) + oldsize = dp->dn_stat.st_size; + while (oldsize + DIRBLKSIZ > dp->allocsize) + if (err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred)) { vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); return err; } - new = (struct directory_entry *) (ds->mapbuf + dp->dn_stat.st_size); + new = (struct directory_entry *) (ds->mapbuf + oldsize); - dp->dn_stat.st_size += DIRBLKSIZ; + dp->dn_stat.st_size = oldsize + DIRBLKSIZ; dp->dn_set_ctime = 1; new->d_ino = np->dn->number; @@ -851,7 +854,7 @@ diskfs_get_directs (struct node *dp, { userp = (struct dirent *) datap; - userp->d_fileno = entryp->d_fileno; + userp->d_fileno = entryp->d_ino; userp->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); userp->d_namlen = DIRECT_NAMLEN (entryp); bcopy (entryp->d_name, userp->d_name, DIRECT_NAMLEN (entryp) + 1); -- cgit v1.2.3 From 13843f409047b9458c3ea2fb0a390773afcef5f7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 19 Sep 1994 23:13:07 +0000 Subject: Formerly inode.c.~33~ --- ufs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index f3f17086..72bdc313 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -19,6 +19,7 @@ #include "dinode.h" #include "fs.h" #include +#include #define INOHSZ 512 #if ((INOHSZ&(INOHSZ-1)) == 0) @@ -173,13 +174,14 @@ read_disknode (struct node *np) struct stat *st = &np->dn_stat; struct dinode *di = &dinodes[np->dn->number]; error_t err; + volatile long long pid = getpid (); err = diskfs_catch_exception (); if (err) return err; st->st_fstype = FSTYPE_UFS; - st->st_fsid = getpid (); + st->st_fsid = pid; st->st_ino = np->dn->number; st->st_gen = di->di_gen; st->st_rdev = di->di_rdev; @@ -306,7 +308,7 @@ create_symlink_hook (struct node *np, char *target) if (!direct_symlink_extension) return EINVAL; - assert (!COMPAT_BSD42); + assert (compat_mode != COMPAT_BSD42); if (len >= sblock->fs_maxsymlinklen) return EINVAL; -- cgit v1.2.3 From 6337cbc4e5f5e0bdb6c41428fc4e15bc7791133c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Sep 1994 19:53:01 +0000 Subject: Formerly pager.c.~27~ --- ufs/pager.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 7aea0f9d..994d65ee 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -387,8 +387,6 @@ pager_report_extent (struct user_pager_info *pager, vm_address_t *offset, vm_size_t *size) { - int sizet; - *offset = 0; switch (pager->type) { @@ -405,12 +403,24 @@ pager_report_extent (struct user_pager_info *pager, break; case SINDIR: - sizet = pager->np->allocsize; - sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; - sizet -= NDADDR; - sizet *= sizeof (daddr_t); - sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; - *size = sizet; + { + int sizet; + + /* sizet = disk size of the file */ + sizet = pager->np->allocsize; + + /* sizet = number of fs blocks in file */ + sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; + + /* sizet = number of fs blocks not list in di_db */ + sizet -= NDADDR; + + /* sizet = space to hold that many pointers */ + sizet *= sizeof (daddr_t); + + /* And that's the size of the sindir area for the file. */ + *size = sizet; + } break; case FILE_DATA: @@ -543,7 +553,6 @@ sin_remap (struct node *np, newsize = (newsize + sblock->fs_bsize - 1) / sblock->fs_bsize; newsize -= NDADDR; newsize *= sizeof (daddr_t); - newsize = (newsize + sblock->fs_bsize - 1) / sblock->fs_bsize; newsize = round_page (newsize); assert (newsize >= size); -- cgit v1.2.3 From 3f1568c61e2af535260364356338cc6adfff22d2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 04:27:44 +0000 Subject: Formerly pager.c.~28~ --- ufs/pager.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 994d65ee..d94fd5ff 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -404,6 +404,9 @@ pager_report_extent (struct user_pager_info *pager, case SINDIR: { + /* This computation is known to sin_remap below, as + is the static `*offset = 0' assignment above. */ + int sizet; /* sizet = disk size of the file */ @@ -564,13 +567,13 @@ sin_remap (struct node *np, port = pager_get_port (upi->p); mach_port_insert_right (mach_task_self (), port, port, MACH_MSG_TYPE_MAKE_SEND); - err = vm_map (mach_task_self (), (u_int *)&np->dn->sinloc, size, + err = vm_map (mach_task_self (), (u_int *)&np->dn->sinloc, newsize, 0, 1, port, 0, 0, VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); mach_port_deallocate (mach_task_self (), port); assert (!err); diskfs_register_memory_fault_area (np->dn->sininfo->p, 0, - np->dn->sinloc, size); + np->dn->sinloc, newsize); } mutex_unlock (&pagernplock); } -- cgit v1.2.3 From 5e000c6f02312a721761e665a5b8db173d29996e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 17:38:49 +0000 Subject: Formerly inode.c.~34~ --- ufs/inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index 72bdc313..55cef7d9 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -78,6 +78,8 @@ iget (ino_t inum, struct node **npp) rwlock_init (&dn->datalock); dn->dinloc = 0; dn->sinloc = 0; + dn->dinloclen = 0; + dn->sinloclen = 0; dn->sininfo = 0; dn->fileinfo = 0; @@ -147,6 +149,7 @@ diskfs_node_norefs (struct node *np) free (np->dn->dirents); assert (!np->dn->sininfo && !np->dn->fileinfo); assert (!np->dn->dinloc && !np->dn->sinloc); + assert (!np->dn->dinloclen && !np->dn->sinloclen); free (np->dn); free (np); } -- cgit v1.2.3 From 3f3454117144e15671fdd5a7618cbffb10cffb41 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 17:47:41 +0000 Subject: Formerly ufs.h.~20~ --- ufs/ufs.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index a9766422..1087c104 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -67,6 +67,9 @@ struct disknode /* These pointers are locked by sinmaplock and dinmaplock for all nodes. */ daddr_t *dinloc; daddr_t *sinloc; + + size_t dinloclen; + size_t sinloclen; /* These two pointers are locked by pagernplock in pager.c for all nodes. */ -- cgit v1.2.3 From d28ca40ffe939c84179f1377489949306f565335 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 19:26:23 +0000 Subject: Formerly sizes.c.~17~ --- ufs/sizes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index c34474f5..bde73dee 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -129,6 +129,7 @@ diskfs_truncate (struct node *np, for (idx = first2free; idx <= olastblock; idx ++) { + assert (idx - NDADDR < np->dn->sinloclen); if (np->dn->sinloc[idx - NDADDR]) { ffs_blkfree (np, np->dn->sinloc[idx - NDADDR], sblock->fs_bsize); @@ -247,6 +248,7 @@ sindir_drop (struct node *np, din_map (np); for (idx = first; idx = last; idx++) { + assert (idx - 1 < np->dn->dinloclen); if (np->dn->dinloc[idx - 1]) { ffs_blkfree (np, np->dn->dinloc[idx - 1], sblock->fs_bsize); @@ -449,6 +451,7 @@ diskfs_grow (struct node *np, } lbn -= NDADDR; + assert (lbn < np->dn->sinloclen); if (!np->dn->sinloc[lbn]) { err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn + NDADDR, lbn, @@ -501,8 +504,10 @@ diskfs_grow (struct node *np, round_page (poke_off2 + poke_len2)); mach_port_deallocate (mach_task_self (), obj); } - + +#if 0 diskfs_file_update (np, 0); +#endif return err; } -- cgit v1.2.3 From c9c5b4e8c965e94e22dae337238d9d6cffab8bdb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 19:27:32 +0000 Subject: Formerly pager.c.~29~ --- ufs/pager.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index d94fd5ff..4de29518 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -44,6 +44,8 @@ static struct mutex pagernplock = MUTEX_INITIALIZER; #define MAY_CACHE 1 #endif +char typechars[] = "ICSDF"; + /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has @@ -113,6 +115,7 @@ find_address (struct user_pager_info *upi, maplock = &dinmaplock; if (!np->dn->dinloc) din_map (np); + assert (vblkno - 1 < np->dn->dinloclen); fsbaddr = np->dn->dinloc[vblkno - 1]; mutex_unlock (&dinmaplock); } @@ -149,6 +152,7 @@ find_address (struct user_pager_info *upi, maplock = &sinmaplock; if (!np->dn->sinloc) sin_map (np); + assert (vblkno - NDADDR < np->dn->sinloclen); fsbaddr = np->dn->sinloc[vblkno - NDADDR]; mutex_unlock (&sinmaplock); } @@ -221,6 +225,9 @@ pager_write_page (struct user_pager_info *pager, error_t err; struct disknode *dn; + printf ("%c", typechars[pager->type]); + fflush (stdout); + err = find_address (pager, page, &addr, &disksize, &nplock, &dn); if (err) return err; @@ -230,6 +237,7 @@ pager_write_page (struct user_pager_info *pager, else { printf ("Attempt to write unallocated disk\n."); + fflush (stdout); err = 0; /* unallocated disk; error would be pointless */ } @@ -299,6 +307,7 @@ pager_unlock_page (struct user_pager_info *pager, { if (!np->dn->dinloc) din_map (np); + assert (vblkno - 1 < np->dn->dinloclen); slot = &np->dn->dinloc[vblkno - 1]; } @@ -330,6 +339,7 @@ pager_unlock_page (struct user_pager_info *pager, > blkroundup (sblock, np->allocsize) - sblock->fs_bsize) { printf ("attempt to unlock at last block denied\n"); + fflush (stdout); rwlock_writer_unlock (&np->dn->datalock, np->dn); return EIO; } @@ -348,6 +358,7 @@ pager_unlock_page (struct user_pager_info *pager, { if (!np->dn->sinloc) sin_map (np); + assert (vblkno - NDADDR < np->dn->sinloclen); slot = &np->dn->sinloc[vblkno - NDADDR]; table = np->dn->sinloc; } @@ -527,7 +538,8 @@ sin_map (struct node *np) mach_port_deallocate (mach_task_self (), port); assert (!err); - + np->dn->sinloclen = extent / sizeof (daddr_t); + diskfs_register_memory_fault_area (np->dn->sininfo->p, offset, np->dn->sinloc, extent); } @@ -572,6 +584,7 @@ sin_remap (struct node *np, VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); mach_port_deallocate (mach_task_self (), port); assert (!err); + np->dn->sinloclen = newsize / sizeof (daddr_t); diskfs_register_memory_fault_area (np->dn->sininfo->p, 0, np->dn->sinloc, newsize); } @@ -590,6 +603,7 @@ sin_unmap (struct node *np) pager_report_extent (np->dn->sininfo, &start, &len); diskfs_unregister_memory_fault_area (np->dn->sinloc, len); vm_deallocate (mach_task_self (), (u_int) np->dn->sinloc, len); + np->dn->sinloclen = 0; np->dn->sinloc = 0; } @@ -608,6 +622,7 @@ din_map (struct node *np) VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); assert (!err); + np->dn->dinloclen = sblock->fs_bsize / sizeof (daddr_t); diskfs_register_memory_fault_area (dinpager->p, np->dn->number * sblock->fs_bsize, np->dn->dinloc, sblock->fs_bsize); @@ -620,6 +635,7 @@ din_unmap (struct node *np) { diskfs_unregister_memory_fault_area (np->dn->dinloc, sblock->fs_bsize); vm_deallocate (mach_task_self (), (u_int) np->dn->dinloc, sblock->fs_bsize); + np->dn->dinloclen = 0; np->dn->dinloc = 0; } -- cgit v1.2.3 From 9faf3438c0da06bb0bcf74e176479245fbd33619 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 20:16:07 +0000 Subject: Formerly sizes.c.~18~ --- ufs/sizes.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index bde73dee..cc25f680 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -505,9 +505,5 @@ diskfs_grow (struct node *np, mach_port_deallocate (mach_task_self (), obj); } -#if 0 - diskfs_file_update (np, 0); -#endif - return err; } -- cgit v1.2.3 From 06e3d2005d0b71a75974deffb66a93e396c00c04 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Sep 1994 20:18:44 +0000 Subject: Formerly pager.c.~30~ --- ufs/pager.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index 4de29518..1916a79e 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -46,6 +46,13 @@ static struct mutex pagernplock = MUTEX_INITIALIZER; char typechars[] = "ICSDF"; +/* Limit the number of outstanding FILE_DATA paging requests. + Otherwise the kernel can send all the data at once and overwhelm us. */ +#define DATA_MAX_THREADS 10 +static int ndatapagethreads; +static struct mutex ndpthreads_lock = MUTEX_INITIALIZER; +static struct condition ndpthreads_wait = CONDITION_INITIALIZER; + /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has -- cgit v1.2.3 From a6d70799e9be91095fef56d6724daf00a079e6fa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 02:35:30 +0000 Subject: Formerly ufs.h.~21~ --- ufs/ufs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 1087c104..76ab1e06 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -71,8 +71,7 @@ struct disknode size_t dinloclen; size_t sinloclen; - /* These two pointers are locked by pagernplock in pager.c for - all nodes. */ + /* These two pointers are locked by pagernplock for all nodes. */ struct user_pager_info *sininfo; struct user_pager_info *fileinfo; }; @@ -177,6 +176,7 @@ spin_lock_t alloclock; struct mutex dinmaplock; struct mutex sinmaplock; +struct mutex pagernplock; spin_lock_t gennumberlock; u_long nextgennumber; -- cgit v1.2.3 From 852149ee4f1e3390491149ed8c5e250d1076ca5c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 02:35:36 +0000 Subject: Formerly pager.c.~31~ --- ufs/pager.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 1916a79e..e6f3c08b 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -35,8 +35,7 @@ static void enqueue_pager (struct user_pager_info *); static void dequeue_pager (struct user_pager_info *); static daddr_t indir_alloc (struct node *, int, int); -/* Locks all nodes' sininfo and fileinfo fields. */ -static struct mutex pagernplock = MUTEX_INITIALIZER; +struct mutex pagernplock = MUTEX_INITIALIZER; #ifdef DONT_CACHE_MEMORY_OBJECTS #define MAY_CACHE 0 @@ -46,13 +45,6 @@ static struct mutex pagernplock = MUTEX_INITIALIZER; char typechars[] = "ICSDF"; -/* Limit the number of outstanding FILE_DATA paging requests. - Otherwise the kernel can send all the data at once and overwhelm us. */ -#define DATA_MAX_THREADS 10 -static int ndatapagethreads; -static struct mutex ndpthreads_lock = MUTEX_INITIALIZER; -static struct condition ndpthreads_wait = CONDITION_INITIALIZER; - /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has @@ -209,6 +201,8 @@ pager_read_page (struct user_pager_info *pager, } else { + printf ("Write-locked pagein Object %#x\tOffset %#x\n", pager, page); + fflush (stdout); vm_allocate (mach_task_self (), buf, __vm_page_size, 1); *writelock = 1; } @@ -232,8 +226,10 @@ pager_write_page (struct user_pager_info *pager, error_t err; struct disknode *dn; +#if 0 printf ("%c", typechars[pager->type]); fflush (stdout); +#endif err = find_address (pager, page, &addr, &disksize, &nplock, &dn); if (err) @@ -244,6 +240,7 @@ pager_write_page (struct user_pager_info *pager, else { printf ("Attempt to write unallocated disk\n."); + printf ("Object %#x\tOffset %#x\n", pager, page); fflush (stdout); err = 0; /* unallocated disk; error would be pointless */ @@ -271,6 +268,9 @@ pager_unlock_page (struct user_pager_info *pager, vblkno = address / sblock->fs_bsize; + printf ("Unlock page request, Object %#x\tOffset %#x...", pager, address); + fflush (stdout); + switch (pager->type) { case DINDIR: @@ -395,6 +395,12 @@ pager_unlock_page (struct user_pager_info *pager, err = 0; } + if (err) + printf ("denied\n"); + else + printf ("succeeded\n"); + fflush (stdout); + return err; } @@ -535,8 +541,6 @@ sin_map (struct node *np) mach_port_insert_right (mach_task_self (), port, port, MACH_MSG_TYPE_MAKE_SEND); } - mutex_unlock (&pagernplock); - pager_report_extent (upi, &offset, &extent); err = vm_map (mach_task_self (), (vm_address_t *)&np->dn->sinloc, @@ -549,6 +553,7 @@ sin_map (struct node *np) diskfs_register_memory_fault_area (np->dn->sininfo->p, offset, np->dn->sinloc, extent); + mutex_unlock (&pagernplock); } /* This is caled when a file (NP) grows (to size NEWSIZE) to see @@ -852,6 +857,7 @@ allow_pager_softrefs (struct node *np) if (np->dn->sininfo) pager_change_attributes (np->dn->sininfo->p, 1, MEMORY_OBJECT_COPY_DELAY, 0); + mutex_unlock (&pagernplock); } } -- cgit v1.2.3 From c3d5befb7e6321f6f28cc991e3024d71fffe1ea8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 02:39:27 +0000 Subject: Formerly sizes.c.~19~ --- ufs/sizes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/sizes.c b/ufs/sizes.c index cc25f680..0bc0e547 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -505,5 +505,7 @@ diskfs_grow (struct node *np, mach_port_deallocate (mach_task_self (), obj); } + diskfs_file_update (np, 0); + return err; } -- cgit v1.2.3 From 8efcb72f07e27ab625ede2bc16abdfd5c7572f88 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 02:51:36 +0000 Subject: Formerly inode.c.~35~ --- ufs/inode.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 55cef7d9..757d8821 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -20,6 +20,7 @@ #include "fs.h" #include #include +#include #define INOHSZ 512 #if ((INOHSZ&(INOHSZ-1)) == 0) @@ -147,9 +148,19 @@ diskfs_node_norefs (struct node *np) np->dn->hnext->dn->hprevp = np->dn->hprevp; if (np->dn->dirents) free (np->dn->dirents); - assert (!np->dn->sininfo && !np->dn->fileinfo); - assert (!np->dn->dinloc && !np->dn->sinloc); - assert (!np->dn->dinloclen && !np->dn->sinloclen); + if (np->dn->sininfo || np->dn->fileinfo || np->dn->dinloc + || np->dn->sinloc || np->dn->dinloclen || np->dn->sinloclen) + { + printf ("I=%d\n", np->dn->number); + printf ("Hard %d\tSoft %d\n", np->references, np->light_references); + fflush (stdout); + } + assert (!np->dn->sininfo); + assert (!np->dn->fileinfo); + assert (!np->dn->dinloc); + assert (!np->dn->sinloc); + assert (!np->dn->dinloclen); + assert (!np->dn->sinloclen); free (np->dn); free (np); } -- cgit v1.2.3 From daf73bd08805ab863709eeb5488fd99aaeb128da Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 15:45:13 +0000 Subject: Formerly inode.c.~36~ --- ufs/inode.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 757d8821..67037450 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -72,8 +72,6 @@ iget (ino_t inum, struct node **npp) dn->number = inum; dn->dirents = 0; - mutex_init (&dn->rwlock_master); - condition_init (&dn->rwlock_wakeup); rwlock_init (&dn->dinlock); rwlock_init (&dn->sinlock); rwlock_init (&dn->datalock); -- cgit v1.2.3 From fbecadaf75d933aa3633a023c591b8fa8ec7611c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 15:56:24 +0000 Subject: Formerly ufs.h.~22~ --- ufs/ufs.h | 77 +++++++++++++++++++++++++-------------------------------------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 76ab1e06..fb9913ca 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -31,10 +31,11 @@ /* #undef DONT_CACHE_MEMORY_OBJECTS */ - /* Simple reader/writer lock. */ struct rwlock { + struct mutex master; + struct condition wakeup; int readers; int writers_waiting; int readers_waiting; @@ -51,97 +52,81 @@ struct disknode /* Links on hash list. */ struct node *hnext, **hprevp; - struct mutex rwlock_master; - struct condition rwlock_wakeup; - - struct rwlock dinlock; /* locks INDIR_DOUBLE pointer */ - - /* sinlock locks INDIR_SINGLE pointer and all the pointers in - the double indir block. */ - struct rwlock sinlock; - - /* datalock locks all the direct block pointers and all the pointers - in all the single indir blocks */ - struct rwlock datalock; + struct rwlock allocptrlock; - /* These pointers are locked by sinmaplock and dinmaplock for all nodes. */ daddr_t *dinloc; daddr_t *sinloc; size_t dinloclen; size_t sinloclen; - /* These two pointers are locked by pagernplock for all nodes. */ - struct user_pager_info *sininfo; struct user_pager_info *fileinfo; }; /* Get a reader lock on reader-writer lock LOCK for disknode DN */ extern inline void -rwlock_reader_lock (struct rwlock *lock, - struct disknode *dn) +rwlock_reader_lock (struct rwlock *lock) { - mutex_lock (&dn->rwlock_master); + mutex_lock (&lock->master); if (lock->readers == -1 || lock->writers_waiting) { lock->readers_waiting++; do - condition_wait (&dn->rwlock_wakeup, &dn->rwlock_master); + condition_wait (&lock->wakeup, &lock->master); while (lock->readers == -1 || lock->writers_waiting); lock->readers_waiting--; } lock->readers++; - mutex_unlock (&dn->rwlock_master); + mutex_unlock (&lock->master); } /* Get a writer lock on reader-writer lock LOCK for disknode DN */ extern inline void -rwlock_writer_lock (struct rwlock *lock, - struct disknode *dn) +rwlock_writer_lock (struct rwlock *lock) { - mutex_lock (&dn->rwlock_master); + mutex_lock (&lock->master); if (lock->readers) { lock->writers_waiting++; do - condition_wait (&dn->rwlock_wakeup, &dn->rwlock_master); + condition_wait (&lock->wakeup, &lock->master); while (lock->readers); lock->writers_waiting--; } lock->readers = -1; - mutex_unlock (&dn->rwlock_master); + mutex_unlock (&lock->master); } /* Release a reader lock on reader-writer lock LOCK for disknode DN */ extern inline void -rwlock_reader_unlock (struct rwlock *lock, - struct disknode *dn) +rwlock_reader_unlock (struct rwlock *lock) { - mutex_lock (&dn->rwlock_master); + mutex_lock (&lock->master); assert (lock->readers); lock->readers--; if (lock->readers_waiting || lock->writers_waiting) - condition_broadcast (&dn->rwlock_wakeup); - mutex_unlock (&dn->rwlock_master); + condition_broadcast (&lock->wakeup); + mutex_unlock (&lock->master); } /* Release a writer lock on reader-writer lock LOCK for disknode DN */ extern inline void -rwlock_writer_unlock (struct rwlock *lock, - struct disknode *dn) +rwlock_writer_unlock (struct rwlock *lock) { - mutex_lock (&dn->rwlock_master); + mutex_lock (&lock->master); assert (lock->readers == -1); lock->readers = 0; if (lock->readers_waiting || lock->writers_waiting) - condition_broadcast (&dn->rwlock_wakeup); - mutex_unlock (&dn->rwlock_master); + condition_broadcast (&lock->wakeup); + mutex_unlock (&lock->master); } /* Initialize reader-writer lock LOCK */ extern inline void rwlock_init (struct rwlock *lock) { + mutex_init (&lock->master); + condition_init (&lock->wakeup); lock->readers = 0; lock->readers_waiting = 0; lock->writers_waiting = 0; @@ -152,31 +137,29 @@ struct user_pager_info struct node *np; enum pager_type { - DINODE, - CG, - SINDIR, - DINDIR, + DISK, FILE_DATA, } type; struct pager *p; struct user_pager_info *next, **prevp; }; -struct user_pager_info *dinpager, *dinodepager, *cgpager; +struct user_pager_info *diskpager; vm_address_t zeroblock; +/* These are copies (not mapped) of the hypermetadata; maintained + by hypen.c. */ struct fs *sblock; -struct dinode *dinodes; -vm_address_t cgs; struct csum *csum; int sblock_dirty; int csum_dirty; -spin_lock_t alloclock; -struct mutex dinmaplock; -struct mutex sinmaplock; -struct mutex pagernplock; +/* These are both mapped from the disk appropriately. */ +struct dinode *dinodes; +vm_address_t cgs; + +spin_lock_t alloclock; spin_lock_t gennumberlock; u_long nextgennumber; -- cgit v1.2.3 From 26e07e59b4ab80c174e51975e275c95eb88f5518 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Sep 1994 16:43:13 +0000 Subject: Formerly pager.c.~32~ --- ufs/pager.c | 307 ++++++++++++++++++++---------------------------------------- 1 file changed, 99 insertions(+), 208 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index e6f3c08b..9b883b2b 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -21,15 +21,11 @@ #include #include -mach_port_t dinport; -mach_port_t dinodeport; -mach_port_t cgport; - /* Filesystem blocks of inodes per cylinder group */ static int infsb_pcg; spin_lock_t pagerlistlock = SPIN_LOCK_INITIALIZER; -struct user_pager_info *filelist, *sinlist; +struct user_pager_info *filepagerlist; static void enqueue_pager (struct user_pager_info *); static void dequeue_pager (struct user_pager_info *); @@ -43,8 +39,6 @@ struct mutex pagernplock = MUTEX_INITIALIZER; #define MAY_CACHE 1 #endif -char typechars[] = "ICSDF"; - /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has @@ -55,84 +49,34 @@ find_address (struct user_pager_info *upi, vm_address_t offset, daddr_t *addr, int *disksize, - struct rwlock **nplock, - struct disknode **dnp) + struct rwlock **nplock) { - int vblkno = lblkno (sblock, offset); - int fsbaddr; - struct node *volatile np; - error_t err; - struct mutex *maplock = 0; - - if (upi->type != FILE_DATA) - *disksize = __vm_page_size; + assert (upi->type == DISK || upi->type == FILE_DATA); - switch (upi->type) + if (upi->type == DISK) { - default: - assert (0); - - case CG: - fsbaddr = cgtod (sblock, vblkno); + *disksize = __vm_page_size; + *addr = offset / DEV_BSIZE; *nplock = 0; - break; - - case DINODE: - fsbaddr = (cgimin (sblock, vblkno / infsb_pcg) - + blkstofrags (sblock, vblkno % infsb_pcg)); - *nplock = 0; - break; - - case DINDIR: - np = ifind (vblkno); - - rwlock_reader_lock (&np->dn->dinlock, np->dn); - *nplock = &np->dn->dinlock; - *dnp = np->dn; - if (err = diskfs_catch_exception ()) - goto error; - - fsbaddr = dinodes[np->dn->number].di_ib[INDIR_DOUBLE]; - diskfs_end_catch_exception (); - break; - - case SINDIR: - np = upi->np; - - rwlock_reader_lock (&np->dn->sinlock, np->dn); - *nplock = &np->dn->sinlock; - *dnp = np->dn; - - if (err = diskfs_catch_exception ()) - goto error; - - if (vblkno == 0) - fsbaddr = dinodes[np->dn->number].di_ib[INDIR_SINGLE]; - else - { - mutex_lock (&dinmaplock); - maplock = &dinmaplock; - if (!np->dn->dinloc) - din_map (np); - assert (vblkno - 1 < np->dn->dinloclen); - fsbaddr = np->dn->dinloc[vblkno - 1]; - mutex_unlock (&dinmaplock); - } - - diskfs_end_catch_exception (); - break; - - case FILE_DATA: + return 0; + } + else + { + int vblkno = lblkno (sblock, offset); + int fsbaddr; + struct node *volatile np; + error_t err; + np = upi->np; - rwlock_reader_lock (&np->dn->datalock, np->dn); - *nplock = &np->dn->datalock; - *dnp = np->dn; + rwlock_reader_lock (&np->dn->allocptrlock); + *nplock = &np->dn->allocptrlock; if (offset >= np->allocsize) { err = EIO; - goto error; + rwlock_reader_unlock (&np->dn->allocptrlock); + return err; } if (offset + __vm_page_size > np->allocsize) @@ -141,39 +85,50 @@ find_address (struct user_pager_info *upi, *disksize = __vm_page_size; if (err = diskfs_catch_exception ()) - goto error; + { + rwlock_reader_unlock (&np->dn->allocptrlock); + return err; + } if (vblkno < NDADDR) fsbaddr = dinodes[np->dn->number].di_db[vblkno]; else { - mutex_lock (&sinmaplock); - maplock = &sinmaplock; - if (!np->dn->sinloc) - sin_map (np); - assert (vblkno - NDADDR < np->dn->sinloclen); - fsbaddr = np->dn->sinloc[vblkno - NDADDR]; - mutex_unlock (&sinmaplock); + vblkno -= NDADDR; + assert (vblkno < np->dn->sinloclen); + int alloc = 1; + + /* It's in the INDIR_DOUBLE area */ + if (vblkno >= sblock->fs_bsize / sizeof (daddr_t)) + { + /* Check if the double indirect block is allocated. */ + if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE] == 0) + alloc = 0; + + /* Check if the appropriate single indirect block is + allocated. */ + else if (np->dinloc[vblkno / sblock->fs_bsize - 1] == 0) + alloc = 0; + } + else + if (dinodes[np->dn->number].di_ib[INDIR_SINGLE] == 0) + alloc = 0; + + fsbaddr = alloc ? np->dn->sinloc[vblkno - NDADDR] : 0; } diskfs_end_catch_exception (); - break; - } - if (fsbaddr) - *addr = fsbtodb (sblock, fsbaddr) + blkoff (sblock, offset) / DEV_BSIZE; - else - *addr = 0; + if (fsbaddr) + *addr = (fsbtodb (sblock, fsbaddr) + + blkoff (sblock, offset) / DEV_BSIZE); + else + *addr = 0; - return 0; - - error: - if (*nplock) - rwlock_reader_unlock (*nplock, *dnp); - if (maplock) - mutex_unlock (maplock); - return err; + return 0; + } } + /* Implement the pager_read_page callback from the pager library. See for the interface description. */ error_t @@ -186,9 +141,8 @@ pager_read_page (struct user_pager_info *pager, struct rwlock *nplock; daddr_t addr; int disksize; - struct disknode *dn; - err = find_address (pager, page, &addr, &disksize, &nplock, &dn); + err = find_address (pager, page, &addr, &disksize, &nplock); if (err) return err; @@ -208,7 +162,7 @@ pager_read_page (struct user_pager_info *pager, } if (nplock) - rwlock_reader_unlock (nplock, dn); + rwlock_reader_unlock (nplock); return err; } @@ -224,14 +178,8 @@ pager_write_page (struct user_pager_info *pager, int disksize; struct rwlock *nplock; error_t err; - struct disknode *dn; -#if 0 - printf ("%c", typechars[pager->type]); - fflush (stdout); -#endif - - err = find_address (pager, page, &addr, &disksize, &nplock, &dn); + err = find_address (pager, page, &addr, &disksize, &nplock); if (err) return err; @@ -247,7 +195,7 @@ pager_write_page (struct user_pager_info *pager, } if (nplock) - rwlock_reader_unlock (nplock, dn); + rwlock_reader_unlock (nplock); return err; } @@ -258,120 +206,63 @@ error_t pager_unlock_page (struct user_pager_info *pager, vm_offset_t address) { - struct node *volatile np; + struct node *np; error_t err; daddr_t vblkno; daddr_t *slot, *table; daddr_t newblk; + struct disknode *dn; /* Problem--where to get cred values for allocation here? */ - vblkno = address / sblock->fs_bsize; + vblkno = lblkno (address); printf ("Unlock page request, Object %#x\tOffset %#x...", pager, address); fflush (stdout); - switch (pager->type) - { - case DINDIR: - np = ifind (vblkno); - - rwlock_writer_lock (&np->dn->dinlock, np->dn); - if (diskfs_catch_exception ()) - err = EIO; - else - { - if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE]) - err = 0; - else - { - newblk = indir_alloc (np, INDIR_DOUBLE, 0); - if (newblk) - { - dinodes[np->dn->number].di_ib[INDIR_DOUBLE] = newblk; - err = 0; - } - else - err = ENOSPC; - } - diskfs_end_catch_exception (); - } - rwlock_writer_unlock (&np->dn->dinlock, np->dn); - break; - - case SINDIR: - np = pager->np; - rwlock_writer_lock (&np->dn->sinlock, np->dn); - - if (diskfs_catch_exception ()) - err = EIO; - else - { - mutex_lock (&dinmaplock); - if (vblkno == 0) - slot = &dinodes[np->dn->number].di_ib[INDIR_SINGLE]; - else - { - if (!np->dn->dinloc) - din_map (np); - assert (vblkno - 1 < np->dn->dinloclen); - slot = &np->dn->dinloc[vblkno - 1]; - } - - if (*slot) - err = 0; - else - { - newblk = indir_alloc (np, INDIR_SINGLE, vblkno); - if (newblk) - { - *slot = newblk; - err = 0; - } - else - err = ENOSPC; - } - mutex_unlock (&dinmaplock); - diskfs_end_catch_exception (); - } - rwlock_writer_unlock (&np->dn->sinlock, np->dn); - break; + if (pager->type == DISK) + return 0; + + np = pager->np; + dn = np->dn; - case FILE_DATA: - np = pager->np; - rwlock_writer_lock (&np->dn->datalock, np->dn); + rwlock_writer_lock (&dn->allocptrlock); + + /* If this is the last block, we don't let it get unlocked. */ + if (address + __vm_page_size + > blkroundup (sblock, np->allocsize) - sblock->fs_bsize) + { + printf ("attempt to unlock at last block denied\n"); + fflush (stdout); + rwlock_writer_unlock (&np->dn->datalock, np->dn); + return EIO; + } + + if (diskfs_catch_exception ()) + { + rwlock_writer_unlock (&dn->allocptrlock); + return EIO; + } - /* If this is the last block, we don't let it get unlocked. */ - if (address + __vm_page_size - > blkroundup (sblock, np->allocsize) - sblock->fs_bsize) - { - printf ("attempt to unlock at last block denied\n"); - fflush (stdout); - rwlock_writer_unlock (&np->dn->datalock, np->dn); - return EIO; - } - - if (diskfs_catch_exception ()) - err = EIO; - else - { - mutex_lock (&sinmaplock); - if (vblkno < NDADDR) - { - slot = &dinodes[np->dn->number].di_db[vblkno]; - table = dinodes[np->dn->number].di_db; - } - else - { - if (!np->dn->sinloc) - sin_map (np); - assert (vblkno - NDADDR < np->dn->sinloclen); - slot = &np->dn->sinloc[vblkno - NDADDR]; - table = np->dn->sinloc; - } + if (vblkno < NDADDR) + { + slot = &dinodes[np->dn->number].di_db[vblkno]; + table = dinodes[np->dn->number].di_db; + } + else + { + assert (vblkno - NDADDR < np->dn->sinloclen); + slot = &np->dn->sinloc[vblkno - NDADDR]; + table = np->dn->sinloc; + } - if (*slot) - err = 0; + if (*slot) + { + diskfs_end_catch_exception (); + rwlock_write_unlock (&dn->allocptrlock); + return 0; + } + else { ffs_alloc (np, vblkno, -- cgit v1.2.3 From c05ecc35ea3ffb8fa8ec8cb91b5936859c716055 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 00:30:19 +0000 Subject: Formerly hyper.c.~10~ --- ufs/hyper.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 74415b63..4cdfa2dc 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -28,8 +28,7 @@ get_hypermetadata (void) { error_t err; - err = dev_read_sync (SBLOCK, (vm_address_t *)&sblock, SBSIZE); - assert (!err); + sblock = (struct fs *) disk_image + SBOFF; if (sblock->fs_magic != FS_MAGIC) { @@ -67,23 +66,32 @@ get_hypermetadata (void) if (sblock->fs_interleave < 1) sblock->fs_interleave = 1; - if (sblock->fs_postblformat == FS_42POSTBLFMT) - sblock->fs_nrpos = 8; - - if (sblock->fs_inodefmt < FS_44INODEFMT) + if (sblock->fs_postblformat == FS_42POSTBLFMT + || sblock->fs_inodefmt < FS_44INODEFMT) { - quad_t sizepb = sblock->fs_bsize; - int i; + /* Make a local copy so we don't write our different + values into the old format disk. */ + sblock = malloc (SBSIZE); + bcopy (disk_image + SBOFF, sblock, SBSIZE); + + if (sblock->fs_postblformat == FS_42POSTBLFMT) + sblock->fs_nrpos = 8; - oldformat = 1; - sblock->fs_maxfilesize = sblock->fs_bsize * NDADDR - 1; - for (i = 0; i < NIADDR; i++) + if (sblock->fs_inodefmt < FS_44INODEFMT) { - sizepb *= NINDIR (sblock); - sblock->fs_maxfilesize += sizepb; + quad_t sizepb = sblock->fs_bsize; + int i; + + oldformat = 1; + sblock->fs_maxfilesize = sblock->fs_bsize * NDADDR - 1; + for (i = 0; i < NIADDR; i++) + { + sizepb *= NINDIR (sblock); + sblock->fs_maxfilesize += sizepb; + } + sblock->fs_qbmask = ~sblock->fs_bmask; + sblock->fs_qfmask = ~sblock->fs_fmask; } - sblock->fs_qbmask = ~sblock->fs_bmask; - sblock->fs_qfmask = ~sblock->fs_fmask; } /* Find out if we support the 4.4 symlink/dirtype extension */ @@ -92,11 +100,9 @@ get_hypermetadata (void) else direct_symlink_extension = 0; - err = dev_read_sync (fsbtodb (sblock, sblock->fs_csaddr), - (vm_address_t *) &csum, - sblock->fs_fsize * howmany (sblock->fs_cssize, - sblock->fs_fsize)); - assert (!err); + csum = (struct csum *) + (disk_image + + howmany (sblock->fs_cssize, sblock->fs_fsize) * sblock->fs_fsize); } /* Write the superblock and cg summary info to disk. If WAIT is set, @@ -109,13 +115,6 @@ diskfs_set_hypermetadata (int wait, int clean) writefn = (wait ? dev_write_sync : dev_write); spin_lock (&alloclock); - if (csum_dirty) - { - (*writefn)(fsbtodb (sblock, sblock->fs_csaddr), (vm_address_t) csum, - sblock->fs_fsize * howmany (sblock->fs_cssize, - sblock->fs_fsize)); - csum_dirty = 0; - } if (clean && !diskfs_readonly) { @@ -139,6 +138,7 @@ diskfs_set_hypermetadata (int wait, int clean) sbcopy->fs_qbmask = -1; sbcopy->fs_qfmask = -1; } + bcopy (sbcopy, disk_image + SBOFF, SBSIZE) (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); } else -- cgit v1.2.3 From dccd60ad78dc70619507c72c68f1a123827c4e99 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 00:44:18 +0000 Subject: Formerly hyper.c.~11~ --- ufs/hyper.c | 79 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 4cdfa2dc..a59637fb 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -28,8 +28,12 @@ get_hypermetadata (void) { error_t err; - sblock = (struct fs *) disk_image + SBOFF; + sblock = malloc (SBSIZE); + assert (!diskfs_catch_exception ()); + bcopy (disk_image + SBOFF, sblock, SBSIZE); + diskfs_end_catch_exception (); + if (sblock->fs_magic != FS_MAGIC) { fprintf (stderr, "Bad magic number %#lx (should be %#x)\n", @@ -66,32 +70,23 @@ get_hypermetadata (void) if (sblock->fs_interleave < 1) sblock->fs_interleave = 1; - if (sblock->fs_postblformat == FS_42POSTBLFMT - || sblock->fs_inodefmt < FS_44INODEFMT) - { - /* Make a local copy so we don't write our different - values into the old format disk. */ - sblock = malloc (SBSIZE); - bcopy (disk_image + SBOFF, sblock, SBSIZE); + if (sblock->fs_postblformat == FS_42POSTBLFMT) + sblock->fs_nrpos = 8; - if (sblock->fs_postblformat == FS_42POSTBLFMT) - sblock->fs_nrpos = 8; + if (sblock->fs_inodefmt < FS_44INODEFMT) + { + quad_t sizepb = sblock->fs_bsize; + int i; - if (sblock->fs_inodefmt < FS_44INODEFMT) + oldformat = 1; + sblock->fs_maxfilesize = sblock->fs_bsize * NDADDR - 1; + for (i = 0; i < NIADDR; i++) { - quad_t sizepb = sblock->fs_bsize; - int i; - - oldformat = 1; - sblock->fs_maxfilesize = sblock->fs_bsize * NDADDR - 1; - for (i = 0; i < NIADDR; i++) - { - sizepb *= NINDIR (sblock); - sblock->fs_maxfilesize += sizepb; - } - sblock->fs_qbmask = ~sblock->fs_bmask; - sblock->fs_qfmask = ~sblock->fs_fmask; + sizepb *= NINDIR (sblock); + sblock->fs_maxfilesize += sizepb; } + sblock->fs_qbmask = ~sblock->fs_bmask; + sblock->fs_qfmask = ~sblock->fs_fmask; } /* Find out if we support the 4.4 symlink/dirtype extension */ @@ -100,21 +95,35 @@ get_hypermetadata (void) else direct_symlink_extension = 0; - csum = (struct csum *) - (disk_image - + howmany (sblock->fs_cssize, sblock->fs_fsize) * sblock->fs_fsize); + csum = malloc (fsaddr (sblock, howmany (sblock->fs_cssize, + sblock->fs_fsize))); + + assert (!diskfs_catch_exception ()); + bcopy (disk_image + fsaddr (sblock, sblock->fs_csaddr), + csum, + fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); + diskfs_end_catch_exception (); } -/* Write the superblock and cg summary info to disk. If WAIT is set, - we must wait for everything to hit the disk; if CLEAN is set, then - mark the clean bit. */ +/* We don't need this callback; all our data is backed by pagers. */ void diskfs_set_hypermetadata (int wait, int clean) { - error_t (*writefn) (daddr_t, vm_address_t, long); - writefn = (wait ? dev_write_sync : dev_write); +} + +/* Copy the sblock and csum into the disk */ +void +copy_sblock () +{ + assert (!diskfs_catch_exception ()); spin_lock (&alloclock); + if (csum_dirty) + { + bcopy (csum, disk_image + fsaddr (sblock, sblock->fs_csaddr), + fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); + csum_dirty = 0; + } if (clean && !diskfs_readonly) { @@ -138,11 +147,10 @@ diskfs_set_hypermetadata (int wait, int clean) sbcopy->fs_qbmask = -1; sbcopy->fs_qfmask = -1; } - bcopy (sbcopy, disk_image + SBOFF, SBSIZE) - (*writefn) (SBLOCK, (vm_address_t) sblockcopy, SBSIZE); + bcopy (sbcopy, disk_image + SBOFF, SBSIZE); } else - (*writefn) (SBLOCK, (vm_address_t) sblock, SBSIZE); + bcopy (sblock, disk_image + SBOFF, SBSIZE); sblock_dirty = 0; } @@ -151,8 +159,9 @@ diskfs_set_hypermetadata (int wait, int clean) sblock->fs_clean = 0; sblock_dirty = 1; } - + spin_unlock (&alloclock); + diskfs_end_catch_exception (); } -- cgit v1.2.3 From 5fbf0f632993ae920b695b2be3585fcd80f5baf1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 01:29:06 +0000 Subject: Formerly alloc.c.~15~ --- ufs/alloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 19389afe..2d27c1e7 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -200,7 +200,7 @@ ffs_realloccg(register struct node *np, goto nospace; if (error = diskfs_catch_exception ()) return error; - bprev = dinodes[np->dn->number].di_db[lbprev]; + bprev = (dino (np->dn->number))->di_db[lbprev]; diskfs_end_catch_exception (); assert ("old block not allocated" && bprev); @@ -787,7 +787,7 @@ ffs_fragextend(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); + cgp = cg_locate (cg); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ @@ -852,7 +852,7 @@ ffs_alloccg(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = (struct cg *) (cgs + sblock->fs_bsize * cg); + cgp = cg_locate (cg); #endif if (!cg_chkmagic(cgp) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { @@ -1146,7 +1146,7 @@ ffs_nodealloccg(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + cgp = cg_locate (cg); #endif if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { /* brelse(bp); */ @@ -1227,7 +1227,7 @@ ffs_blkfree(register struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + cgp = cg_locate (cg); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ @@ -1317,7 +1317,7 @@ diskfs_free_node (struct node *np, mode_t mode) } cgp = (struct cg *)bp->b_data; #else - cgp = (struct cg *)(cgs + sblock->fs_bsize * cg); + cgp = cg_locate (cg); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ -- cgit v1.2.3 From e008ef767254409f7ebefb4e41180300b310a8dd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 01:48:24 +0000 Subject: Initial revision --- ufs/bmap.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ufs/bmap.c diff --git a/ufs/bmap.c b/ufs/bmap.c new file mode 100644 index 00000000..8b544e40 --- /dev/null +++ b/ufs/bmap.c @@ -0,0 +1,24 @@ +/* Interpretation of indirect block structure + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +#include "ufs.h" +#include "dinode.h" +#include "fs.h" -- cgit v1.2.3 From 3c2e2b076f48a787345f217c18a6c0e9a542c941 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 02:08:14 +0000 Subject: Formerly bmap.c.~2~ --- ufs/bmap.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/ufs/bmap.c b/ufs/bmap.c index 8b544e40..c2eea356 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -22,3 +22,82 @@ #include "ufs.h" #include "dinode.h" #include "fs.h" + +/* Number of block pointers that fit in a single disk block */ +#define NIPTR (sblock->fs_bsize / sizeof (daddr_t)) + +/* For logical block number LBN of file NP, look it the block address, + giving the "path" of indirect blocks to the file, starting + with the least indirect. Fill *INDIRS with information for + the block. */ +error_t +fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs) +{ + struct dinode *di = dino (np->dn->number); + int boff; + error_t err; + daddr_t *siblock; + + if (err = diskfs_catch_exception ()) + return err; + + if (lbn < NDADDR) + { + indirs[0].bno = di->di_db[lbn]; + indirs[0].offset = -1; + + diskfs_end_catch_exception (); + return 0; + } + + lbn -= NDADDR; + + indirs[0].offset = lbn % NIPTR; + + if (lbn / NIPTR) + { + /* We will use the double indirect block */ + int ibn; + daddr_t *diblock; + + ibn = lbn / NIPTR - 1; + + indirs[1].offset = ibn % NIPTR; + + /* We don't support triple indirect blocks, but this + is where we'd do it. */ + assert (!(ibn / NIPTR)); + + indirs[2].offset = -1; + indirs[2].bno = di->di_ib[INDIR_DOUBLE]; + + if (indirs[2].bno) + { + diblock = indir_block (indirs[2].bno); + indirs[1].bno = diblock[indirs[1].offset]; + } + else + indirs[1].bno = 0; + } + else + { + indirs[1].offset = -1; + indirs[1].bno = di->di_ib[INDIR_DOUBLE]; + } + + if (indirs[1].bno) + { + siblock = indir_block (indirs[1].bno); + indirs[0].bno = siblock[indirs[0].offset]; + } + else + indirs[0].bno = 0; + + diskfs_end_catch_exception (); + return 0; +} + + + + + -- cgit v1.2.3 From 6e7220dc1dcbde1a12984d5cb9899ccbc473eecb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 02:51:16 +0000 Subject: Formerly ufs.h.~23~ --- ufs/ufs.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index fb9913ca..a1186531 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -54,12 +54,6 @@ struct disknode struct rwlock allocptrlock; - daddr_t *dinloc; - daddr_t *sinloc; - - size_t dinloclen; - size_t sinloclen; - struct user_pager_info *fileinfo; }; @@ -80,6 +74,17 @@ rwlock_reader_lock (struct rwlock *lock) mutex_unlock (&lock->master); } +/* Identifies a particular block and where it's found + when interpreting indirect block structure. */ +struct iblock_spec +{ + /* Disk address of block */ + daddr_t bno; + + /* Offset in next block up; -1 if it's in the inode itself. */ + int offset; +}; + /* Get a writer lock on reader-writer lock LOCK for disknode DN */ extern inline void rwlock_writer_lock (struct rwlock *lock) @@ -145,19 +150,15 @@ struct user_pager_info }; struct user_pager_info *diskpager; +mach_port_t diskpagerport; +off_t diskpagersize; vm_address_t zeroblock; -/* These are copies (not mapped) of the hypermetadata; maintained - by hypen.c. */ struct fs *sblock; struct csum *csum; -int sblock_dirty; -int csum_dirty; -/* These are both mapped from the disk appropriately. */ -struct dinode *dinodes; -vm_address_t cgs; +void *disk_image; spin_lock_t alloclock; @@ -181,7 +182,8 @@ enum compat_mode of the dinode. */ int direct_symlink_extension; - + +/* Handy macros */ #define DEV_BSIZE 512 #define NBBY 8 #define btodb(n) ((n) / DEV_BSIZE) @@ -191,6 +193,48 @@ int direct_symlink_extension; #define isset(a, i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<(i)%NBBY)) +#define fsaddr(fs,n) (fsbtodb(fs,n)*DEV_BSIZE) + + +/* Functions for looking inside disk_image */ + +/* Convert an inode number to the dinode on disk. */ +extern inline struct dinode * +dino (ino_t inum) +{ + return (struct disknode *) + (disk_image + + fsaddr (sblock, ino_to_fsba (sblock, inum)) + + ino_to_fsbo (sblock, inum)); +} + +/* Convert a indirect block number to a daddr_t table. */ +extern inline daddr_t * +indir_block (daddr_t bno) +{ + return (daddr_t *) (disk_image + fsaddr (fsbtodb (bno))); +} + +/* Convert a cg number to the cylinder group. */ +extern inline struct cg * +cg_locate (int ncg) +{ + return (struct cg *) (disk_image + fsaddr (cgtod (sblock, ncg))); +} + +/* Sync part of the disk */ +extern inline void +sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait) +{ + pager_sync_some (diskpager->p, fsaddr (blkno), nbytes, wait); +} + +/* Sync an disk inode */ +extern inline void +sync_dinode (int inum, int wait) +{ + sync_disk_blocks (ino_to_fsba (sblock, inum), sblock->fs_fsize, wait); +} /* From alloc.c: */ error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, @@ -215,7 +259,6 @@ void inode_init (void); void write_all_disknodes (void); /* From pager.c: */ -void sync_dinode (struct node *, int); void pager_init (void); void din_map (struct node *); void sin_map (struct node *); -- cgit v1.2.3 From d0370cb4e0e430b6300a8545b3a78dcc5de1dfb0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 02:52:58 +0000 Subject: Formerly main.c.~19~ --- ufs/main.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index ee0e2268..5fd1ff11 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -98,7 +98,6 @@ main (int argc, char **argv) error_t err; int sizes[DEV_GET_SIZE_COUNT]; u_int sizescnt = 2; - save_argv = argv; @@ -145,6 +144,29 @@ main (int argc, char **argv) exit (1); } + diskpagersize = sizes[DEV_GET_SIZE_DEVICE_SIZE]; + assert (diskpagersize >= SBSIZE + SBOFF); + + /* Map the entire disk. */ + create_disk_pager (); + + err = vm_map (mach_task_self (), (vm_address_t *)&disk_image, + diskpagersize, 0, 1, diskpagerport, 0, 0, + VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), + VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), + VM_INHERIT_NONE); + assert (!err); + + if (diskpagersize < sblock->fs_size * sblock->fs_fsize) + { + fprintf (stderr, + "Disk size %d less than necessary " + "(superblock says we need %ld)\n", + sizes[DEV_GET_SIZE_DEVICE_SIZE], + sblock->fs_size * sblock->fs_fsize); + exit (1); + } + get_hypermetadata (); /* Check to make sure device size is big enough. */ -- cgit v1.2.3 From 2c6a8c23ec0177814ae0e9db526826d2def081cd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 04:40:30 +0000 Subject: Formerly inode.c.~37~ --- ufs/inode.c | 126 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 67037450..d5c17e99 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -72,14 +72,7 @@ iget (ino_t inum, struct node **npp) dn->number = inum; dn->dirents = 0; - rwlock_init (&dn->dinlock); - rwlock_init (&dn->sinlock); - rwlock_init (&dn->datalock); - dn->dinloc = 0; - dn->sinloc = 0; - dn->dinloclen = 0; - dn->sinloclen = 0; - dn->sininfo = 0; + rwlock_init (&dn->allocptrlock); dn->fileinfo = 0; np = diskfs_make_node (dn); @@ -92,6 +85,7 @@ iget (ino_t inum, struct node **npp) spin_unlock (&diskfs_node_refcnt_lock); err = read_disknode (np); + if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) np->allocsize = fragroundup (sblock, np->dn_stat.st_size); else @@ -146,31 +140,63 @@ diskfs_node_norefs (struct node *np) np->dn->hnext->dn->hprevp = np->dn->hprevp; if (np->dn->dirents) free (np->dn->dirents); - if (np->dn->sininfo || np->dn->fileinfo || np->dn->dinloc - || np->dn->sinloc || np->dn->dinloclen || np->dn->sinloclen) - { - printf ("I=%d\n", np->dn->number); - printf ("Hard %d\tSoft %d\n", np->references, np->light_references); - fflush (stdout); - } - assert (!np->dn->sininfo); assert (!np->dn->fileinfo); - assert (!np->dn->dinloc); - assert (!np->dn->sinloc); - assert (!np->dn->dinloclen); - assert (!np->dn->sinloclen); free (np->dn); free (np); } -/* The last hard referencs to a node has gone away; arrange to have +/* The last hard reference to a node has gone away; arrange to have all the weak references dropped that can be. */ void -diskfs_lost_hardrefs (struct node *np) +diskfs_try_dropping_softrefs (struct node *np) { drop_pager_softrefs (np); } +/* The last hard reference to a node has gone away. */ +void +diskfs_lost_hardrefs (struct node *np) +{ + /* Check and see if there is a pager which has only + one reference (ours). If so, then drop that reference, + breaking the cycle. The complexity in this routine + is all due to this cycle. */ + + if (np->dn->fileinfo) + { + spin_lock (&_libports_portrefcntlock); + if (np->fileinfo->p->pi.refcnt == 1) + { + struct pager *p; + + /* The only way to get a new reference to the pager + in this state is to call diskfs_get_filemap; this + can't happen as long as we hold NP locked. So + we can safely unlock _libports_portrefcntlock for + the following call. */ + spin_unlock (&_libports_portrefcntlock); + + /* Right now the node is locked with no hard refs; + this is an anomolous 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 + unreference. */ + p = np->fileinfo->p; + np->fileinfo = 0; + diskfs_nref (np); + pager_unreference (p); + + assert (np->references == 1 && np->light_references == 0); + + /* This will do the real deallocate. Whew. */ + diskfs_nput (np); + } + else + spin_unlock (&_libports_portrefcntlock); + } +} + /* A new hard reference to a node has been created; it's now OK to have unused weak references. */ void @@ -184,7 +210,7 @@ static error_t read_disknode (struct node *np) { struct stat *st = &np->dn_stat; - struct dinode *di = &dinodes[np->dn->number]; + struct dinode *di = dino (np->dn->number); error_t err; volatile long long pid = getpid (); @@ -192,6 +218,8 @@ read_disknode (struct node *np) if (err) return err; + np->istranslated = !! di->translator; + st->st_fstype = FSTYPE_UFS; st->st_fsid = pid; st->st_ino = np->dn->number; @@ -241,7 +269,7 @@ static void write_node (struct node *np) { struct stat *st = &np->dn_stat; - struct dinode *di = &dinodes[np->dn->number]; + struct dinode *di = dino (np->dn->number); error_t err; assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); @@ -329,7 +357,7 @@ create_symlink_hook (struct node *np, char *target) if (err) return err; - bcopy (target, dinodes[np->dn->number].di_shortlink, len); + bcopy (target, (dino (np->dn->number))->di_shortlink, len); np->dn_stat.st_size = len; np->dn_set_ctime = 1; np->dn_set_mtime = 1; @@ -356,7 +384,7 @@ read_symlink_hook (struct node *np, if (err) return err; - bcopy (dinodes[np->dn->number].di_shortlink, buf, np->dn_stat.st_size); + bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); np->dn_set_atime = 1; diskfs_end_catch_exception (); @@ -387,10 +415,9 @@ void diskfs_write_disknode (struct node *np, int wait) { write_node (np); - sync_dinode (np, wait); + sync_dinode (np->dn->number, wait); } - /* Implement the diskfs_set_statfs callback from the diskfs library; see for the interface description. */ error_t @@ -430,7 +457,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, if (err) return err; - blkno = dinodes[np->dn->number].di_trans; + blkno = (dino (np->dn->number))->di_trans; if (namelen && !blkno) { @@ -441,27 +468,31 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, diskfs_end_catch_exception (); return err; } - dinodes[np->dn->number].di_trans = blkno; + (dino (np->dn->number))->di_trans = blkno; np->dn_set_ctime = 1; } else if (!namelen && blkno) { /* Clear block for translator going away. */ ffs_blkfree (np, blkno, sblock->fs_bsize); - dinodes[np->dn->number].di_trans = 0; + (dino (np->dn->number))->di_trans = 0; + np->istranslated = 0; np->dn_set_ctime = 1; } - diskfs_end_catch_exception (); - if (namelen) { bcopy (&namelen, buf, sizeof (u_int)); bcopy (name, buf + sizeof (u_int), namelen); - err = dev_write_sync (fsbtodb (sblock, blkno), - (vm_address_t)buf, sblock->fs_bsize); + + bcopy (buf, fsaddr (sblock, blkno), sblock->fs_bsize); + sync_disk_blocks (blkno, sblock->fs_bsize, 1); + + np->istranslated = 1; np->dn_set_ctime = 1; } + + diskfs_end_catch_exception (); return err; } @@ -478,15 +509,11 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) err = diskfs_catch_exception (); if (err) return err; - blkno = dinodes[np->dn->number].di_trans; - diskfs_end_catch_exception (); + blkno = (dino (np->dn->number))->di_trans; assert (blkno); - - err = dev_read_sync (fsbtodb (sblock, blkno), (vm_address_t *)&buf, - sblock->fs_bsize); - if (err) - return err; + bcopy (fsaddr (sblock, blkno), buf, sblock->fs_bsize); + diskfs_end_catch_exception (); datalen = *(u_int *)buf; if (datalen > *namelen) @@ -496,21 +523,6 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) return 0; } -/* Implement the diskfs_node_translated callback from the diskfs library. - See for the interface description. */ -int -diskfs_node_translated (struct node *np) -{ - int ret; - - if (diskfs_catch_exception ()) - return 0; - - ret = !! dinodes[np->dn->number].di_trans; - diskfs_end_catch_exception (); - return ret; -} - /* Called when all hard ports have gone away. */ void diskfs_shutdown_soft_ports () -- cgit v1.2.3 From e05d7cfc35960065686a8e27b921bf508bcace36 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 04:52:31 +0000 Subject: Formerly pager.c.~33~ --- ufs/pager.c | 595 ++++++++++++++---------------------------------------------- 1 file changed, 139 insertions(+), 456 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 9b883b2b..6f7ecc9f 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -21,18 +21,9 @@ #include #include -/* Filesystem blocks of inodes per cylinder group */ -static int infsb_pcg; - spin_lock_t pagerlistlock = SPIN_LOCK_INITIALIZER; struct user_pager_info *filepagerlist; -static void enqueue_pager (struct user_pager_info *); -static void dequeue_pager (struct user_pager_info *); -static daddr_t indir_alloc (struct node *, int, int); - -struct mutex pagernplock = MUTEX_INITIALIZER; - #ifdef DONT_CACHE_MEMORY_OBJECTS #define MAY_CACHE 0 #else @@ -62,10 +53,8 @@ find_address (struct user_pager_info *upi, } else { - int vblkno = lblkno (sblock, offset); - int fsbaddr; - struct node *volatile np; - error_t err; + struct iblock_spec indirs[NINDIR + 1]; + struct node *np; np = upi->np; @@ -74,9 +63,8 @@ find_address (struct user_pager_info *upi, if (offset >= np->allocsize) { - err = EIO; rwlock_reader_unlock (&np->dn->allocptrlock); - return err; + return EIO; } if (offset + __vm_page_size > np->allocsize) @@ -84,47 +72,19 @@ find_address (struct user_pager_info *upi, else *disksize = __vm_page_size; - if (err = diskfs_catch_exception ()) - { - rwlock_reader_unlock (&np->dn->allocptrlock); - return err; - } - - if (vblkno < NDADDR) - fsbaddr = dinodes[np->dn->number].di_db[vblkno]; + err = fetch_indir_spec (np, lblkno (offset), indirs); + if (err) + rwlock_reader_unlock (&np->dn->allocptrlock); else { - vblkno -= NDADDR; - assert (vblkno < np->dn->sinloclen); - int alloc = 1; - - /* It's in the INDIR_DOUBLE area */ - if (vblkno >= sblock->fs_bsize / sizeof (daddr_t)) - { - /* Check if the double indirect block is allocated. */ - if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE] == 0) - alloc = 0; - - /* Check if the appropriate single indirect block is - allocated. */ - else if (np->dinloc[vblkno / sblock->fs_bsize - 1] == 0) - alloc = 0; - } + if (indirs[0].bno) + *addr = (fsbtodb (sblock, indirs[0].bno) + + blkoff (sblkc, offset) / DEV_BSIZE); else - if (dinodes[np->dn->number].di_ib[INDIR_SINGLE] == 0) - alloc = 0; - - fsbaddr = alloc ? np->dn->sinloc[vblkno - NDADDR] : 0; + *addr = 0; } - diskfs_end_catch_exception (); - - if (fsbaddr) - *addr = (fsbtodb (sblock, fsbaddr) - + blkoff (sblock, offset) / DEV_BSIZE); - else - *addr = 0; - - return 0; + + return err; } } @@ -208,15 +168,21 @@ pager_unlock_page (struct user_pager_info *pager, { struct node *np; error_t err; - daddr_t vblkno; - daddr_t *slot, *table; - daddr_t newblk; - struct disknode *dn; + struct iblock_spec indirs[NINDIR + 1]; + daddr_t bno; + + /* Zero an sblock->fs_bsize piece of disk starting at BNO, + synchronously. We do this on newly allocated indirect + blocks before setting the pointer to them to ensure that an + indirect block absolutely never points to garbage. */ + void zero_disk_block (int bno) + { + bzero (indir_block (bno), sblock->fs_bsize); + sync_disk_blocks (bno, sblock->fs_bsize, 1); + }; /* Problem--where to get cred values for allocation here? */ - vblkno = lblkno (address); - printf ("Unlock page request, Object %#x\tOffset %#x...", pager, address); fflush (stdout); @@ -238,60 +204,106 @@ pager_unlock_page (struct user_pager_info *pager, return EIO; } - if (diskfs_catch_exception ()) + err = fetch_indir_spec (np, lblkno (address), indirs); + if (err) { rwlock_writer_unlock (&dn->allocptrlock); return EIO; } - if (vblkno < NDADDR) - { - slot = &dinodes[np->dn->number].di_db[vblkno]; - table = dinodes[np->dn->number].di_db; - } - else + /* See if we need a triple indirect block; fail if we do. */ + assert (indirs[0].offset == -1 + || indirs[1].offset == -1 + || indirs[2].offset == -1); + + /* Check to see if this block is allocated. */ + if (indirs[0].bno == 0) { - assert (vblkno - NDADDR < np->dn->sinloclen); - slot = &np->dn->sinloc[vblkno - NDADDR]; - table = np->dn->sinloc; - } + if (indirs[0].offset == -1) + { + err = ffs_alloc (np, lblkno (address), + ffs_blkpref (np, lblkno (address), + lblkno (address), di->di_db), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + assert (lblkno (address) < NDADDR); + indirs[0].bno = di->di_db[lblkno (address)] = bno; + } + else + { + daddr_t *siblock; - if (*slot) - { - diskfs_end_catch_exception (); - rwlock_write_unlock (&dn->allocptrlock); - return 0; - } - - else + /* We need to set siblock to the single indirect block + array; see if the single indirect block is allocated. */ + if (indirs[1].bno == 0) { - ffs_alloc (np, vblkno, - ffs_blkpref (np, vblkno, slot - table, table), - sblock->fs_bsize, &newblk, 0); - if (newblk) + if (indirs[1].offset == -1) { - *slot = newblk; - err = 0; + err = ffs_alloc (np, lblkno (address), + ffs_blkpref (np, lblkno (address), + INDIR_SINGLE, di->di_ib), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; } else - err = ENOSPC; + { + daddr_t *diblock; + + /* We need to set diblock to the double indirect + block array; see if the double indirect block is + allocated. */ + if (indirs[2].bno == 0) + { + /* This assert because triple indirection is + not supported. */ + assert (indirs[2].offset == -1); + + err = ffs_alloc (np, lblkno (address), + ffs_blkpref (np, lblkno (address), + INDIR_DOUBLE, di->di_ib), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + } + + diblock = indir_block (indirs[2].bno); + + /* Now we can allocate the single indirect block */ + + err = ffs_alloc (np, lblkno (address), + ffs_blkpref (np, lblkno (address), + indirs[1].offset, diblock), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[1].bno = diblock[indirs[1].offset] = bno; + } } - mutex_unlock (&sinmaplock); - diskfs_end_catch_exception (); + + siblock = indir_block (indirs[1].bno); + + /* Now we can allocate the data block. */ + + err = ffs_alloc (np, lblkno (address), + ffs_blkpref (np, lblkno (address), + indirs[0].offset, siblock), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + indirs[0].bno = siblock[indirs[0].offset] = bno; } - rwlock_writer_unlock (&np->dn->datalock, np->dn); - break; - - default: - err = 0; } - if (err) - printf ("denied\n"); - else - printf ("succeeded\n"); - fflush (stdout); - + out: + diskfs_end_catch_exception (); + rwlock_writer_unlock (&np->dn->datalock, np->dn); return err; } @@ -302,51 +314,15 @@ pager_report_extent (struct user_pager_info *pager, vm_address_t *offset, vm_size_t *size) { - *offset = 0; - switch (pager->type) - { - case DINODE: - *size = sblock->fs_ipg * sblock->fs_ncg * sizeof (struct dinode); - break; - - case CG: - *size = sblock->fs_bsize * sblock->fs_ncg; - break; - - case DINDIR: - *size = sblock->fs_ipg * sblock->fs_ncg * sblock->fs_bsize; - break; - - case SINDIR: - { - /* This computation is known to sin_remap below, as - is the static `*offset = 0' assignment above. */ - - int sizet; - - /* sizet = disk size of the file */ - sizet = pager->np->allocsize; - - /* sizet = number of fs blocks in file */ - sizet = (sizet + sblock->fs_bsize - 1) / sblock->fs_bsize; + assert (pager->type == DISK || pager->type == FILE_DATA); - /* sizet = number of fs blocks not list in di_db */ - sizet -= NDADDR; - - /* sizet = space to hold that many pointers */ - sizet *= sizeof (daddr_t); + *offset = 0; - /* And that's the size of the sindir area for the file. */ - *size = sizet; - } - break; - - case FILE_DATA: - *size = pager->np->allocsize; - break; - } + if (pager->type == DISK) + *size = diskpagersize; + else + *size = pager->np->allocsize; - *size = round_page (*size); return 0; } @@ -355,192 +331,15 @@ pager_report_extent (struct user_pager_info *pager, void pager_clear_user_data (struct user_pager_info *upi) { - struct node *np = upi->np; - - switch (upi->type) - { - case FILE_DATA: - mutex_lock (&sinmaplock); - mutex_lock (&pagernplock); - np->dn->fileinfo = 0; - mutex_unlock (&pagernplock); - if (np->dn->sinloc) - sin_unmap (np); - mutex_unlock (&sinmaplock); - break; - - case SINDIR: - mutex_lock (&dinmaplock); - mutex_lock (&pagernplock); - np->dn->sininfo = 0; - mutex_unlock (&pagernplock); - if (np->dn->dinloc) - din_unmap (np); - mutex_unlock (&dinmaplock); - break; - - case DINDIR: - dinpager = 0; - return; - case CG: - cgpager = 0; - return; - case DINODE: - dinodepager = 0; - return; - } - - if (np) - diskfs_nrele_light (np); - dequeue_pager (upi); + assert (upi->type == FILE_DATA); + diskfs_nrele_light (upi->np); + *upi->prevp = upi->next; + if (upi->next) + upi->next->prevp = upi->prevp; free (upi); } -/* This is called (with sinmaplock held) to map the contents of the - single indirect blocks of node NP. */ -void -sin_map (struct node *np) -{ - int err; - struct user_pager_info *upi; - mach_port_t port; - vm_address_t offset; - vm_size_t extent; - - assert (!np->dn->sinloc); - - mutex_lock (&pagernplock); - if (np->dn->sininfo) - { - upi = np->dn->sininfo; - port = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), port, port, - MACH_MSG_TYPE_MAKE_SEND); - } - else - { - upi = malloc (sizeof (struct user_pager_info)); - upi->type = SINDIR; - upi->np = np; - diskfs_nref_light (np); - - upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - np->dn->sininfo = upi; - enqueue_pager (upi); - port = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), port, port, - MACH_MSG_TYPE_MAKE_SEND); - } - pager_report_extent (upi, &offset, &extent); - - err = vm_map (mach_task_self (), (vm_address_t *)&np->dn->sinloc, - extent, 0, 1, port, offset, 0, VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); - mach_port_deallocate (mach_task_self (), port); - - assert (!err); - np->dn->sinloclen = extent / sizeof (daddr_t); - - diskfs_register_memory_fault_area (np->dn->sininfo->p, offset, - np->dn->sinloc, extent); - mutex_unlock (&pagernplock); -} - -/* This is caled when a file (NP) grows (to size NEWSIZE) to see - if the single indirect mapping needs to grow to. sinmaplock - must be held. - The caller must set ip->i_allocsize to reflect newsize. */ -void -sin_remap (struct node *np, - int newsize) -{ - struct user_pager_info *upi; - int err; - vm_address_t offset; - vm_size_t size; - mach_port_t port; - - mutex_lock (&pagernplock); - upi = np->dn->sininfo; - - pager_report_extent (upi, &offset, &size); - - /* This is the same calculation as in pager_report_extent - for the SINDIR case. */ - newsize = (newsize + sblock->fs_bsize - 1) / sblock->fs_bsize; - newsize -= NDADDR; - newsize *= sizeof (daddr_t); - newsize = round_page (newsize); - - assert (newsize >= size); - if (newsize != size) - { - diskfs_unregister_memory_fault_area (np->dn->sinloc, size); - vm_deallocate (mach_task_self (), (u_int) np->dn->sinloc, size); - - port = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), port, port, - MACH_MSG_TYPE_MAKE_SEND); - err = vm_map (mach_task_self (), (u_int *)&np->dn->sinloc, newsize, - 0, 1, port, 0, 0, VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); - mach_port_deallocate (mach_task_self (), port); - assert (!err); - np->dn->sinloclen = newsize / sizeof (daddr_t); - diskfs_register_memory_fault_area (np->dn->sininfo->p, 0, - np->dn->sinloc, newsize); - } - mutex_unlock (&pagernplock); -} - -/* This is called (with sinmaplock set) to unmap the - single indirect block mapping of node NP. */ -void -sin_unmap (struct node *np) -{ - vm_offset_t start; - vm_size_t len; - - assert (np->dn->sinloc); - pager_report_extent (np->dn->sininfo, &start, &len); - diskfs_unregister_memory_fault_area (np->dn->sinloc, len); - vm_deallocate (mach_task_self (), (u_int) np->dn->sinloc, len); - np->dn->sinloclen = 0; - np->dn->sinloc = 0; -} - -/* This is called (with dinmaplock set) to map the contents - of the double indirect block of node NP. */ -void -din_map (struct node *np) -{ - int err; - - assert (!np->dn->dinloc); - - err = vm_map (mach_task_self (), (vm_address_t *)&np->dn->dinloc, - sblock->fs_bsize, 0, 1, dinport, - np->dn->number * sblock->fs_bsize, 0, - VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, - VM_INHERIT_NONE); - assert (!err); - np->dn->dinloclen = sblock->fs_bsize / sizeof (daddr_t); - diskfs_register_memory_fault_area (dinpager->p, - np->dn->number * sblock->fs_bsize, - np->dn->dinloc, sblock->fs_bsize); -} - -/* This is called (with dinmaplock set) to unmap the double - indirect block mapping of node NP. */ -void -din_unmap (struct node *np) -{ - diskfs_unregister_memory_fault_area (np->dn->dinloc, sblock->fs_bsize); - vm_deallocate (mach_task_self (), (u_int) np->dn->dinloc, sblock->fs_bsize); - np->dn->dinloclen = 0; - np->dn->dinloc = 0; -} /* Initialize the pager subsystem. */ void @@ -602,89 +401,22 @@ pager_init () MACH_MSG_TYPE_MAKE_SEND); } -/* Allocate one indirect block for NP. TYPE is either INDIR_DOUBLE or - INDIR_SINGLE; IND is (for INDIR_SINGLE) the index of the block - (The first block is 0, the next 1, etc.). */ -static daddr_t -indir_alloc (struct node *np, - int type, - int ind) -{ - daddr_t bn; - daddr_t lbn; - int error; - - switch (type) - { - case INDIR_DOUBLE: - lbn = NDADDR + sblock->fs_bsize / sizeof (daddr_t); - break; - case INDIR_SINGLE: - if (ind == 0) - lbn = NDADDR; - else - lbn = NDADDR + ind * sblock->fs_bsize / sizeof (daddr_t); - break; - default: - assert (0); - } - - if (error = ffs_alloc (np, NDADDR, - ffs_blkpref (np, lbn, 0, (daddr_t *)0), - sblock->fs_bsize, &bn, 0)) - return 0; - - /* We do this write synchronously so that the inode never - points at an indirect block full of garbage */ - if (dev_write_sync (fsbtodb (sblock, bn), zeroblock, sblock->fs_bsize)) - { - ffs_blkfree (np, bn, sblock->fs_bsize); - return 0; - } - else - return bn; -} - -/* Write a single dinode (NP->dn->number) to disk. This might sync more - than actually necessary; it's really just an attempt to avoid syncing - all the inodes. Return immediately if WAIT is clear. */ -void -sync_dinode (struct node *np, - int wait) -{ - vm_offset_t offset, offsetpg; - - offset = np->dn->number * sizeof (struct dinode); - offsetpg = offset / __vm_page_size; - offset = offsetpg * __vm_page_size; - - pager_sync_some (dinodepager->p, offset, __vm_page_size, wait); -} - /* This syncs a single file (NP) to disk. Wait for all I/O to complete if WAIT is set. NP->lock must be held. */ void diskfs_file_update (struct node *np, int wait) { - mutex_lock (&pagernplock); if (np->dn->fileinfo) pager_sync (np->dn->fileinfo->p, wait); - mutex_unlock (&pagernplock); - mutex_lock (&pagernplock); - if (np->dn->sininfo) - pager_sync (np->dn->sininfo->p, wait); - mutex_unlock (&pagernplock); - - pager_sync_some (dinpager->p, np->dn->number * sblock->fs_bsize, - sblock->fs_bsize, wait); + /* XXX FIXME sync indirect blocks XXX */ diskfs_node_update (np, wait); } /* Call this to create a FILE_DATA pager and return a send right. - NP must be locked. The toplock must be locked. */ + NP must be locked. */ mach_port_t diskfs_get_filemap (struct node *np) { @@ -697,7 +429,6 @@ diskfs_get_filemap (struct node *np) && (!direct_symlink_extension || np->dn_stat.st_size >= sblock->fs_maxsymlinklen))); - mutex_lock (&pagernplock); if (!np->dn->fileinfo) { upi = malloc (sizeof (struct user_pager_info)); @@ -706,7 +437,15 @@ diskfs_get_filemap (struct node *np) diskfs_nref_light (np); upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; - enqueue_pager (upi); + ports_port_ref (p); + + spin_lock (&pagerlistlock); + upi->next = filepagerlist; + upi->prevp = &filepagerlist; + if (upi->next) + upi->next->prevp = &upi->next; + filepagerlist = upi; + spin_unlock (&pagerlistlock); } right = pager_get_port (np->dn->fileinfo->p); mutex_unlock (&pagernplock); @@ -721,17 +460,9 @@ diskfs_get_filemap (struct node *np) void drop_pager_softrefs (struct node *np) { - if (MAY_CACHE) - { - mutex_lock (&pagernplock); - if (np->dn->fileinfo) - pager_change_attributes (np->dn->fileinfo->p, 0, - MEMORY_OBJECT_COPY_DELAY, 0); - if (np->dn->sininfo) - pager_change_attributes (np->dn->sininfo->p, 0, - MEMORY_OBJECT_COPY_DELAY, 0); - mutex_unlock (&pagernplock); - } + if (MAY_CACHE && np->dn->fileinfo) + pager_change_attributes (np->dn->fileinfo->p, 0, + MEMORY_OBJECT_COPY_DELAY, 0); } /* Call this when we should turn on caching because it's no longer @@ -739,67 +470,19 @@ drop_pager_softrefs (struct node *np) void allow_pager_softrefs (struct node *np) { - if (MAY_CACHE) - { - mutex_lock (&pagernplock); - if (np->dn->fileinfo) - pager_change_attributes (np->dn->fileinfo->p, 1, - MEMORY_OBJECT_COPY_DELAY, 0); - if (np->dn->sininfo) - pager_change_attributes (np->dn->sininfo->p, 1, - MEMORY_OBJECT_COPY_DELAY, 0); - mutex_unlock (&pagernplock); - } + if (MAY_CACHE && np->dn->fileinfo) + pager_change_attributes (np->dn->fileinfo->p, 1, + MEMORY_OBJECT_COPY_DELAY, 0); } /* Call this to find out the struct pager * corresponding to the FILE_DATA pager of inode IP. This should be used *only* as a subsequent argument to register_memory_fault_area, and will be deleted when - the kernel interface is fixed. */ + the kernel interface is fixed. NP must be locked. */ struct pager * diskfs_get_filemap_pager_struct (struct node *np) { - struct pager *p; - mutex_unlock (&pagernplock); - p = np->dn->fileinfo->p; - mutex_unlock (&pagernplock); - return p; -} - -/* Add pager P to the appropriate list (filelist or sinlist) of pagers - of its type. */ -static void -enqueue_pager (struct user_pager_info *p) -{ - struct user_pager_info **listp; - - if (p->type == FILE_DATA) - listp = &filelist; - else if (p->type == SINDIR) - listp = &filelist; - else - return; - - spin_lock (&pagerlistlock); - - p->next = *listp; - p->prevp = listp; - *listp = p; - if (p->next) - p->next->prevp = &p->next; - - spin_unlock (&pagerlistlock); -} - -/* Remove pager P from the linked list it was placed on with enqueue_pager. */ -static void -dequeue_pager (struct user_pager_info *p) -{ - spin_lock (&pagerlistlock); - if (p->next) - p->next->prevp = p->prevp; - *p->prevp = p->next; - spin_unlock (&pagerlistlock); + return np->dn->fileinfo->p; } /* Call function FUNC (which takes one argument, a pager) on each pager, with -- cgit v1.2.3 From 1fefc1704f3653c72bcc4963be6afd19621f0093 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:40:50 +0000 Subject: Formerly main.c.~20~ --- ufs/main.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 5fd1ff11..2f3aad09 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -150,6 +150,9 @@ main (int argc, char **argv) /* Map the entire disk. */ create_disk_pager (); + /* Start the first request thread, to handle RPCs and page requests. */ + diskfs_spawn_first_thread (); + err = vm_map (mach_task_self (), (vm_address_t *)&disk_image, diskpagersize, 0, 1, diskpagerport, 0, 0, VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), @@ -157,30 +160,20 @@ main (int argc, char **argv) VM_INHERIT_NONE); assert (!err); - if (diskpagersize < sblock->fs_size * sblock->fs_fsize) - { - fprintf (stderr, - "Disk size %d less than necessary " - "(superblock says we need %ld)\n", - sizes[DEV_GET_SIZE_DEVICE_SIZE], - sblock->fs_size * sblock->fs_fsize); - exit (1); - } - get_hypermetadata (); - /* Check to make sure device size is big enough. */ - if (sizes[DEV_GET_SIZE_DEVICE_SIZE] != 0) - if (sizes[DEV_GET_SIZE_DEVICE_SIZE] < sblock->fs_size * sblock->fs_fsize) + if (diskpagersize < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size %d less than necessary " + "Disk size (%d) less than necessary " "(superblock says we need %ld)\n", sizes[DEV_GET_SIZE_DEVICE_SIZE], sblock->fs_size * sblock->fs_fsize); exit (1); } + vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); + /* If the filesystem has new features in it, don't pay attention to the user's request not to use them. */ if ((sblock->fs_inodefmt == FS_44INODEFMT @@ -201,10 +194,6 @@ main (int argc, char **argv) inode_init (); pager_init (); - /* Start the first request thread, to handle RPCs and page requests - resulting from warp_root below. */ - diskfs_spawn_first_thread (); - /* Find our root node. */ warp_root (); -- cgit v1.2.3 From 422856454093ef77ba75ed7d23c3a50743e1fa1c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:41:31 +0000 Subject: Formerly sizes.c.~20~ --- ufs/sizes.c | 719 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 357 insertions(+), 362 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 0bc0e547..a349eb40 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -30,283 +30,236 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAY_CACHE 1 #endif -static void dindir_drop (struct node *); -static void sindir_drop (struct node *, int, int); -static void poke_pages (memory_object_t, vm_offset_t, vm_offset_t); - -/* Truncate node NP to be at most LENGTH bytes. */ -/* The inode must be locked, and we must have the conch. */ -/* This is a pain. Sigh. */ + +/* Implement the diskfs_truncate callback; sse for the + interface description. */ error_t diskfs_truncate (struct node *np, off_t length) { - daddr_t lastblock, olastblock, bn; - off_t osize; - int bsize, idx; - mach_port_t obj; - - osize = np->dn_stat.st_size; - if (length >= osize) + int offset; + daddr_t lastiblock[NIADDR], lastblock, bn; + struct dinode *di = dino (np->dn->number); + int blocksfreed = 0; + + if (length >= np->dn_stat.st_size) return 0; - /* Check to see if this is a kludged symlink. */ + assert (!diskfs_readonly); + + /* First check to see if this is a kludged symlink; if so + this is special. */ if (direct_symlink_extension && S_ISLNK (np->dn_stat.st_mode) - && osize < sblock->fs_maxsymlinklen) + && np->dn_stat.st_size < sblock->fs_maxsymlinklen) { error_t err; - - /* Prune it here */ - err = diskfs_catch_exception (); - if (err) + + if (err = diskfs_catch_exception ()) return err; - - bzero (dinodes[np->dn->number].di_shortlink + length, - osize - length); + bzero (di->di_shortlink + length, np->dn_stat.st_size - length); diskfs_end_catch_exception (); np->dn_stat.st_size = length; - np->dn_set_ctime = 1; - np->dn_set_mtime = 1; + np->dn_set_ctime = np->dn_set_mtime = 1; + return 0; + } + + /* If the file is not being trucated to a block boundary, + the zero the partial bit in the new last block. */ + offset = blkoff (sblock, length); + if (offset) + { + int bsize; /* size of new last block */ + int savesize = np->allocsize; + + np->allocsize = length; /* temporary */ + bsize = blksize (sblock, np, lbkno (sblock, length)); + np->allocsize = savesize; + diskfs_node_rdwr (np, zeroblock, length, bsize - offset, 1, 0, 0); + diskfs_file_update (np, 1); } - /* Calculate block number of last block */ - lastblock = lblkno (sblock, length + sblock->fs_bsize - 1) - 1; - olastblock = lblkno (sblock, osize + sblock->fs_bsize - 1) - 1; - - /* If the prune is not to a block boundary, zero the bit upto the - next block boundary. */ - if (blkoff (sblock, length)) - diskfs_node_rdwr (np, (void *) zeroblock, length, - (blksize (sblock, np, lastblock) - - blkoff (sblock, length)), - 1, 0, 0); - - /* We are going to throw away the block pointers for the blocks - olastblock+1 through lastblock. This will cause the underlying - data to become zeroes, because of the behavior of pager_read_page - (in ufs/pager.c). Consequently, we have to take action to force - the kernel to immediately undertake any delayed copies that - implicitly depend on the data we are flushing. We also have to - prevent any new delayed copies from being undertaken until we - have finished the flush. */ + rwlock_writer_lock (&np->allocptrlock); + + /* Now flush all the data past the new size from the kernel. + Also force any delayed copies of this data to take place + immediately. (We are changing the data implicitly to zeros + and doing it without the kernels immediate knowledge; + this forces us to help out the kernel thusly.) */ if (np->dn->fileinfo) { - pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, + pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np); - mach_port_insert_right (mach_task_self (), obj, obj, + mach_port_insert_right (mach_task_self (), obj, obj, MACH_MSG_TYPE_MAKE_SEND); - poke_pages (obj, round_page (length), round_page (osize)); + poke_pages (obj, round_page (length), round_page (np->allocsize)); mach_port_deallocate (mach_task_self (), obj); + pager_flush_some (np->fileinfo->p, round_page (length), + np->allocsize - length, 1); } + + /* Calculate index into node's block list of direct + and indirect blocks which we want to keep. Lastblock + is -1 when the file is truncated to 0. */ + lastblock = lblkno (sblock, length + sblock->fs_bsize - 1) - 1; + lastiblock[INDIR_SINGLE] = lastblock - NDADDR; + lastiblock[INDIR_DOUBLE] = lastiblock[INDIR_SINGLE] - NINDIR (sblock); + lastiblock[INDIR_TRIPLE] = (lastiblock[INDIR_DOUBLE] + - NINDIR (sblock) * NINDIR (sblock)); - rwlock_writer_lock (&np->dn->datalock, np->dn); + /* Normalize to -1 indicating that this block will not be needed. */ + for (level = INDIR_TRIPLE; level >= INDIR_SINGLE; level--) + if (lastiblock[level] < 0) + lastiblock[level] = -1; - /* Update the size now. If we crash, fsck can finish freeing the - blocks. */ + /* Update the size on disk; fsck will finish freeing blocks if necessary + should we crash. */ np->dn_stat.st_size = length; - np->dn_stat_dirty = 1; + np->dn_set_mtime = 1; + np->dn_set_ctime = 1; + diskfs_node_update (np, 1); - /* Flush the old data. */ - if (np->dn->fileinfo) - pager_flush_some (np->dn->fileinfo->p, - (lastblock == -1 ? 0 : lastblock) * sblock->fs_bsize, - (olastblock - lastblock) * sblock->fs_bsize, 1); + /* Free the blocks. */ + + err = diskfs_catch_exception (); + if (err) + { + rwlock_writer_unlock (&np->allocptrlock); + return err; + } - /* Drop data blocks mapped by indirect blocks */ - if (olastblock >= NDADDR) + /* Indirect blocks first. */ + for (level = INDIR_TRIPLE; level >= INDIR_SINGLE; level--) + if (lastiblock[level] == -1 && di->di_ib[level]) + { + int count; + count = free_indir (np, di->di_ib[level], level); + blocksfreed += count; + di->di_ib[level] = 0; + } + + /* Whole direct blocks or frags */ + for (i = NDADDR - 1; i > lastblock; i--) { - daddr_t first2free; + long bsize; - mutex_lock (&sinmaplock); - if (!np->dn->sinloc) - sin_map (np); + bn = dn->di_db[i]; + if (bn == 0) + continue; - if (lastblock + 1 > NDADDR) - first2free = lastblock + 1; - else - first2free = NDADDR; - - for (idx = first2free; idx <= olastblock; idx ++) - { - assert (idx - NDADDR < np->dn->sinloclen); - if (np->dn->sinloc[idx - NDADDR]) - { - ffs_blkfree (np, np->dn->sinloc[idx - NDADDR], sblock->fs_bsize); - np->dn->sinloc[idx - NDADDR] = 0; - np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; - np->dn_stat_dirty = 1; - } - } + bsize = blksize (sblock, np, i); + ffs_blkfree (sblock, bn, bsize); + blocksfreed += btodb (bsize); - /* Prune the block pointers handled by the sindir pager. This will - free all the indirect blocks and such as necessary. */ - sindir_drop (np, lblkno(sblock, - (first2free - NDADDR) * sizeof (daddr_t)), - lblkno (sblock, (olastblock - NDADDR) * sizeof (daddr_t))); - - if (!np->dn->fileinfo) - sin_unmap (np); - mutex_unlock (&sinmaplock); + dn->di_db[i] = 0; } - /* Prune the blocks mapped directly from the inode */ - for (idx = lastblock + 1; idx < NDADDR; idx++) + /* Finally, check to see if the new last direct block is + changing size; if so release any frags necessary. */ + if (lastblock >= 0 + && dn->di_db[lastblock]) { - bn = dinodes[np->dn->number].di_db[idx]; - if (bn) + bn = dn->di_db[lastblock]; + long oldspace, newspace; + + oldspace = blksize (sblock, np, lastblock); + np->allocsize = length; + newspace = blksize (sblock, np, lastblock); + + assert (newspace); + + if (oldspace - newspace) { - dinodes[np->dn->number].di_db[idx] = 0; - assert (idx <= olastblock); - if (idx == olastblock) - bsize = blksize (sblock, np, idx); - else - bsize = sblock->fs_bsize; - ffs_blkfree (np, bn, bsize); - np->dn_stat.st_blocks -= bsize / DEV_BSIZE; - np->dn_stat_dirty = 1; + bn += numfrags (sblock, newspace); + ffs_blkfree (np, bn, oldspace - newspace); + blocksfreed += btodb (oldspace - newspace) } } + else + np->allocsize = length; - if (lastblock >= 0 && lastblock < NDADDR) - { - /* Look for a change in the size of the last direct block */ - bn = dinodes[np->dn->number].di_db[lastblock]; - if (bn) - { - off_t oldspace, newspace; - - oldspace = blksize (sblock, np, lastblock); - newspace = fragroundup (sblock, blkoff (sblock, length));; - assert (newspace); - if (oldspace - newspace) - { - bn += numfrags (sblock, newspace); - ffs_blkfree (np, bn, oldspace - newspace); - np->dn_stat.st_blocks -= (oldspace - newspace) / DEV_BSIZE; - np->dn_stat_dirty = 1; - } - } - } + diskfs_end_catch_exception (); - if (lastblock < NDADDR) - np->allocsize = fragroundup (sblock, length); - else - np->allocsize = blkroundup (sblock, length); + np->dn_set_ctime = 1; + diskfs_node_update (np, 1); - rwlock_writer_unlock (&np->dn->datalock, np->dn); + rwlock_writer_unlock (&np->allocptrlock); - /* Now we can allow delayed copies again */ + /* Now we can permit delayed copies again. */ if (np->dn->fileinfo) pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY, 0); - - diskfs_file_update (np, 1); - return 0; -} - -/* Deallocate the double indirect block of the file NP. */ -static void -dindir_drop (struct node *np) -{ - rwlock_writer_lock (&np->dn->dinlock, np->dn); - pager_flush_some (dinpager->p, np->dn->number * sblock->fs_bsize, - sblock->fs_bsize, 1); - - if (dinodes[np->dn->number].di_ib[INDIR_DOUBLE]) - { - ffs_blkfree (np, dinodes[np->dn->number].di_ib[INDIR_DOUBLE], - sblock->fs_bsize); - dinodes[np->dn->number].di_ib[INDIR_DOUBLE] = 0; - np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; - } - - rwlock_writer_unlock (&np->dn->dinlock, np->dn); + return 0; } - -/* Deallocate the single indirect blocks of file IP from - FIRST through LAST inclusive. */ -static void -sindir_drop (struct node *np, - int first, - int last) +/* Free indirect block BNO of level LEVEL; recursing if necessary + to free other indirect blocks. Return the number of disk + blocks freed. */ +static int +free_indir (struct node *np, daddr_t bno, int level) { - int idx; + int count = 0; + daddr_t *addrs; + int i; + struct indir_dirty *d, *prev, *nxt; - rwlock_writer_lock (&np->dn->sinlock, np->dn); + assert (bno); - pager_flush_some (np->dn->sininfo->p, first * sblock->fs_bsize, - (last - first + 1) * sblock->fs_bsize, 1); + addrs = indir_block (bno); + for (i = 0; i < NINDIR (sblock); i++) + if (addrs[i]) + { + if (level == INDIR_SINGLE) + { + ffs_blkfree (np, addrs[i], sblock->fs_bsize); + count += btodb (sblock->fs_bsize); + } + else + count += free_indir (addrs[i], level - 1); + } - /* Drop indirect blocks found in the double indirect block */ - if (last > 1) + /* Subtlety: this block is no longer necessary; the information + the kernel has cached corresponding to ADDRS is now unimportant. + Consider that if this block is allocated to a file, it will then + be double cached and the kernel might decide to write out + the disk_image version of the block. So we have to flush + the block from the kernel's memory, making sure we do it + synchronously--and BEFORE we attach it to the free list + with ffs_blkfree. */ + pager_flush_some (diskpager->p, fsaddr (bno), sblock->fs_bsize, 1); + + /* We should also take this block off the inode's list of + dirty indirect blocks if it's there. */ + prev = 0; + d = np->dirty; + while (d) { - mutex_lock (&dinmaplock); - if (!np->dn->dinloc) - din_map (np); - for (idx = first; idx = last; idx++) + next = d->next; + if (d->bno == bno) { - assert (idx - 1 < np->dn->dinloclen); - if (np->dn->dinloc[idx - 1]) - { - ffs_blkfree (np, np->dn->dinloc[idx - 1], sblock->fs_bsize); - np->dn->dinloc[idx - 1] = 0; - np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; - } + if (prev) + prev->next = next; + else + np->dirty = next; + free (d); } - - /* If we no longer need the double indirect block, drop it. */ - if (first <= 1) - dindir_drop (np); - - mutex_lock (&dinmaplock); - if (!np->dn->sininfo) - din_unmap (np); - mutex_unlock (&dinmaplock); - } - - /* Drop the block from the inode if we don't need it any more */ - if (first == 0 && dinodes[np->dn->number].di_ib[INDIR_SINGLE]) - { - ffs_blkfree (np, dinodes[np->dn->number].di_ib[INDIR_SINGLE], - sblock->fs_bsize); - dinodes[np->dn->number].di_ib[INDIR_SINGLE] = 0; - np->dn_stat.st_blocks -= sblock->fs_bsize / DEV_BSIZE; - } - rwlock_writer_unlock (&np->dn->sinlock, np->dn); -} - -/* Write something to each page from START to END inclusive of memory - object OBJ, but make sure the data doesns't actually change. */ -static void -poke_pages (memory_object_t obj, - vm_offset_t start, - vm_offset_t end) -{ - vm_address_t addr, poke; - vm_size_t len; - error_t err; - - while (start < end) - { - len = 8 * vm_page_size; - if (len > end - start) - len = end - start; - addr = 0; - err = vm_map (mach_task_self (), &addr, len, 0, 1, obj, start, 0, - VM_PROT_WRITE|VM_PROT_READ, VM_PROT_READ|VM_PROT_WRITE, 0); - if (!err) + else { - for (poke = addr; poke < addr + len; poke += vm_page_size) - *(volatile int *)poke = *(volatile int *)poke; - vm_deallocate (mach_task_self (), addr, len); + prev = d; + next = d->next; } - start += len; + d = next; } + + /* Free designated block */ + ffs_blkfree (np, bno, sblock->fs_bsize); + count += btodb (sblock->fs_bsize); + + return count; } + /* Implement the diskfs_grow callback; see for the interface description. */ @@ -315,197 +268,239 @@ diskfs_grow (struct node *np, off_t end, struct protid *cred) { - daddr_t lbn, pbn, nb; - int osize, size; - int err; - volatile daddr_t dealloc_on_error = 0; - volatile int dealloc_size = 0; - volatile off_t zero_off1 = 0, zero_off2 = 0; - volatile int zero_len1 = 0, zero_len2 = 0; - volatile off_t poke_off1 = 0, poke_off2 = 0; - volatile off_t poke_len1 = 0, poke_len2 = 0; - vm_address_t zerobuf; + daddr_t lbn, olbn; + int size, osize; + error_t err; + struct dinode *di = dino (np->dn->number); + off_t poke_off; + size_t poke_len = 0; + + /* Zero an sblock->fs_bsize piece of disk starting at BNO, + synchronously. We do this on newly allocated indirect + blocks before setting the pointer to them to ensure that an + indirect block absolutely never points to garbage. */ + void zero_disk_block (int bno) + { + bzero (indir_block (bno), sblock->fs_bsize); + sync_disk_blocks (bno, sblock->fs_bsize, 1); + }; + /* Check to see if we don't actually have to do anything */ if (end <= np->allocsize) return 0; - - rwlock_writer_lock (&np->dn->datalock, np->dn); - - /* This deallocation works for the calls to alloc, but not for - realloccg. I'm not sure how to prune the fragment down, especially if - we grew a fragment and then couldn't allocate the piece later. - freeing it all up is a royal pain, largely punted right now... -mib. - */ - if (err = diskfs_catch_exception()) - { - if (dealloc_on_error) - ffs_blkfree (np, dealloc_on_error, dealloc_size); - goto out; - } - /* This is the logical block number of what will be the last block. */ + assert (!diskfs_readonly); + + /* The new last block of the file. */ lbn = lblkno (sblock, end + sblock->fs_bsize - 1) - 1; - /* This is the size to be of that block if it is in the NDADDR array. */ + /* This is the size of that block if it is in the NDADDR array. */ size = fragroundup (sblock, blkoff (sblock, end)); if (size == 0) size = sblock->fs_bsize; - /* if we are writing a new block, then an old one may need to be - reallocated into a full block. */ + rwlock_writer_lock (&np->dn->allocptrlock); - nb = lblkno (sblock, np->allocsize + sblock->fs_bsize - 1) - 1; - if (np->allocsize && nb < NDADDR && nb < lbn) + /* The old last block of the file. */ + olbn = lbkno (sblock, np->allocsize + sblock->fs_bsize - 1) - 1; + + /* This is the size of that block if it is in the NDADDR array. */ + osize = fragroundup (sblock, blkoff (sblock, np->allocsize)); + if (osize == 0) + osize = sblock->fs_bsize; + + /* If this end point is a new block and the file currently + has a fragment, then expand the fragment to a full block. */ + if (np->allocsize && olbn < NDADDR && olbn < lbn) { - osize = blksize (sblock, np, nb); - if (osize < sblock->fs_bsize && osize > 0) + if (osize < sblock->fs_bsize) { - daddr_t old_pbn; + daddr_t olb_pbn, bno; err = ffs_realloccg (np, nb, - ffs_blkpref (np, nb, (int)nb, - dinodes[np->dn->number].di_db), - osize, sblock->fs_bsize, &pbn, cred); + ffs_blkpref (np, lbn, lbn, di->di_db), + osize, sblock->fs_bsize, &bno, cred); if (err) goto out; - np->allocsize = (nb + 1) * sblock->fs_bsize; - old_pbn = dinodes[np->dn->number].di_db[nb]; - dinodes[np->dn->number].di_db[nb] = pbn; - - /* The new disk blocks should be zeros but might not be. - This is a sanity measure that I'm not sure is necessary. */ - zero_off1 = nb * sblock->fs_bsize + osize; - zero_len1 = nb * sblock->fs_bsize + sblock->fs_bsize - zero_off1; + old_pbn = di->di_db + di->di_db[nb] = bno; + np->dn_set_ctime = 1; + + dev_write_sync (fsbtodb (bno) + btodb (osize), + zeroblock, sblock->fs_bsize - osize); if (pbn != old_pbn) { - /* Make sure that the old contents get written out by - poking the pages. */ - poke_off1 = nb * sblock->fs_bsize; - poke_len1 = osize; + /* Make sure the old contents get written out + to the new address by poking the pages. */ + poke_off = nb * sblock->fs_bsize; + poke_len = osize; } } } - - /* allocate this block */ + if (lbn < NDADDR) { - nb = dinodes[np->dn->number].di_db[lbn]; - - if (nb != 0) + daddr_t bno, old_pbn = di->di_db[lbn]; + + if (old_pbn != 0) { - /* consider need to reallocate a fragment. */ - osize = blkoff (sblock, np->allocsize); - if (osize == 0) - osize = sblock->fs_bsize; - if (size > osize) - { - err = ffs_realloccg (np, lbn, - ffs_blkpref (np, lbn, lbn, - dinodes[np->dn->number].di_db), - osize, size, &pbn, cred); - if (err) - goto out; - dinodes[np->dn->number].di_db[lbn] = pbn; - - /* The new disk blocks should be zeros but might not be. - This is a sanity measure that I'm not sure is necessary. */ - zero_off2 = lbn * sblock->fs_bsize + osize; - zero_len2 = lbn * sblock->fs_bsize + size - zero_off2; + /* The last block is already allocated. Therefore we + must be expanding the fragment. Make sure that's really + what we're up to. */ + assert (size > osize); + assert (lbn == olbn); + + err = ffs_realloccg (np, lbn, + ffs_blkpref (np, lbn, lbn, di->di_db), + osize, size, &bno, cred); + if (err) + goto out; + + di->di_db[lbn] = bno; + np->dn_sat_ctime = 1; + + dev_write_sync (fsbtodb (bno) + btodb (osize), + zeroblock, size - osize); - if (pbn != nb) - { - /* Make sure that the old contents get written out by - poking the pages. */ - poke_off2 = lbn * sblock->fs_bsize; - poke_len2 = osize; - } + if (pbn != old_pbn) + { + assert (!poke_len); + + /* Make sure the old contents get written out to + the new address by poking the pages. */ + poke_off = lbn * sblock->fs_bsize; + poke_len = osize; } } else { - err = ffs_alloc (np, lbn, - ffs_blkpref (np, lbn, lbn, - dinodes[np->dn->number].di_db), - size, &pbn, cred); + /* Allocate a new last block. */ + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, lbn, di->di_db), + size, &bno, cred); if (err) goto out; - dealloc_on_error = pbn; - dealloc_size = size; - dinodes[np->dn->number].di_db[lbn] = pbn; + + di->di_db[lbn] = pbn; + np->dn_set_ctime = 1; + + dev_write_sync (fsbtodb (bno), zeroblock, size); } - np->allocsize = fragroundup (sblock, end); } else { - /* Make user the sindir area is mapped at the right size. */ - mutex_lock (&sinmaplock); - if (np->dn->sinloc) - { - sin_remap (np, end); - np->allocsize = blkroundup (sblock, end); - } - else - { - np->allocsize = blkroundup (sblock, end); - sin_map (np); - } + struct iblock_spec indirs[NINDIR + 1]; + int i; + daddr_t *siblock; + + /* Count the number of levels of indirection. */ + err = fetch_indir_spec (np, lbn, indirs); + if (err) + goto out; - lbn -= NDADDR; - assert (lbn < np->dn->sinloclen); - if (!np->dn->sinloc[lbn]) + /* Make sure we didn't miss the NDADDR case + above somehow. */ + assert (indirs[0].offset != -1); + + /* See if we need a triple indirect block; fail if so. */ + assert (indirs[1].offset == -1 || indirs[2].offset == -1); + + /* Check to see if this block is allocated. If it is + that's an error. */ + assert (indirs[0].bno == 0); + + /* We need to set SIBLOCK to the single indirect block + array; see if the single indirect block is allocated. */ + if (indirs[1].bno == 0) { - err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn + NDADDR, lbn, - np->dn->sinloc), - sblock->fs_bsize, &pbn, cred); - if (err) - goto out; - dealloc_on_error = pbn; - dealloc_size = sblock->fs_bsize; - np->dn->sinloc[lbn] = pbn; + /* Allocate it. */ + if (indirs[1].offset == -1) + { + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, INDIR_SINGLE, di->di_ib), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; + } + else + { + daddr_t *diblock; + + /* We need to set diblock to the double indirect block + array; see if the double indirect block is allocated. */ + if (indirs[2].bno == 0) + { + /* This assert because triple indirection is not + supported. */ + assert (indirs[2].offset == -1); + err = ffs_alloc (np, lbn + ffs_blkpref (np, lbn, + INDIR_DOUBLE, di->di_ib), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + } + + diblock = indir_block (indirs[2].bno); + mark_indir_dirty (indirs[2].bno); + + /* Now we can allocate the single indirect block */ + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, + indirs[1].offset, diblock), + sblock->fs_bsize, &bno, 0); + if (err) + goto out; + zero_disk_block (bno); + indirs[1].bno = diblock[indirs[1].offset] = bno; + } } - if (!np->dn->fileinfo) - sin_unmap (np); - mutex_unlock (&sinmaplock); - } + + siblock = indir_block (indirs[1].bno); + mark_indir_dirty (np, indirs[1].bno); - if (np->conch.holder) - ioserver_put_shared_data (np->conch.holder); + /* Now we can allocate the data block. */ + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, indirs[0].offset, siblock), + sblock->fn_bsize, &bno, 0); + if (err) + goto out; + indirs[0].bno = siblock[indirs[0].offset] = bno; + dev_write_sync (fsbtodb (bno), zeroblock, sblock->fs_bsize); + } out: - diskfs_end_catch_exception (); - rwlock_writer_unlock (&np->dn->datalock, np->dn); - - /* Do the pokes and zeros that we requested before; they have to be - done here because we can't cause a page while holding datalock. */ - if (zero_len1 || zero_len2) + if (!err) { - vm_allocate (mach_task_self (), &zerobuf, - zero_len1 > zero_len2 ? zero_len1 : zero_len2, 1); - if (zero_len1) - diskfs_node_rdwr (np, (char *) zerobuf, zero_off1, - zero_len1, 1, cred, 0); - if (zero_len2) - diskfs_node_rdwr (np, (char *) zerobuf, zero_off2, - zero_len2, 1, cred, 0); - vm_deallocate (mach_task_self (), zerobuf, - zero_len1 > zero_len2 ? zero_len1 : zero_len2); + int newallocsize; + if (lbn < NDADDR) + newallocsize = (lbn - 1) * sblock->fs_bsize + size; + else + newallocsize = lbn * sblock->fs_bsize; + assert (newallocsize > np->allocsize); + np->allocsize = newallocsize; } - if (poke_len1 || poke_len2) + + rwlock_writer_unlock (&np->allocptrlock); + + /* If we expanded a fragment, then POKE_LEN will be set. + We need to poke the requested amount of the memory object + so that the kernel will write out the data to the new location + at a suitable time. */ + if (poke_len) { - mach_port_t obj; obj = diskfs_get_filemap (np); - mach_port_insert_right (mach_task_self (), obj, obj, + mach_port_insert_reght (mach_task_self (), obj, obj, MACH_MSG_TYPE_MAKE_SEND); - if (poke_len1) - poke_pages (obj, trunc_page (poke_off1), - round_page (poke_off1 + poke_len1)); - if (poke_len2) - poke_pages (obj, trunc_page (poke_off2), - round_page (poke_off2 + poke_len2)); + poke_pages (obj, trunc_page (poke_off), + round_page (poke_off + poke_len)); mach_port_deallocate (mach_task_self (), obj); } - diskfs_file_update (np, 0); - return err; -} +} + -- cgit v1.2.3 From d7c2d027981d86ff9d5370dbd424650ea2c37fbc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:49:57 +0000 Subject: Formerly ufs.h.~24~ --- ufs/ufs.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index a1186531..a4f0579c 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -23,6 +23,7 @@ #include #include #include +#include "fs.h" /* Define this if memory objects should not be cached by the kernel. @@ -54,6 +55,8 @@ struct disknode struct rwlock allocptrlock; + struct dirty_indir *dirty; + struct user_pager_info *fileinfo; }; @@ -85,6 +88,14 @@ struct iblock_spec int offset; }; +/* Identifies an indirect block owned by this file which + might be dirty. */ +struct dirty_indir +{ + daddr_t bno; /* Disk address of block. */ + struct dirty_indir *next; +}; + /* Get a writer lock on reader-writer lock LOCK for disknode DN */ extern inline void rwlock_writer_lock (struct rwlock *lock) @@ -202,7 +213,7 @@ int direct_symlink_extension; extern inline struct dinode * dino (ino_t inum) { - return (struct disknode *) + return (struct dinode *) (disk_image + fsaddr (sblock, ino_to_fsba (sblock, inum)) + ino_to_fsbo (sblock, inum)); @@ -212,21 +223,21 @@ dino (ino_t inum) extern inline daddr_t * indir_block (daddr_t bno) { - return (daddr_t *) (disk_image + fsaddr (fsbtodb (bno))); + return (daddr_t *) (disk_image + fsaddr (sblock, bno)); } /* Convert a cg number to the cylinder group. */ extern inline struct cg * cg_locate (int ncg) { - return (struct cg *) (disk_image + fsaddr (cgtod (sblock, ncg))); + return (struct cg *) (disk_image + fsaddr (sblock, cgtod (sblock, ncg))); } /* Sync part of the disk */ extern inline void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait) { - pager_sync_some (diskpager->p, fsaddr (blkno), nbytes, wait); + pager_sync_some (diskpager->p, fsaddr (sblock, blkno), nbytes, wait); } /* Sync an disk inode */ -- cgit v1.2.3 From 7d0599b3ffb4a08bfdcdaf8e0383f05c58517b51 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:50:13 +0000 Subject: Formerly alloc.c.~16~ --- ufs/alloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 2d27c1e7..b7c1ec40 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -54,7 +54,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #include "ufs.h" -#include "fs.h" #include "dinode.h" #include -- cgit v1.2.3 From 8a847cdca4840b9834994782789b1e4f69749ae3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:50:32 +0000 Subject: Formerly inode.c.~38~ --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index d5c17e99..e5e74736 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -17,7 +17,6 @@ #include "ufs.h" #include "dinode.h" -#include "fs.h" #include #include #include @@ -73,6 +72,7 @@ iget (ino_t inum, struct node **npp) dn->dirents = 0; rwlock_init (&dn->allocptrlock); + dn->dirty = 0; dn->fileinfo = 0; np = diskfs_make_node (dn); -- cgit v1.2.3 From d4d738ac07a1b6280b2cbcca64ec5757071fa846 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:50:43 +0000 Subject: Formerly hyper.c.~12~ --- ufs/hyper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index a59637fb..e63e9eff 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "fs.h" #include "dinode.h" #include #include @@ -60,6 +59,10 @@ get_hypermetadata (void) exit (1); } + assert ((__vm_page_size % DEV_BSIZE) == 0); + assert ((sblock->fs_bsize % DEV_BSIZE) == 0); + assert (__vm_page_size <= sblock->fs_bsize); + /* If this is an old filesystem, then we have some more work to do; some crucial constants might not be set; we are therefore forced to set them here. */ -- cgit v1.2.3 From 71cbb9b6c50902866147c6c01e15b825c5dac93c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:50:56 +0000 Subject: Formerly bmap.c.~3~ --- ufs/bmap.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index c2eea356..58ec06f4 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -21,10 +21,6 @@ #include "ufs.h" #include "dinode.h" -#include "fs.h" - -/* Number of block pointers that fit in a single disk block */ -#define NIPTR (sblock->fs_bsize / sizeof (daddr_t)) /* For logical block number LBN of file NP, look it the block address, giving the "path" of indirect blocks to the file, starting @@ -52,21 +48,21 @@ fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs) lbn -= NDADDR; - indirs[0].offset = lbn % NIPTR; + indirs[0].offset = lbn % NINDIR (sblock) - if (lbn / NIPTR) + if (lbn / NINBIR (sblock)) { /* We will use the double indirect block */ int ibn; daddr_t *diblock; - ibn = lbn / NIPTR - 1; + ibn = lbn / NINDIR (sblock) - 1; - indirs[1].offset = ibn % NIPTR; + indirs[1].offset = ibn % NINDIR (sblock); /* We don't support triple indirect blocks, but this is where we'd do it. */ - assert (!(ibn / NIPTR)); + assert (!(ibn / NINDIR (sblock))); indirs[2].offset = -1; indirs[2].bno = di->di_ib[INDIR_DOUBLE]; @@ -97,7 +93,21 @@ fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs) return 0; } + +/* Mark indirect block BNO as dirty on node NP's list. NP must + be locked. */ +void +mark_indir_dirty (struct node *np, daddr_t bno) +{ + struct dirty_indir *d; + for (d = np->dn->dirty; d; d = d->next) + if (d->bno == bno) + return; - + d = malloc (sizeof (struct dirty_indir)); + d->bno = bno; + d->next = np->dn->dirty; + np->dn->dirty = d; +} -- cgit v1.2.3 From e35942f33cbf6e41afae957bd59a787a81fa34dd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 21:50:58 +0000 Subject: Formerly pager.c.~34~ --- ufs/pager.c | 95 ++++++++++++++++--------------------------------------------- 1 file changed, 24 insertions(+), 71 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 6f7ecc9f..d5b3849f 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "fs.h" #include "dinode.h" #include #include @@ -273,6 +272,7 @@ pager_unlock_page (struct user_pager_info *pager, } diblock = indir_block (indirs[2].bno); + mark_indir_dirty (indirs[2].bno); /* Now we can allocate the single indirect block */ @@ -288,6 +288,7 @@ pager_unlock_page (struct user_pager_info *pager, } siblock = indir_block (indirs[1].bno); + mark_indir_dirty (np, indirs[1].bno); /* Now we can allocate the data block. */ @@ -341,65 +342,18 @@ pager_clear_user_data (struct user_pager_info *upi) -/* Initialize the pager subsystem. */ +/* Create a the DISK pager, initializing DISKPAGER, and DISKPAGERPORT */ void -pager_init () +create_disk_pager () { - struct user_pager_info *upi; - vm_address_t offset; - vm_size_t size; - error_t err; - - /* firewalls: */ - assert ((DEV_BSIZE % sizeof (struct dinode)) == 0); - assert ((__vm_page_size % DEV_BSIZE) == 0); - assert ((sblock->fs_bsize % DEV_BSIZE) == 0); - assert ((sblock->fs_ipg % sblock->fs_inopb) == 0); - assert (__vm_page_size <= sblock->fs_bsize); - - infsb_pcg = sblock->fs_ipg / sblock->fs_inopb; - - vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); - - upi = malloc (sizeof (struct user_pager_info)); - upi->type = DINODE; - upi->np = 0; - upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - dinodepager = upi; - dinodeport = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), dinodeport, dinodeport, + diskpager = malloc (sizeof (struct user_pager_info)); + diskpager->type = DISK; + diskpager->np = 0; + diskpager->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + diskpagerport = pager_get_port (upi->p); + mach_port_insert_right (mach_task_self (), diskpagerport, diskpagerport, MACH_MSG_TYPE_MAKE_SEND); - pager_report_extent (upi, &offset, &size); - err = vm_map (mach_task_self (), (vm_address_t *)&dinodes, size, - 0, 1, dinodeport, offset, 0, VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); - assert (!err); - diskfs_register_memory_fault_area (dinodepager->p, 0, dinodes, size); - - upi = malloc (sizeof (struct user_pager_info)); - upi->type = CG; - upi->np = 0; - upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - cgpager = upi; - cgport = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), cgport, cgport, - MACH_MSG_TYPE_MAKE_SEND); - pager_report_extent (upi, &offset, &size); - err = vm_map (mach_task_self (), &cgs, size, - 0, 1, cgport, offset, 0, VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, VM_INHERIT_NONE); - assert (!err); - diskfs_register_memory_fault_area (cgpager->p, 0, (void *)cgs, size); - - upi = malloc (sizeof (struct user_pager_info)); - upi->type = DINDIR; - upi->np = 0; - upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - dinpager = upi; - dinport = pager_get_port (upi->p); - mach_port_insert_right (mach_task_self (), dinport, dinport, - MACH_MSG_TYPE_MAKE_SEND); -} +} /* This syncs a single file (NP) to disk. Wait for all I/O to complete if WAIT is set. NP->lock must be held. */ @@ -407,10 +361,18 @@ void diskfs_file_update (struct node *np, int wait) { + struct indir_dirty *d, *tmp; + if (np->dn->fileinfo) pager_sync (np->dn->fileinfo->p, wait); - /* XXX FIXME sync indirect blocks XXX */ + for (d = np->dn->dirty; d; d = tmp) + { + sync_disk_blocks (d->bno, sblock->fs_bsize, wait); + tmp = d->next; + free (d); + } + np->dn->dirty = 0; diskfs_node_update (np, wait); } @@ -486,23 +448,17 @@ diskfs_get_filemap_pager_struct (struct node *np) } /* Call function FUNC (which takes one argument, a pager) on each pager, with - all file pagers being processed before sindir pagers, and then the dindir, - dinode, and cg pagers (in that order). Make the calls while holding - no locks. */ + all file pagers being processed before the disk pager. Make the calls + while holding no locks. */ static void pager_traverse (void (*func)(struct user_pager_info *)) { struct user_pager_info *p; struct item {struct item *next; struct user_pager_info *p;} *list = 0; struct item *i; - int looped; - /* Putting SINDIR's on first means they will be removed last; after - the FILE_DATA pagers. */ spin_lock (&pagerlistlock); - for (p = sinlist, looped = 0; - p || (!looped && (looped = 1, p = filelist)); - p = p->next) + for (p = filepagerlit; p; p = p->next) { i = alloca (sizeof (struct item)); i->next = list; @@ -518,11 +474,8 @@ pager_traverse (void (*func)(struct user_pager_info *)) pager_unreference (i->p->p); } - (*func)(dinpager); - (*func)(dinodepager); - (*func)(cgpager); + (*func)(diskpager); } - /* Shutdown all the pagers. */ void -- cgit v1.2.3 From 75ba58c3a5a613bfdda55938e9e2c38b922dfc13 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 22:04:08 +0000 Subject: Formerly hyper.c.~13~ --- ufs/hyper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index e63e9eff..a5d05bc8 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -25,8 +25,6 @@ static int oldformat = 0; void get_hypermetadata (void) { - error_t err; - sblock = malloc (SBSIZE); assert (!diskfs_catch_exception ()); @@ -118,6 +116,8 @@ diskfs_set_hypermetadata (int wait, int clean) void copy_sblock () { + int clean = 1; /* XXX wrong... */ + assert (!diskfs_catch_exception ()); spin_lock (&alloclock); -- cgit v1.2.3 From 703bd469dfdc4bd41d987fb2cd08a662090f750a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 22:06:02 +0000 Subject: Formerly main.c.~21~ --- ufs/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 2f3aad09..b5e05f41 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -17,7 +17,6 @@ #include "ufs.h" -#include "fs.h" #include #include #include -- cgit v1.2.3 From 2b0776c062bea2d2e8b509c40832f5e4051aa64d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 22:08:49 +0000 Subject: Formerly ufs.h.~25~ --- ufs/ufs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index a4f0579c..3088b2a2 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -168,6 +168,8 @@ vm_address_t zeroblock; struct fs *sblock; struct csum *csum; +int sblock_dirty; +int csum_dirty; void *disk_image; @@ -270,7 +272,7 @@ void inode_init (void); void write_all_disknodes (void); /* From pager.c: */ -void pager_init (void); +void create_disk_pager (void); void din_map (struct node *); void sin_map (struct node *); void sin_remap (struct node *, int); -- cgit v1.2.3 From a02e74948d63c82185875d40b201c3633a8ee3df Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 22:08:50 +0000 Subject: Formerly inode.c.~39~ --- ufs/inode.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index e5e74736..1caf947e 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -40,8 +40,6 @@ inode_init () int n; for (n = 0; n < INOHSZ; n++) nodehash[n] = 0; - mutex_init (&dinmaplock); - mutex_init (&sinmaplock); } /* Fetch inode INUM, set *NPP to the node structure; @@ -165,7 +163,7 @@ diskfs_lost_hardrefs (struct node *np) if (np->dn->fileinfo) { spin_lock (&_libports_portrefcntlock); - if (np->fileinfo->p->pi.refcnt == 1) + if (np->dn->fileinfo->p->pi.refcnt == 1) { struct pager *p; @@ -182,8 +180,8 @@ diskfs_lost_hardrefs (struct node *np) give ourselves a reference back so that we are really allowed to hold the lock. Then we can do the unreference. */ - p = np->fileinfo->p; - np->fileinfo = 0; + p = np->dn->fileinfo->p; + np->dn->fileinfo = 0; diskfs_nref (np); pager_unreference (p); @@ -218,7 +216,7 @@ read_disknode (struct node *np) if (err) return err; - np->istranslated = !! di->translator; + np->istranslated = !! di->di_translator; st->st_fstype = FSTYPE_UFS; st->st_fsid = pid; @@ -485,7 +483,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, bcopy (&namelen, buf, sizeof (u_int)); bcopy (name, buf + sizeof (u_int), namelen); - bcopy (buf, fsaddr (sblock, blkno), sblock->fs_bsize); + bcopy (buf, disk_image + fsaddr (sblock, blkno), sblock->fs_bsize); sync_disk_blocks (blkno, sblock->fs_bsize, 1); np->istranslated = 1; @@ -512,7 +510,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) blkno = (dino (np->dn->number))->di_trans; assert (blkno); - bcopy (fsaddr (sblock, blkno), buf, sblock->fs_bsize); + bcopy (disk_image + fsaddr (sblock, blkno), buf, sblock->fs_bsize); diskfs_end_catch_exception (); datalen = *(u_int *)buf; -- cgit v1.2.3 From 7f3059c7939bde35e4b7d1798834306c8bc7af8e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 23 Sep 1994 22:10:03 +0000 Subject: Formerly pager.c.~35~ --- ufs/pager.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index d5b3849f..e4abf85d 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -41,6 +41,8 @@ find_address (struct user_pager_info *upi, int *disksize, struct rwlock **nplock) { + error_t err; + assert (upi->type == DISK || upi->type == FILE_DATA); if (upi->type == DISK) @@ -52,7 +54,7 @@ find_address (struct user_pager_info *upi, } else { - struct iblock_spec indirs[NINDIR + 1]; + struct iblock_spec indirs[NIADDR + 1]; struct node *np; np = upi->np; @@ -71,14 +73,14 @@ find_address (struct user_pager_info *upi, else *disksize = __vm_page_size; - err = fetch_indir_spec (np, lblkno (offset), indirs); + err = fetch_indir_spec (np, lblkno (sblock, offset), indirs); if (err) rwlock_reader_unlock (&np->dn->allocptrlock); else { if (indirs[0].bno) *addr = (fsbtodb (sblock, indirs[0].bno) - + blkoff (sblkc, offset) / DEV_BSIZE); + + blkoff (sblkoc, offset) / DEV_BSIZE); else *addr = 0; } @@ -167,8 +169,9 @@ pager_unlock_page (struct user_pager_info *pager, { struct node *np; error_t err; - struct iblock_spec indirs[NINDIR + 1]; + struct iblock_spec indirs[NIADDR + 1]; daddr_t bno; + struct disknode *dn; /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect @@ -199,11 +202,11 @@ pager_unlock_page (struct user_pager_info *pager, { printf ("attempt to unlock at last block denied\n"); fflush (stdout); - rwlock_writer_unlock (&np->dn->datalock, np->dn); + rwlock_writer_unlock (&dn->allocptrlock); return EIO; } - err = fetch_indir_spec (np, lblkno (address), indirs); + err = fetch_indir_spec (np, lblkno (sblock, address), indirs); if (err) { rwlock_writer_unlock (&dn->allocptrlock); @@ -220,14 +223,14 @@ pager_unlock_page (struct user_pager_info *pager, { if (indirs[0].offset == -1) { - err = ffs_alloc (np, lblkno (address), - ffs_blkpref (np, lblkno (address), - lblkno (address), di->di_db), + err = ffs_alloc (np, lblkno (sblock, address), + ffs_blkpref (np, lblkno (sblock, address), + lblkno (sblock, address), di->di_db), sblock->fs_bsize, &bno, 0); if (err) goto out; - assert (lblkno (address) < NDADDR); - indirs[0].bno = di->di_db[lblkno (address)] = bno; + assert (lblkno (sblock, address) < NDADDR); + indirs[0].bno = di->di_db[lblkno (sblock, address)] = bno; } else { @@ -239,8 +242,8 @@ pager_unlock_page (struct user_pager_info *pager, { if (indirs[1].offset == -1) { - err = ffs_alloc (np, lblkno (address), - ffs_blkpref (np, lblkno (address), + err = ffs_alloc (np, lblkno (sblock, address), + ffs_blkpref (np, lblkno (sblock, address), INDIR_SINGLE, di->di_ib), sblock->fs_bsize, &bno, 0); if (err) @@ -261,8 +264,9 @@ pager_unlock_page (struct user_pager_info *pager, not supported. */ assert (indirs[2].offset == -1); - err = ffs_alloc (np, lblkno (address), - ffs_blkpref (np, lblkno (address), + err = ffs_alloc (np, lblkno (sblock, address), + ffs_blkpref (np, lblkno (sblock, + address), INDIR_DOUBLE, di->di_ib), sblock->fs_bsize, &bno, 0); if (err) @@ -276,8 +280,8 @@ pager_unlock_page (struct user_pager_info *pager, /* Now we can allocate the single indirect block */ - err = ffs_alloc (np, lblkno (address), - ffs_blkpref (np, lblkno (address), + err = ffs_alloc (np, lblkno (sblock, address), + ffs_blkpref (np, lblkno (sblock, address), indirs[1].offset, diblock), sblock->fs_bsize, &bno, 0); if (err) @@ -292,12 +296,15 @@ pager_unlock_page (struct user_pager_info *pager, /* Now we can allocate the data block. */ - err = ffs_alloc (np, lblkno (address), - ffs_blkpref (np, lblkno (address), + err = ffs_alloc (np, lblkno (sblock, address), + ffs_blkpref (np, lblkno (sblock, address), indirs[0].offset, siblock), sblock->fs_bsize, &bno, 0); if (err) goto out; + + dev_write_sync (fsbtodb (bno), zeroblock, sblock->fs_bsize); + indirs[0].bno = siblock[indirs[0].offset] = bno; } } -- cgit v1.2.3 From d8f33f64f398997cbf7e35a93ccd4bf7b42787b1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 26 Sep 1994 16:51:55 +0000 Subject: Formerly inode.c.~40~ --- ufs/inode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 1caf947e..3edb697f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -155,6 +155,7 @@ diskfs_try_dropping_softrefs (struct node *np) void diskfs_lost_hardrefs (struct node *np) { + struct port_info *pi; /* Check and see if there is a pager which has only one reference (ours). If so, then drop that reference, breaking the cycle. The complexity in this routine @@ -163,9 +164,9 @@ diskfs_lost_hardrefs (struct node *np) if (np->dn->fileinfo) { spin_lock (&_libports_portrefcntlock); - if (np->dn->fileinfo->p->pi.refcnt == 1) + pi = np->dn->fileinfo->p; + if (pi->refcnt == 1) { - struct pager *p; /* The only way to get a new reference to the pager in this state is to call diskfs_get_filemap; this @@ -216,7 +217,7 @@ read_disknode (struct node *np) if (err) return err; - np->istranslated = !! di->di_translator; + np->istranslated = !! di->di_trans; st->st_fstype = FSTYPE_UFS; st->st_fsid = pid; @@ -499,6 +500,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, error_t diskfs_get_translator (struct node *np, char **namep, u_int *namelen) { + XXX FIXME error_t err; daddr_t blkno; char *buf; -- cgit v1.2.3 From e67942011aa05d0fed6baed98556b3a207ce7c54 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 01:30:00 +0000 Subject: entered into RCS --- ufs/subr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/subr.c b/ufs/subr.c index 6c7ea5f2..2b356ddc 100644 --- a/ufs/subr.c +++ b/ufs/subr.c @@ -34,7 +34,6 @@ */ #include "ufs.h" -#include "fs.h" #if 0 /* Not needed in GNU Hurd ufs. */ /* -- cgit v1.2.3 From d813134b3217dcbf47a938659f9acd7dbfe1127f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:04:19 +0000 Subject: Formerly main.c.~22~ --- ufs/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index b5e05f41..5f41265b 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -189,9 +189,7 @@ main (int argc, char **argv) diskfs_set_hypermetadata (1, 0); } - /* Initiialize our pagers so we can begin using them. */ inode_init (); - pager_init (); /* Find our root node. */ warp_root (); -- cgit v1.2.3 From 33c30e925639806931dbc124ee7c94a8cbd83c16 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:04:42 +0000 Subject: Formerly Makefile.~35~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 17bcf3f4..941452ff 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -19,7 +19,7 @@ dir := ufs makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ - sizes.c subr.c tables.c + sizes.c subr.c tables.c bmap.c OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ -- cgit v1.2.3 From 0692f912df6d760fdc7310a5733d07f63376aad4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:51:13 +0000 Subject: Formerly ufs.h.~26~ --- ufs/ufs.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 3088b2a2..6d706100 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -24,7 +24,7 @@ #include #include #include "fs.h" - +#include "dinode.h" /* 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 @@ -218,7 +218,7 @@ dino (ino_t inum) return (struct dinode *) (disk_image + fsaddr (sblock, ino_to_fsba (sblock, inum)) - + ino_to_fsbo (sblock, inum)); + + ino_to_fsbo (sblock, inum) * sizeof (struct dinode)); } /* Convert a indirect block number to a daddr_t table. */ @@ -257,6 +257,10 @@ daddr_t ffs_blkpref (struct node *, daddr_t, int, daddr_t *); error_t ffs_realloccg(struct node *, daddr_t, daddr_t, int, int, daddr_t *, struct protid *); +/* From bmap.c */ +error_t fetch_indir_spec (struct node *, daddr_t, struct iblock_spec *); +void mark_indir_dirty (struct node *, daddr_t); + /* From devio.c: */ error_t dev_write_sync (daddr_t addr, vm_address_t data, long len); error_t dev_write (daddr_t addr, vm_address_t data, long len); -- cgit v1.2.3 From 6ef59be7e2ab2cdb8a80356ea45e4b1218610c62 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:51:54 +0000 Subject: Formerly alloc.c.~17~ --- ufs/alloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index b7c1ec40..c881454b 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -54,7 +54,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #include "ufs.h" -#include "dinode.h" #include /* These don't work *at all* here; don't even try setting them. */ -- cgit v1.2.3 From 33cb86f397d267719d3aa68c40b15abb3c31c465 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:51:57 +0000 Subject: Formerly bmap.c.~4~ --- ufs/bmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index 58ec06f4..18c53662 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -18,19 +18,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "ufs.h" -#include "dinode.h" /* For logical block number LBN of file NP, look it the block address, giving the "path" of indirect blocks to the file, starting with the least indirect. Fill *INDIRS with information for the block. */ error_t -fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs) +fetch_indir_spec (struct node *np, volatile daddr_t lbn, + struct iblock_spec *indirs) { struct dinode *di = dino (np->dn->number); - int boff; error_t err; daddr_t *siblock; @@ -48,9 +46,9 @@ fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs) lbn -= NDADDR; - indirs[0].offset = lbn % NINDIR (sblock) + indirs[0].offset = lbn % NINDIR (sblock); - if (lbn / NINBIR (sblock)) + if (lbn / NINDIR (sblock)) { /* We will use the double indirect block */ int ibn; -- cgit v1.2.3 From a58816f05792722823d8907de36c8b08e2ffb134 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:52:27 +0000 Subject: Formerly sizes.c.~21~ --- ufs/sizes.c | 134 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 50 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index a349eb40..11efc2b8 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -20,8 +20,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Michael I. Bushnell. */ #include "ufs.h" -#include "fs.h" -#include "dinode.h" #include #ifdef DONT_CACHE_MEMORY_OBJECTS @@ -30,6 +28,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAY_CACHE 1 #endif +static int free_indir (struct node *np, daddr_t bno, int level); +static void poke_pages (memory_object_t, vm_offset_t, vm_offset_t); /* Implement the diskfs_truncate callback; sse for the interface description. */ @@ -41,7 +41,10 @@ diskfs_truncate (struct node *np, daddr_t lastiblock[NIADDR], lastblock, bn; struct dinode *di = dino (np->dn->number); int blocksfreed = 0; - + error_t err; + int level; + int i; + if (length >= np->dn_stat.st_size) return 0; @@ -72,13 +75,14 @@ diskfs_truncate (struct node *np, int savesize = np->allocsize; np->allocsize = length; /* temporary */ - bsize = blksize (sblock, np, lbkno (sblock, length)); + bsize = blksize (sblock, np, lblkno (sblock, length)); np->allocsize = savesize; - diskfs_node_rdwr (np, zeroblock, length, bsize - offset, 1, 0, 0); + diskfs_node_rdwr (np, (void *) zeroblock, length, + bsize - offset, 1, 0, 0); diskfs_file_update (np, 1); } - rwlock_writer_lock (&np->allocptrlock); + rwlock_writer_lock (&np->dn->allocptrlock); /* Now flush all the data past the new size from the kernel. Also force any delayed copies of this data to take place @@ -87,6 +91,8 @@ diskfs_truncate (struct node *np, this forces us to help out the kernel thusly.) */ if (np->dn->fileinfo) { + mach_port_t obj; + pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np); @@ -94,23 +100,20 @@ diskfs_truncate (struct node *np, MACH_MSG_TYPE_MAKE_SEND); poke_pages (obj, round_page (length), round_page (np->allocsize)); mach_port_deallocate (mach_task_self (), obj); - pager_flush_some (np->fileinfo->p, round_page (length), + pager_flush_some (np->dn->fileinfo->p, round_page (length), np->allocsize - length, 1); } /* Calculate index into node's block list of direct and indirect blocks which we want to keep. Lastblock is -1 when the file is truncated to 0. */ - lastblock = lblkno (sblock, length + sblock->fs_bsize - 1) - 1; + lastblock = lblkno (sblock, length - 1); lastiblock[INDIR_SINGLE] = lastblock - NDADDR; lastiblock[INDIR_DOUBLE] = lastiblock[INDIR_SINGLE] - NINDIR (sblock); lastiblock[INDIR_TRIPLE] = (lastiblock[INDIR_DOUBLE] - NINDIR (sblock) * NINDIR (sblock)); - /* Normalize to -1 indicating that this block will not be needed. */ - for (level = INDIR_TRIPLE; level >= INDIR_SINGLE; level--) - if (lastiblock[level] < 0) - lastiblock[level] = -1; + /* lastiblock will now be negative for elements that we should free. */ /* Update the size on disk; fsck will finish freeing blocks if necessary should we crash. */ @@ -124,13 +127,13 @@ diskfs_truncate (struct node *np, err = diskfs_catch_exception (); if (err) { - rwlock_writer_unlock (&np->allocptrlock); + rwlock_writer_unlock (&np->dn->allocptrlock); return err; } /* Indirect blocks first. */ for (level = INDIR_TRIPLE; level >= INDIR_SINGLE; level--) - if (lastiblock[level] == -1 && di->di_ib[level]) + if (lastiblock[level] < 0 && di->di_ib[level]) { int count; count = free_indir (np, di->di_ib[level], level); @@ -143,27 +146,27 @@ diskfs_truncate (struct node *np, { long bsize; - bn = dn->di_db[i]; + bn = di->di_db[i]; if (bn == 0) continue; bsize = blksize (sblock, np, i); - ffs_blkfree (sblock, bn, bsize); + ffs_blkfree (np, bn, bsize); blocksfreed += btodb (bsize); - dn->di_db[i] = 0; + di->di_db[i] = 0; } /* Finally, check to see if the new last direct block is changing size; if so release any frags necessary. */ if (lastblock >= 0 - && dn->di_db[lastblock]) + && di->di_db[lastblock]) { - bn = dn->di_db[lastblock]; long oldspace, newspace; + bn = di->di_db[lastblock]; oldspace = blksize (sblock, np, lastblock); - np->allocsize = length; + np->allocsize = fragroundup (sblock, length); newspace = blksize (sblock, np, lastblock); assert (newspace); @@ -172,18 +175,18 @@ diskfs_truncate (struct node *np, { bn += numfrags (sblock, newspace); ffs_blkfree (np, bn, oldspace - newspace); - blocksfreed += btodb (oldspace - newspace) + blocksfreed += btodb (oldspace - newspace); } } else - np->allocsize = length; + np->allocsize = fragroundup (sblock, length); diskfs_end_catch_exception (); np->dn_set_ctime = 1; diskfs_node_update (np, 1); - rwlock_writer_unlock (&np->allocptrlock); + rwlock_writer_unlock (&np->dn->allocptrlock); /* Now we can permit delayed copies again. */ if (np->dn->fileinfo) @@ -202,7 +205,7 @@ free_indir (struct node *np, daddr_t bno, int level) int count = 0; daddr_t *addrs; int i; - struct indir_dirty *d, *prev, *nxt; + struct dirty_indir *d, *prev, *next; assert (bno); @@ -216,7 +219,7 @@ free_indir (struct node *np, daddr_t bno, int level) count += btodb (sblock->fs_bsize); } else - count += free_indir (addrs[i], level - 1); + count += free_indir (np, addrs[i], level - 1); } /* Subtlety: this block is no longer necessary; the information @@ -227,12 +230,12 @@ free_indir (struct node *np, daddr_t bno, int level) the block from the kernel's memory, making sure we do it synchronously--and BEFORE we attach it to the free list with ffs_blkfree. */ - pager_flush_some (diskpager->p, fsaddr (bno), sblock->fs_bsize, 1); + pager_flush_some (diskpager->p, fsaddr (sblock, bno), sblock->fs_bsize, 1); /* We should also take this block off the inode's list of dirty indirect blocks if it's there. */ prev = 0; - d = np->dirty; + d = np->dn->dirty; while (d) { next = d->next; @@ -241,7 +244,7 @@ free_indir (struct node *np, daddr_t bno, int level) if (prev) prev->next = next; else - np->dirty = next; + np->dn->dirty = next; free (d); } else @@ -292,7 +295,7 @@ diskfs_grow (struct node *np, assert (!diskfs_readonly); /* The new last block of the file. */ - lbn = lblkno (sblock, end + sblock->fs_bsize - 1) - 1; + lbn = lblkno (sblock, end - 1); /* This is the size of that block if it is in the NDADDR array. */ size = fragroundup (sblock, blkoff (sblock, end)); @@ -302,7 +305,7 @@ diskfs_grow (struct node *np, rwlock_writer_lock (&np->dn->allocptrlock); /* The old last block of the file. */ - olbn = lbkno (sblock, np->allocsize + sblock->fs_bsize - 1) - 1; + olbn = lblkno (sblock, np->allocsize - 1); /* This is the size of that block if it is in the NDADDR array. */ osize = fragroundup (sblock, blkoff (sblock, np->allocsize)); @@ -315,24 +318,24 @@ diskfs_grow (struct node *np, { if (osize < sblock->fs_bsize) { - daddr_t olb_pbn, bno; - err = ffs_realloccg (np, nb, + daddr_t old_pbn, bno; + err = ffs_realloccg (np, olbn, ffs_blkpref (np, lbn, lbn, di->di_db), osize, sblock->fs_bsize, &bno, cred); if (err) goto out; - old_pbn = di->di_db - di->di_db[nb] = bno; + old_pbn = di->di_db[olbn]; + di->di_db[olbn] = bno; np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (bno) + btodb (osize), + dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, sblock->fs_bsize - osize); - if (pbn != old_pbn) + if (bno != old_pbn) { /* Make sure the old contents get written out to the new address by poking the pages. */ - poke_off = nb * sblock->fs_bsize; + poke_off = olbn * sblock->fs_bsize; poke_len = osize; } } @@ -357,12 +360,12 @@ diskfs_grow (struct node *np, goto out; di->di_db[lbn] = bno; - np->dn_sat_ctime = 1; + np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (bno) + btodb (osize), + dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, size - osize); - if (pbn != old_pbn) + if (bno != old_pbn) { assert (!poke_len); @@ -381,17 +384,17 @@ diskfs_grow (struct node *np, if (err) goto out; - di->di_db[lbn] = pbn; + di->di_db[lbn] = bno; np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (bno), zeroblock, size); + dev_write_sync (fsbtodb (sblock, bno), zeroblock, size); } } else { - struct iblock_spec indirs[NINDIR + 1]; - int i; + struct iblock_spec indirs[NIADDR + 1]; daddr_t *siblock; + daddr_t bno; /* Count the number of levels of indirection. */ err = fetch_indir_spec (np, lbn, indirs); @@ -435,7 +438,7 @@ diskfs_grow (struct node *np, /* This assert because triple indirection is not supported. */ assert (indirs[2].offset == -1); - err = ffs_alloc (np, lbn + err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn, INDIR_DOUBLE, di->di_ib), sblock->fs_bsize, &bno, 0); @@ -446,7 +449,7 @@ diskfs_grow (struct node *np, } diblock = indir_block (indirs[2].bno); - mark_indir_dirty (indirs[2].bno); + mark_indir_dirty (np, indirs[2].bno); /* Now we can allocate the single indirect block */ err = ffs_alloc (np, lbn, @@ -466,11 +469,11 @@ diskfs_grow (struct node *np, /* Now we can allocate the data block. */ err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn, indirs[0].offset, siblock), - sblock->fn_bsize, &bno, 0); + sblock->fs_bsize, &bno, 0); if (err) goto out; indirs[0].bno = siblock[indirs[0].offset] = bno; - dev_write_sync (fsbtodb (bno), zeroblock, sblock->fs_bsize); + dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); } out: @@ -485,7 +488,7 @@ diskfs_grow (struct node *np, np->allocsize = newallocsize; } - rwlock_writer_unlock (&np->allocptrlock); + rwlock_writer_unlock (&np->dn->allocptrlock); /* If we expanded a fragment, then POKE_LEN will be set. We need to poke the requested amount of the memory object @@ -493,8 +496,10 @@ diskfs_grow (struct node *np, at a suitable time. */ if (poke_len) { + mach_port_t obj; + obj = diskfs_get_filemap (np); - mach_port_insert_reght (mach_task_self (), obj, obj, + mach_port_insert_right (mach_task_self (), obj, obj, MACH_MSG_TYPE_MAKE_SEND); poke_pages (obj, trunc_page (poke_off), round_page (poke_off + poke_len)); @@ -504,3 +509,32 @@ diskfs_grow (struct node *np, return err; } +/* Write something to each page from START to END inclusive of memory + object OBJ, but make sure the data doesns't actually change. */ +static void +poke_pages (memory_object_t obj, + vm_offset_t start, + vm_offset_t end) +{ + vm_address_t addr, poke; + vm_size_t len; + error_t err; + + while (start < end) + { + len = 8 * vm_page_size; + if (len > end - start) + len = end - start; + addr = 0; + err = vm_map (mach_task_self (), &addr, len, 0, 1, obj, start, 0, + VM_PROT_WRITE|VM_PROT_READ, VM_PROT_READ|VM_PROT_WRITE, 0); + if (!err) + { + for (poke = addr; poke < addr + len; poke += vm_page_size) + *(volatile int *)poke = *(volatile int *)poke; + vm_deallocate (mach_task_self (), addr, len); + } + start += len; + } +} + -- cgit v1.2.3 From c8ee2836ff8d5eda9d3976a9ee4ca36df19f3283 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:52:30 +0000 Subject: Formerly pager.c.~38~ --- ufs/pager.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index e4abf85d..b5a98e79 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "dinode.h" #include #include @@ -80,7 +79,7 @@ find_address (struct user_pager_info *upi, { if (indirs[0].bno) *addr = (fsbtodb (sblock, indirs[0].bno) - + blkoff (sblkoc, offset) / DEV_BSIZE); + + blkoff (sblock, offset) / DEV_BSIZE); else *addr = 0; } @@ -172,6 +171,7 @@ pager_unlock_page (struct user_pager_info *pager, struct iblock_spec indirs[NIADDR + 1]; daddr_t bno; struct disknode *dn; + struct dinode *di; /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect @@ -193,6 +193,7 @@ pager_unlock_page (struct user_pager_info *pager, np = pager->np; dn = np->dn; + di = dino (dn->number); rwlock_writer_lock (&dn->allocptrlock); @@ -276,7 +277,7 @@ pager_unlock_page (struct user_pager_info *pager, } diblock = indir_block (indirs[2].bno); - mark_indir_dirty (indirs[2].bno); + mark_indir_dirty (np, indirs[2].bno); /* Now we can allocate the single indirect block */ @@ -303,7 +304,7 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; - dev_write_sync (fsbtodb (bno), zeroblock, sblock->fs_bsize); + dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); indirs[0].bno = siblock[indirs[0].offset] = bno; } @@ -311,7 +312,7 @@ pager_unlock_page (struct user_pager_info *pager, out: diskfs_end_catch_exception (); - rwlock_writer_unlock (&np->dn->datalock, np->dn); + rwlock_writer_unlock (&dn->allocptrlock); return err; } @@ -356,8 +357,8 @@ create_disk_pager () diskpager = malloc (sizeof (struct user_pager_info)); diskpager->type = DISK; diskpager->np = 0; - diskpager->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - diskpagerport = pager_get_port (upi->p); + diskpager->p = pager_create (diskpager, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + diskpagerport = pager_get_port (diskpager->p); mach_port_insert_right (mach_task_self (), diskpagerport, diskpagerport, MACH_MSG_TYPE_MAKE_SEND); } @@ -368,7 +369,7 @@ void diskfs_file_update (struct node *np, int wait) { - struct indir_dirty *d, *tmp; + struct dirty_indir *d, *tmp; if (np->dn->fileinfo) pager_sync (np->dn->fileinfo->p, wait); @@ -406,7 +407,7 @@ diskfs_get_filemap (struct node *np) diskfs_nref_light (np); upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; - ports_port_ref (p); + ports_port_ref (upi->p); spin_lock (&pagerlistlock); upi->next = filepagerlist; @@ -417,7 +418,6 @@ diskfs_get_filemap (struct node *np) spin_unlock (&pagerlistlock); } right = pager_get_port (np->dn->fileinfo->p); - mutex_unlock (&pagernplock); mach_port_insert_right (mach_task_self (), right, right, MACH_MSG_TYPE_MAKE_SEND); @@ -465,7 +465,7 @@ pager_traverse (void (*func)(struct user_pager_info *)) struct item *i; spin_lock (&pagerlistlock); - for (p = filepagerlit; p; p = p->next) + for (p = filepagerlist; p; p = p->next) { i = alloca (sizeof (struct item)); i->next = list; -- cgit v1.2.3 From e54bb543df6526896794b97f367cdd1d4569c694 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:52:31 +0000 Subject: Formerly inode.c.~41~ --- ufs/inode.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 3edb697f..91963c16 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "dinode.h" #include #include #include @@ -156,6 +155,8 @@ void diskfs_lost_hardrefs (struct node *np) { struct port_info *pi; + struct pager *p; + /* Check and see if there is a pager which has only one reference (ours). If so, then drop that reference, breaking the cycle. The complexity in this routine @@ -164,7 +165,7 @@ diskfs_lost_hardrefs (struct node *np) if (np->dn->fileinfo) { spin_lock (&_libports_portrefcntlock); - pi = np->dn->fileinfo->p; + pi = (struct port_info *) np->dn->fileinfo->p; if (pi->refcnt == 1) { @@ -500,25 +501,26 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, error_t diskfs_get_translator (struct node *np, char **namep, u_int *namelen) { - XXX FIXME error_t err; daddr_t blkno; - char *buf; u_int datalen; + void *transloc; err = diskfs_catch_exception (); if (err) return err; + blkno = (dino (np->dn->number))->di_trans; - assert (blkno); - bcopy (disk_image + fsaddr (sblock, blkno), buf, sblock->fs_bsize); - diskfs_end_catch_exception (); + transloc = disk_image + fsaddr (sblock, blkno); - datalen = *(u_int *)buf; + datalen = *(u_int *)transloc; if (datalen > *namelen) vm_allocate (mach_task_self (), (vm_address_t *) namep, datalen, 1); - bcopy (buf + sizeof (u_int), *namep, datalen); + bcopy (transloc + sizeof (u_int), *namep, datalen); + + diskfs_end_catch_exception (); + *namelen = datalen; return 0; } -- cgit v1.2.3 From c7a908bb80c55dcdfae4f13dd945d6b95441e0c1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:52:32 +0000 Subject: entered into RCS --- ufs/consts.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/consts.c b/ufs/consts.c index 0004230f..2062a07f 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "dinode.h" int diskfs_link_max = LINK_MAX; int diskfs_maxsymlinks = 8; -- cgit v1.2.3 From ab87c35f13c27216d1e6e5c9c47afdc6a394b6e7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 02:52:34 +0000 Subject: Formerly hyper.c.~14~ --- ufs/hyper.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index a5d05bc8..e73f78b8 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -16,7 +16,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" -#include "dinode.h" #include #include -- cgit v1.2.3 From a291563796dc0e60b318dd2e7aea61e55a7320c5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 15:58:12 +0000 Subject: Formerly bmap.c.~5~ --- ufs/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index 18c53662..e43a648c 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -76,7 +76,7 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, else { indirs[1].offset = -1; - indirs[1].bno = di->di_ib[INDIR_DOUBLE]; + indirs[1].bno = di->di_ib[INDIR_SINGLE]; } if (indirs[1].bno) -- cgit v1.2.3 From c427330289e857525ac44e0f428343868bba405e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Sep 1994 19:24:51 +0000 Subject: Formerly sizes.c.~22~ --- ufs/sizes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 11efc2b8..0f0fd427 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -481,9 +481,9 @@ diskfs_grow (struct node *np, { int newallocsize; if (lbn < NDADDR) - newallocsize = (lbn - 1) * sblock->fs_bsize + size; + newallocsize = lbn * sblock->fs_bsize + size; else - newallocsize = lbn * sblock->fs_bsize; + newallocsize = (lbn + 1) * sblock->fs_bsize; assert (newallocsize > np->allocsize); np->allocsize = newallocsize; } -- cgit v1.2.3 From 0ee74b5b66d79eba411f8fc57545a1140b0bd799 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 29 Sep 1994 22:17:57 +0000 Subject: Formerly main.c.~23~ --- ufs/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 5f41265b..65da85bb 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -23,6 +23,7 @@ #include #include #include +#include char *ufs_version = "0.0 pre-alpha"; @@ -102,10 +103,10 @@ main (int argc, char **argv) mutex_init (&printf_lock); /* XXX */ - task_get_bootstrap_port (mach_task_self (), &bootstrap); - - if (bootstrap) + if (getpid () > 0) { + /* We are in a normal Hurd universe, started as a translator. */ + devname = trans_parse_args (argc, argv); { @@ -120,10 +121,13 @@ main (int argc, char **argv) } else { + /* We are the bootstrap filesystem. */ devname = diskfs_parse_bootargs (argc, argv); compat_mode = COMPAT_GNU; } + task_get_bootstrap_port (mach_task_self (), &bootstrap); + /* Initialize the diskfs library. This must come before any other diskfs call. */ diskfs_init_diskfs (); -- cgit v1.2.3 From 661267c4ad4f5724340d5167d2b25f3e26547fb3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 30 Sep 1994 15:25:32 +0000 Subject: Formerly dir.c.~29~ --- ufs/dir.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index e4d54cdf..2f215974 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -858,9 +858,7 @@ diskfs_get_directs (struct node *dp, userp->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); userp->d_namlen = DIRECT_NAMLEN (entryp); bcopy (entryp->d_name, userp->d_name, DIRECT_NAMLEN (entryp) + 1); -#ifdef notyet - userp->d_type = entryp->d_type; -#endif + userp->d_type = DT_UNKNOWN; /* until fixed */ i++; datap += DIRSIZ (DIRECT_NAMLEN (entryp)); } -- cgit v1.2.3 From 02e17dd72bc35481855708a6184d083aa324129a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 30 Sep 1994 15:27:08 +0000 Subject: entered into RCS --- ufs/dir.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ufs/dir.h b/ufs/dir.h index c6535342..193e167b 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -83,24 +83,6 @@ struct directory_entry { char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */ }; -/* - * File types - */ -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 - -/* - * Convert between stat structure types and directory types. - */ -#define IFTODT(mode) (((mode) & 0170000) >> 12) -#define DTTOIF(dirtype) ((dirtype) << 12) - /* Return the type from a struct directory_entry, paying attention to whether this filesystem supports the type extension */ #define DIRECT_TYPE(dp) (direct_symlink_extension ? (dp)->d_type : DT_UNKNOWN) -- cgit v1.2.3 From aaf97f45a58d426809c0d289a88155a57bf57879 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 Oct 1994 01:29:06 +0000 Subject: Formerly Makefile.~7~ --- bsdfsck/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index e40ceb67..bc718b66 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -22,6 +22,7 @@ SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c # preen.c OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ pass5.o setup.o utilities.o tables.o # preen.o +LCLHDRS = fsck.h target = fsck include ../Makeconf -- cgit v1.2.3 From 8ed965f0767037b11167315ae43c879061d55d4b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 18:51:49 +0000 Subject: Initial revision --- ufs/mapbuf.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ufs/mapbuf.c diff --git a/ufs/mapbuf.c b/ufs/mapbuf.c new file mode 100644 index 00000000..a323bdbc --- /dev/null +++ b/ufs/mapbuf.c @@ -0,0 +1,33 @@ +/* Cache mappings of the disk + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +#include "ufs.h" + +#define MAXMAPMEM (1024 * 1024 * 1024) /* one Gb */ + +struct mapbuf +{ + vm_size_t length; + vm_offset_t diskaddr; +}; + +void * +map_region -- cgit v1.2.3 From 05a19cf1799badd6446ac0524c649b5572f2f349 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 18:54:58 +0000 Subject: entered into RCS --- ufs/mapbuf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ufs/mapbuf.c b/ufs/mapbuf.c index a323bdbc..edf432a5 100644 --- a/ufs/mapbuf.c +++ b/ufs/mapbuf.c @@ -21,13 +21,16 @@ #include "ufs.h" -#define MAXMAPMEM (1024 * 1024 * 1024) /* one Gb */ +struct mapbuf *mblist; +spin_lock_t mblistlock = SPIN_LOCK_INITIALIZER; -struct mapbuf +struct mapbuf * +map_region (vm_offset_t diskloc, vm_size_t length) { - vm_size_t length; - vm_offset_t diskaddr; -}; + struct mapbuf *mb; + + /* Check to see if we are already mapping this region */ + spin_lock (&mblistlock); + for (mb = mblist; mb; mb = mb->next) + { -void * -map_region -- cgit v1.2.3 From d97f48fc688d937e7f2ae68098789dbb7d9256bf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 19:03:08 +0000 Subject: Initial revision --- ufs/pokeloc.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ufs/pokeloc.c diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c new file mode 100644 index 00000000..bf3c9add --- /dev/null +++ b/ufs/pokeloc.c @@ -0,0 +1,63 @@ +/* Remember where we've written the disk to speed up sync + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +#include "ufs.h" + +struct pokeloc +{ + vm_offset_t offset; + vm_size_t length; + struct pokeloc *next; +}; + +struct pokeloc *pokelist; +spin_lock_t pokelistlock = SPIN_LOCK_INITIAILIZER; + +/* Remember that data here on the disk has been modified. */ +void +record_poke (vm_offset_t offset, vm_size_t length) +{ + struct pokeloc *pl = malloc (sizeof (struct pokeloc)); + pl->offset = trunc_page (offset); + pl->length = round_page (offset + length) - pl->offset; + + spin_lock (&pokelistlock); + pl->next = pokelist; + pokelist = pl; + spin_unlock (&pokelistlock); +} + +/* Sync all the modified pieces of disk */ +void +sync_disk (int wait) +{ + struct pokeloc *pl, *tmp; + + spin_lock (&pokelistlock); + for (pl = pokelist; pl; pl = tmp) + { + pager_sync_some (diskpager->p, pl->offset, pl->length, wait); + tmp = pl->next; + free (pl); + } + pokelist = 0; + spin_unlock (&pokelistlock); +} + -- cgit v1.2.3 From 8af736c549ec9d5eb69487f41222950d6f366193 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 19:06:29 +0000 Subject: Formerly pokeloc.c.~2~ --- ufs/pokeloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c index bf3c9add..cc1f364c 100644 --- a/ufs/pokeloc.c +++ b/ufs/pokeloc.c @@ -32,9 +32,12 @@ spin_lock_t pokelistlock = SPIN_LOCK_INITIAILIZER; /* Remember that data here on the disk has been modified. */ void -record_poke (vm_offset_t offset, vm_size_t length) +record_poke (void *loc, vm_size_t length) { struct pokeloc *pl = malloc (sizeof (struct pokeloc)); + vm_offset_t offset; + + offset = loc - disk_image; pl->offset = trunc_page (offset); pl->length = round_page (offset + length) - pl->offset; -- cgit v1.2.3 From 0ae2901ce73d17da45be0af289dc4b50b0d207e8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 19:06:38 +0000 Subject: Formerly ufs.h.~27~ --- ufs/ufs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index 6d706100..20f67203 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -292,3 +292,7 @@ void ffs_clrblock(struct fs *, u_char *, daddr_t); void ffs_setblock (struct fs *, u_char *, daddr_t); int skpc (int, int, char *); int scanc (u_int, u_char *, u_char [], int); + +/* From pokeloc.c: */ +void record_poke (void *, vm_size_t); +void sync_disk (int); -- cgit v1.2.3 From 820bedd006fb925b4043f60b5809e9441e79031b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 19:09:11 +0000 Subject: Formerly inode.c.~42~ --- ufs/inode.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 91963c16..ba720b48 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -333,6 +333,7 @@ write_node (struct node *np) diskfs_end_catch_exception (); np->dn_stat_dirty = 0; + record_poke (di, sizeof (struct dinode)); } } @@ -344,6 +345,7 @@ create_symlink_hook (struct node *np, char *target) { int len = strlen (target); error_t err; + struct dinode *di; if (!direct_symlink_extension) return EINVAL; @@ -357,10 +359,12 @@ create_symlink_hook (struct node *np, char *target) if (err) return err; - bcopy (target, (dino (np->dn->number))->di_shortlink, len); + di = dino (np->dn->number); + bcopy (target, di->di_shortlink, len); np->dn_stat.st_size = len; np->dn_set_ctime = 1; np->dn_set_mtime = 1; + record_poke (di, sizeof (struct dinode)); diskfs_end_catch_exception (); return 0; @@ -446,7 +450,8 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, daddr_t blkno; error_t err; char buf[sblock->fs_bsize]; - + struct dinode *di; + if (compat_mode != COMPAT_GNU) return EOPNOTSUPP; @@ -457,7 +462,8 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, if (err) return err; - blkno = (dino (np->dn->number))->di_trans; + di = dino (np->dn->number); + blkno = di->di_trans; if (namelen && !blkno) { @@ -468,14 +474,16 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, diskfs_end_catch_exception (); return err; } - (dino (np->dn->number))->di_trans = blkno; + di->di_trans = blkno; + record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; } else if (!namelen && blkno) { /* Clear block for translator going away. */ ffs_blkfree (np, blkno, sblock->fs_bsize); - (dino (np->dn->number))->di_trans = 0; + di->di_trans = 0; + record_poke (di, sizeof (struct dinode)); np->istranslated = 0; np->dn_set_ctime = 1; } -- cgit v1.2.3 From e7c7fde09edf3a831daedd42afab061502b59871 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 21:15:48 +0000 Subject: entered into RCS --- ufs/bmap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index e43a648c..0b3574b8 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -35,10 +35,18 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, if (err = diskfs_catch_exception ()) return err; + indirs[0].offset = -2; + indirs[1].offset = -2; + indirs[2].offset = -2; + indirs[3].offset = -2; + if (lbn < NDADDR) { - indirs[0].bno = di->di_db[lbn]; - indirs[0].offset = -1; + if (lbn >= 0) + { + indirs[0].bno = di->di_db[lbn]; + indirs[0].offset = -1; + } diskfs_end_catch_exception (); return 0; -- cgit v1.2.3 From b6bff823d8d4504af1ec6521e6a25f752ecc8fdf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 3 Oct 1994 21:18:00 +0000 Subject: Formerly sizes.c.~23~ --- ufs/sizes.c | 181 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 55 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 0f0fd427..8f6174af 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -28,7 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAY_CACHE 1 #endif -static int free_indir (struct node *np, daddr_t bno, int level); +static int indir_release (struct node *np, daddr_t bno, int level); static void poke_pages (memory_object_t, vm_offset_t, vm_offset_t); /* Implement the diskfs_truncate callback; sse for the @@ -38,12 +38,12 @@ diskfs_truncate (struct node *np, off_t length) { int offset; - daddr_t lastiblock[NIADDR], lastblock, bn; struct dinode *di = dino (np->dn->number); int blocksfreed = 0; error_t err; - int level; int i; + struct iblock_spec indirs[NIADDR + 1]; + daddr_t lbn; if (length >= np->dn_stat.st_size) return 0; @@ -104,17 +104,6 @@ diskfs_truncate (struct node *np, np->allocsize - length, 1); } - /* Calculate index into node's block list of direct - and indirect blocks which we want to keep. Lastblock - is -1 when the file is truncated to 0. */ - lastblock = lblkno (sblock, length - 1); - lastiblock[INDIR_SINGLE] = lastblock - NDADDR; - lastiblock[INDIR_DOUBLE] = lastiblock[INDIR_SINGLE] - NINDIR (sblock); - lastiblock[INDIR_TRIPLE] = (lastiblock[INDIR_DOUBLE] - - NINDIR (sblock) * NINDIR (sblock)); - - /* lastiblock will now be negative for elements that we should free. */ - /* Update the size on disk; fsck will finish freeing blocks if necessary should we crash. */ np->dn_stat.st_size = length; @@ -122,52 +111,98 @@ diskfs_truncate (struct node *np, np->dn_set_ctime = 1; diskfs_node_update (np, 1); - /* Free the blocks. */ + /* Find out the location information for the last block to + be retained */ + lbn = lblkno (sblock, length - 1); + err = fetch_indir_spec (np, lbn, indirs); + /* err XXX */ + + /* We don't support triple indirs */ + assert (indirs[0].offset == -1 + || indirs[1].offset == -1 + || indirs[2].offset == -1); + + /* BSD carefully finds out how far to clear; it's vastly simpler + to just clear everything after the new last block. */ - err = diskfs_catch_exception (); - if (err) + /* Free direct blocks */ + if (indirs[0].offset < 0) { - rwlock_writer_unlock (&np->dn->allocptrlock); - return err; + /* ...mapped from the inode. */ + for (i = lbn + 1; i < NDADDR; i++) + if (di->di_db[i]) + { + long bsize = blksize (sblock, np, i); + ffs_blkfree (np, di->di_db[i], bsize); + di->di_db[i] = 0; + blocksfreed += btodb (bsize); + } } - - /* Indirect blocks first. */ - for (level = INDIR_TRIPLE; level >= INDIR_SINGLE; level--) - if (lastiblock[level] < 0 && di->di_ib[level]) - { - int count; - count = free_indir (np, di->di_ib[level], level); - blocksfreed += count; - di->di_ib[level] = 0; - } - - /* Whole direct blocks or frags */ - for (i = NDADDR - 1; i > lastblock; i--) + else { - long bsize; - - bn = di->di_db[i]; - if (bn == 0) - continue; - - bsize = blksize (sblock, np, i); - ffs_blkfree (np, bn, bsize); - blocksfreed += btodb (bsize); - - di->di_db[i] = 0; + /* ... or mapped from sindir */ + if (indirs[1].bno) + { + daddr_t *sindir = indir_block (indirs[1].bno); + for (i = indirs[0].offset + 1; i < NINDIR (sblock); i++) + { + ffs_blkfree (np, sindir[i], sblock->fs_bsize); + sindir[i] = 0; + blocksfreed += btodb (sblock->fs_bsize); + } + record_poke (sindir, sblock->fs_bsize); + } } - + + /* Free single indirect blocks */ + if (indirs[1].offset < 0) + { + /* ...mapped from the inode */ + if (di->di_ib[INDIR_SINGLE] && indirs[1].offset == -2) + { + blocksfreed += indir_release (np, di->di_ib[INDIR_SINGLE], + INDIR_SINGLE); + di->di_ib[INDIR_SINGLE] = 0; + } + } + else + { + /* ...or mapped from dindir */ + if (indirs[2].bno) + { + daddr_t *dindir = indir_block (indirs[2].bno); + for (i = indirs[1].offset + 1; i < NINDIR (sblock); i++) + { + blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); + dindir[i] = 0; + } + record_poke (dindir, sblock->fs_bsize); + } + } + + /* Free double indirect block */ + assert (indirs[2].offset < 0); /* which must be mapped from the inode */ + if (indirs[2].offset == -2) + { + if (di->di_ib[INDIR_DOUBLE]) + { + blocksfreed += indir_release (np, di->di_ib[INDIR_DOUBLE], + INDIR_DOUBLE); + di->di_ib[INDIR_DOUBLE] = 0; + } + } + /* Finally, check to see if the new last direct block is changing size; if so release any frags necessary. */ - if (lastblock >= 0 - && di->di_db[lastblock]) + if (lbn >= 0 && lbn < NDADDR && di->di_db[lbn]) { long oldspace, newspace; + daddr_t bn; - bn = di->di_db[lastblock]; - oldspace = blksize (sblock, np, lastblock); + bn = di->di_db[lbn]; + oldspace = blksize (sblock, np, lbn); np->allocsize = fragroundup (sblock, length); - newspace = blksize (sblock, np, lastblock); + newspace = blksize (sblock, np, lbn); assert (newspace); @@ -179,28 +214,56 @@ diskfs_truncate (struct node *np, } } else - np->allocsize = fragroundup (sblock, length); - - diskfs_end_catch_exception (); + { + if (lbn > NDADDR) + np->allocsize = blkroundup (sblock, length); + else + np->allocsize = fragroundup (sblock, length); + } + + record_poke (di, sizeof (struct dinode)); + np->dn_stat.st_blocks -= blocksfreed; np->dn_set_ctime = 1; diskfs_node_update (np, 1); rwlock_writer_unlock (&np->dn->allocptrlock); + /* At this point the last block (as defined by np->allocsize) + might not be allocated. We need to allocate it to maintain + the rule that the last block of a file is always allocated. */ + + if (np->allocsize && indirs[0].bno == 0) + { + /* The strategy is to reduce LBN until we get one that's allocated; + then reduce allocsize accordingly, then call diskfs_grow. */ + + do + err = fetch_indir_spec (np, --lbn, indirs); + /* err XXX */ + while (indirs[0].bno == 0 && lbn >= 0); + + assert ((lbn + 1) * sblock->fs_bsize < np->allocsize); + np->allocsize = (lbn + 1) * sblock->fs_bsize; + + diskfs_grow (np, length, 0); + } + + diskfs_end_catch_exception (); + /* Now we can permit delayed copies again. */ if (np->dn->fileinfo) pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY, 0); - return 0; + return err; } /* Free indirect block BNO of level LEVEL; recursing if necessary to free other indirect blocks. Return the number of disk blocks freed. */ static int -free_indir (struct node *np, daddr_t bno, int level) +indir_release (struct node *np, daddr_t bno, int level) { int count = 0; daddr_t *addrs; @@ -219,7 +282,7 @@ free_indir (struct node *np, daddr_t bno, int level) count += btodb (sblock->fs_bsize); } else - count += free_indir (np, addrs[i], level - 1); + count += indir_release (np, addrs[i], level - 1); } /* Subtlety: this block is no longer necessary; the information @@ -263,6 +326,7 @@ free_indir (struct node *np, daddr_t bno, int level) } + /* Implement the diskfs_grow callback; see for the interface description. */ @@ -326,6 +390,7 @@ diskfs_grow (struct node *np, goto out; old_pbn = di->di_db[olbn]; di->di_db[olbn] = bno; + record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), @@ -360,6 +425,7 @@ diskfs_grow (struct node *np, goto out; di->di_db[lbn] = bno; + record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), @@ -385,6 +451,7 @@ diskfs_grow (struct node *np, goto out; di->di_db[lbn] = bno; + record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; dev_write_sync (fsbtodb (sblock, bno), zeroblock, size); @@ -426,6 +493,7 @@ diskfs_grow (struct node *np, goto out; zero_disk_block (bno); indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; + record_poke (di, sizeof (struct dinode)); } else { @@ -446,6 +514,7 @@ diskfs_grow (struct node *np, goto out; zero_disk_block (bno); indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + record_poke (di, sizeof (struct dinode)); } diblock = indir_block (indirs[2].bno); @@ -460,6 +529,7 @@ diskfs_grow (struct node *np, goto out; zero_disk_block (bno); indirs[1].bno = diblock[indirs[1].offset] = bno; + record_poke (diblock, sblock->fs_bsize); } } @@ -473,6 +543,7 @@ diskfs_grow (struct node *np, if (err) goto out; indirs[0].bno = siblock[indirs[0].offset] = bno; + record_poke (siblock, sblock->fs_bsize); dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); } -- cgit v1.2.3 From cd9220f84279dd9cd0d64e7910637c73431a38be Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 04:15:39 +0000 Subject: Formerly Makefile.~36~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 941452ff..3dac8b98 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -19,7 +19,7 @@ dir := ufs makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ - sizes.c subr.c tables.c bmap.c + sizes.c subr.c tables.c bmap.c pokeloc.c OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ -- cgit v1.2.3 From 0d9a65449c21d6bc4a1dd4dbe5e5fc5eb8169bdd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 04:18:06 +0000 Subject: entered into RCS --- ufs/pokeloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c index cc1f364c..0e7235ad 100644 --- a/ufs/pokeloc.c +++ b/ufs/pokeloc.c @@ -28,7 +28,7 @@ struct pokeloc }; struct pokeloc *pokelist; -spin_lock_t pokelistlock = SPIN_LOCK_INITIAILIZER; +spin_lock_t pokelistlock = SPIN_LOCK_INITIALIZER; /* Remember that data here on the disk has been modified. */ void -- cgit v1.2.3 From 0e1359c5b9e65131dfff28f1054fc838f6fa35a8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 06:16:27 +0000 Subject: Formerly inode.c.~43~ --- ufs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index ba720b48..9321d2e8 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -154,6 +154,7 @@ diskfs_try_dropping_softrefs (struct node *np) void diskfs_lost_hardrefs (struct node *np) { +#ifdef notanymore struct port_info *pi; struct pager *p; @@ -195,6 +196,7 @@ diskfs_lost_hardrefs (struct node *np) else spin_unlock (&_libports_portrefcntlock); } +#endif } /* A new hard reference to a node has been created; it's now OK to -- cgit v1.2.3 From ba3b952dd16e913bcf611881906b0a7ee0a0a41d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 06:30:08 +0000 Subject: Formerly ufs.h.~28~ --- ufs/ufs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index 20f67203..3301e703 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -173,6 +173,8 @@ int csum_dirty; void *disk_image; +spin_lock_t node2pagelock; + spin_lock_t alloclock; spin_lock_t gennumberlock; -- cgit v1.2.3 From b2d95e7216075bc9e4caff1c70ba880801d770a2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 06:34:16 +0000 Subject: Formerly sizes.c.~24~ --- ufs/sizes.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 8f6174af..7225a851 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -39,11 +39,12 @@ diskfs_truncate (struct node *np, { int offset; struct dinode *di = dino (np->dn->number); - int blocksfreed = 0; + volatile int blocksfreed = 0; error_t err; int i; struct iblock_spec indirs[NIADDR + 1]; - daddr_t lbn; + volatile daddr_t lbn; + struct user_pager_info *upi; if (length >= np->dn_stat.st_size) return 0; @@ -89,19 +90,26 @@ diskfs_truncate (struct node *np, immediately. (We are changing the data implicitly to zeros and doing it without the kernels immediate knowledge; this forces us to help out the kernel thusly.) */ - if (np->dn->fileinfo) + spin_lock (&node2pagelock); + upi = np->dn->fileinfo; + if (upi) + pager_reference (upi->p); + spin_unlock (&node2pagelock); + + if (upi) { mach_port_t obj; - pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, + pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np); mach_port_insert_right (mach_task_self (), obj, obj, MACH_MSG_TYPE_MAKE_SEND); poke_pages (obj, round_page (length), round_page (np->allocsize)); mach_port_deallocate (mach_task_self (), obj); - pager_flush_some (np->dn->fileinfo->p, round_page (length), + pager_flush_some (upi->p, round_page (length), np->allocsize - length, 1); + pager_unreference (upi->p); } /* Update the size on disk; fsck will finish freeing blocks if necessary @@ -118,9 +126,10 @@ diskfs_truncate (struct node *np, /* err XXX */ /* We don't support triple indirs */ - assert (indirs[0].offset == -1 - || indirs[1].offset == -1 - || indirs[2].offset == -1); + assert (indirs[3].offset == -2); + + err = diskfs_catch_exception (); + /* err XXX */ /* BSD carefully finds out how far to clear; it's vastly simpler to just clear everything after the new last block. */ @@ -252,9 +261,17 @@ diskfs_truncate (struct node *np, diskfs_end_catch_exception (); /* Now we can permit delayed copies again. */ - if (np->dn->fileinfo) - pager_change_attributes (np->dn->fileinfo->p, MAY_CACHE, - MEMORY_OBJECT_COPY_DELAY, 0); + spin_lock (&node2pagelock); + upi = np->dn->fileinfo; + if (upi) + pager_reference (upi->p); + spin_unlock (&node2pagelock); + if (upi) + { + pager_change_attributes (upi->p, MAY_CACHE, + MEMORY_OBJECT_COPY_DELAY, 0); + pager_unreference (upi->p); + } return err; } -- cgit v1.2.3 From c05ba8d85217e41af0b1a5538372a493fa4da76b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 4 Oct 1994 07:29:34 +0000 Subject: Formerly pager.c.~39~ --- ufs/pager.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index b5a98e79..90e5d985 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -22,6 +22,8 @@ spin_lock_t pagerlistlock = SPIN_LOCK_INITIALIZER; struct user_pager_info *filepagerlist; +spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; + #ifdef DONT_CACHE_MEMORY_OBJECTS #define MAY_CACHE 0 #else @@ -232,6 +234,7 @@ pager_unlock_page (struct user_pager_info *pager, goto out; assert (lblkno (sblock, address) < NDADDR); indirs[0].bno = di->di_db[lblkno (sblock, address)] = bno; + record_poke (di, sizeof (struct dinode)); } else { @@ -251,6 +254,7 @@ pager_unlock_page (struct user_pager_info *pager, goto out; zero_disk_block (bno); indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; + record_poke (di, sizeof (struct dinode)); } else { @@ -274,6 +278,7 @@ pager_unlock_page (struct user_pager_info *pager, goto out; zero_disk_block (bno); indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + record_poke (di, sizeof (struct dinode)); } diblock = indir_block (indirs[2].bno); @@ -289,6 +294,7 @@ pager_unlock_page (struct user_pager_info *pager, goto out; zero_disk_block (bno); indirs[1].bno = diblock[indirs[1].offset] = bno; + record_poke (diblock, sblock->fs_bsize); } } @@ -307,6 +313,7 @@ pager_unlock_page (struct user_pager_info *pager, dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); indirs[0].bno = siblock[indirs[0].offset] = bno; + record_poke (siblock, sblock->fs_bsize); } } @@ -341,6 +348,9 @@ void pager_clear_user_data (struct user_pager_info *upi) { assert (upi->type == FILE_DATA); + spin_lock (&node2pagelock); + upi->np->dn->fileinfo = 0; + spin_unlock (&node2pagelock); diskfs_nrele_light (upi->np); *upi->prevp = upi->next; if (upi->next) @@ -370,10 +380,20 @@ diskfs_file_update (struct node *np, int wait) { struct dirty_indir *d, *tmp; - - if (np->dn->fileinfo) - pager_sync (np->dn->fileinfo->p, wait); + struct user_pager_info *upi; + spin_lock (&node2pagelock); + upi = np->dn->fileinfo; + if (upi) + pager_reference (upi->p); + spin_unlock (&node2pagelock); + + if (upi) + { + pager_sync (upi->p, wait); + pager_unreference (upi->p); + } + for (d = np->dn->dirty; d; d = tmp) { sync_disk_blocks (d->bno, sblock->fs_bsize, wait); @@ -399,6 +419,7 @@ diskfs_get_filemap (struct node *np) && (!direct_symlink_extension || np->dn_stat.st_size >= sblock->fs_maxsymlinklen))); + spin_lock (&node2pagelock); if (!np->dn->fileinfo) { upi = malloc (sizeof (struct user_pager_info)); @@ -407,7 +428,6 @@ diskfs_get_filemap (struct node *np) diskfs_nref_light (np); upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; - ports_port_ref (upi->p); spin_lock (&pagerlistlock); upi->next = filepagerlist; @@ -418,6 +438,8 @@ diskfs_get_filemap (struct node *np) spin_unlock (&pagerlistlock); } right = pager_get_port (np->dn->fileinfo->p); + spin_unlock (&node2pagelock); + mach_port_insert_right (mach_task_self (), right, right, MACH_MSG_TYPE_MAKE_SEND); @@ -429,9 +451,18 @@ diskfs_get_filemap (struct node *np) void drop_pager_softrefs (struct node *np) { - if (MAY_CACHE && np->dn->fileinfo) - pager_change_attributes (np->dn->fileinfo->p, 0, - MEMORY_OBJECT_COPY_DELAY, 0); + struct user_pager_info *upi; + + spin_lock (&node2pagelock); + upi = np->dn->fileinfo; + if (upi) + pager_reference (upi->p); + spin_unlock (&node2pagelock); + + if (MAY_CACHE && upi) + pager_change_attributes (upi->p, 0, MEMORY_OBJECT_COPY_DELAY, 0); + if (upi) + pager_unreference (upi->p); } /* Call this when we should turn on caching because it's no longer @@ -439,9 +470,18 @@ drop_pager_softrefs (struct node *np) void allow_pager_softrefs (struct node *np) { - if (MAY_CACHE && np->dn->fileinfo) - pager_change_attributes (np->dn->fileinfo->p, 1, - MEMORY_OBJECT_COPY_DELAY, 0); + struct user_pager_info *upi; + + spin_lock (&node2pagelock); + upi = np->dn->fileinfo; + if (upi) + pager_reference (upi->p); + spin_unlock (&node2pagelock); + + if (MAY_CACHE && upi) + pager_change_attributes (upi->p, 1, MEMORY_OBJECT_COPY_DELAY, 0); + if (upi) + pager_unreference (upi->p); } /* Call this to find out the struct pager * corresponding to the @@ -451,6 +491,8 @@ allow_pager_softrefs (struct node *np) struct pager * diskfs_get_filemap_pager_struct (struct node *np) { + /* This is safe because fileinfo can't be cleared; there must be + an active mapping for this to be called. */ return np->dn->fileinfo->p; } @@ -503,7 +545,10 @@ diskfs_sync_everything (int wait) { void sync_one (struct user_pager_info *p) { - pager_sync (p->p, wait); + if (p != diskpager) + pager_sync (p->p, wait); + else + sync_disk (wait); } write_all_disknodes (); -- cgit v1.2.3 From 016352f721dd20c128333af12abc4660939c59b1 Mon Sep 17 00:00:00 2001 From: Hurd Maintainers Date: Tue, 4 Oct 1994 22:46:15 +0000 Subject: Formerly pager.c.~40~ --- ufs/pager.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index 90e5d985..fd148d8d 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -117,8 +117,10 @@ pager_read_page (struct user_pager_info *pager, } else { +#if 0 printf ("Write-locked pagein Object %#x\tOffset %#x\n", pager, page); fflush (stdout); +#endif vm_allocate (mach_task_self (), buf, __vm_page_size, 1); *writelock = 1; } @@ -187,8 +189,10 @@ pager_unlock_page (struct user_pager_info *pager, /* Problem--where to get cred values for allocation here? */ +#if 0 printf ("Unlock page request, Object %#x\tOffset %#x...", pager, address); fflush (stdout); +#endif if (pager->type == DISK) return 0; @@ -216,6 +220,13 @@ pager_unlock_page (struct user_pager_info *pager, return EIO; } + err = diskfs_catch_exception (); + if (err) + { + rwlock_writer_unlock (&dn->allocptrlock); + return EIO; + } + /* See if we need a triple indirect block; fail if we do. */ assert (indirs[0].offset == -1 || indirs[1].offset == -1 -- cgit v1.2.3 From 7aea4fc19256166ffceff077399838b4562632d0 Mon Sep 17 00:00:00 2001 From: Hurd Maintainers Date: Tue, 4 Oct 1994 23:38:49 +0000 Subject: Initial revision --- ufs-utils/clri.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 ufs-utils/clri.c diff --git a/ufs-utils/clri.c b/ufs-utils/clri.c new file mode 100644 index 00000000..bebc262f --- /dev/null +++ b/ufs-utils/clri.c @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rich $alz of BBN Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; +#endif /* not lint */ + +/* Modified by Michael I. Bushnell for GNU Hurd. */ + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +int +main(argc, argv) + int argc; + char *argv[]; +{ + register struct fs *sbp; + register struct dinode *ip; + register int fd; + struct dinode ibuf[MAXBSIZE / sizeof (struct dinode)]; + long generation, bsize; + off_t offset; + int inonum; + char *fs, sblock[SBSIZE]; + + if (argc < 3) { + (void)fprintf(stderr, "usage: clri filesystem inode ...\n"); + exit(1); + } + + fs = *++argv; + + /* get the superblock. */ + if ((fd = open(fs, O_RDWR, 0)) < 0) + err(1, "%s", fs); + if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0) + err(1, "%s", fs); + if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock)) { + (void)fprintf(stderr, + "clri: %s: can't read the superblock.\n", fs); + exit(1); + } + + sbp = (struct fs *)sblock; + if (sbp->fs_magic != FS_MAGIC) { + (void)fprintf(stderr, + "clri: %s: superblock magic number 0x%x, not 0x%x.\n", + fs, sbp->fs_magic, FS_MAGIC); + exit(1); + } + bsize = sbp->fs_bsize; + + /* remaining arguments are inode numbers. */ + while (*++argv) { + /* get the inode number. */ + if ((inonum = atoi(*argv)) <= 0) { + (void)fprintf(stderr, + "clri: %s is not a valid inode number.\n", *argv); + exit(1); + } + (void)printf("clearing %d\n", inonum); + + /* read in the appropriate block. */ + offset = ino_to_fsba(sbp, inonum); /* inode to fs blk */ + offset = fsbtodb(sbp, offset); /* fs blk disk blk */ + offset *= DEV_BSIZE; /* disk blk to bytes */ + + /* seek and read the block */ + if (lseek(fd, offset, SEEK_SET) < 0) + err(1, "%s", fs); + if (read(fd, ibuf, bsize) != bsize) + err(1, "%s", fs); + + /* get the inode within the block. */ + ip = &ibuf[ino_to_fsbo(sbp, inonum)]; + + /* clear the inode, and bump the generation count. */ + generation = ip->di_gen + 1; + memset(ip, 0, sizeof(*ip)); + ip->di_gen = generation; + + /* backup and write the block */ + if (lseek(fd, (off_t)-bsize, SEEK_CUR) < 0) + err(1, "%s", fs); + if (write(fd, ibuf, bsize) != bsize) + err(1, "%s", fs); + (void)fsync(fd); + } + (void)close(fd); + exit(0); +} -- cgit v1.2.3 From f5a4f184d85db850f383d909477d8139e3fe191d Mon Sep 17 00:00:00 2001 From: Hurd Maintainers Date: Tue, 4 Oct 1994 23:44:09 +0000 Subject: entered into RCS --- ufs-utils/clri.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/ufs-utils/clri.c b/ufs-utils/clri.c index bebc262f..203073e2 100644 --- a/ufs-utils/clri.c +++ b/ufs-utils/clri.c @@ -49,10 +49,11 @@ static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; #include #include -#include -#include +#include "../ufs/dinode.h" +#include "../ufs/fs.h" + + -#include #include #include #include @@ -60,6 +61,10 @@ static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; #include #include +#define MAXPHYS (64 * 1024) +#define DEV_BSIZE 512 + + int main(argc, argv) int argc; @@ -83,9 +88,15 @@ main(argc, argv) /* get the superblock. */ if ((fd = open(fs, O_RDWR, 0)) < 0) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock)) { (void)fprintf(stderr, "clri: %s: can't read the superblock.\n", fs); @@ -118,9 +129,15 @@ main(argc, argv) /* seek and read the block */ if (lseek(fd, offset, SEEK_SET) < 0) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } if (read(fd, ibuf, bsize) != bsize) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } /* get the inode within the block. */ ip = &ibuf[ino_to_fsbo(sbp, inonum)]; @@ -132,9 +149,15 @@ main(argc, argv) /* backup and write the block */ if (lseek(fd, (off_t)-bsize, SEEK_CUR) < 0) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } if (write(fd, ibuf, bsize) != bsize) - err(1, "%s", fs); + { + perror (fs); + exit (1); + } (void)fsync(fd); } (void)close(fd); -- cgit v1.2.3 From d8c76eb62f2cdc4c191d869c574db2de3b0541dd Mon Sep 17 00:00:00 2001 From: Hurd Maintainers Date: Wed, 5 Oct 1994 02:51:16 +0000 Subject: Formerly inode.c.~5~ --- bsdfsck/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c index 6282d1d1..293b69c8 100644 --- a/bsdfsck/inode.c +++ b/bsdfsck/inode.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: inode.c,v 1.4 1994/09/01 19:15:35 mib Exp $"; +static char *rcsid = "$Id: inode.c,v 1.5 1994/10/05 02:51:16 root Exp $"; #endif /* not lint */ #include @@ -48,6 +48,9 @@ static char *rcsid = "$Id: inode.c,v 1.4 1994/09/01 19:15:35 mib Exp $"; #include #include "fsck.h" +/* Don't include dirent.h lest we get confused, but we still want this. */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) + static ino_t startinum; ckinode(dp, idesc) @@ -102,7 +105,7 @@ ckinode(dp, idesc) remsize -= sizepb; } /* GNU Hurd extension. */ - if (dino.di_trans) + if (dino.di_trans && idesc->id_type == ADDR) { idesc->id_blkno = dino.di_trans; idesc->id_numfrags = sblock.fs_frag; -- cgit v1.2.3 From 37983942de858432043318761c826d0e69ce3fe7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Oct 1994 16:53:12 +0000 Subject: entered into RCS --- bsdfsck/pass1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bsdfsck/pass1.c b/bsdfsck/pass1.c index 6f254ca8..46b0e109 100644 --- a/bsdfsck/pass1.c +++ b/bsdfsck/pass1.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)pass1.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: pass1.c,v 1.3 1994/09/01 19:19:17 mib Exp $"; +static char *rcsid = "$Id: pass1.c,v 1.4 1994/10/05 16:53:12 mib Exp $"; #endif /* not lint */ #include @@ -101,11 +101,12 @@ checkinode(inumber, idesc) dp = getnextinode(inumber); mode = DI_MODE(dp) & IFMT; if (mode == 0) { + /* Check for DI_TRANS here is a GNU Hurd addition. */ if (bcmp((char *)dp->di_db, (char *)zino.di_db, NDADDR * sizeof(daddr_t)) || bcmp((char *)dp->di_ib, (char *)zino.di_ib, NIADDR * sizeof(daddr_t)) || - DI_MODE(dp) || dp->di_size) { + DI_MODE(dp) || dp->di_size || dp->di_trans) { pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber); if (reply("CLEAR") == 1) { dp = ginode(inumber); -- cgit v1.2.3 From da152d2b61bf591ce23d89b40db10a92989159b5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Oct 1994 16:58:39 +0000 Subject: Formerly alloc.c.~18~ --- ufs/alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/alloc.c b/ufs/alloc.c index c881454b..4464dfa0 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -546,6 +546,7 @@ diskfs_alloc_node (struct node *dir, goto noinodes; error = iget (ino, &np); assert ("duplicate allocation" && !np->dn_stat.st_mode); + assert (!np->istranslated); if (np->dn_stat.st_blocks) { printf("free inode %d had %d blocks\n", ino, np->dn_stat.st_blocks); -- cgit v1.2.3 From a1630bac443f1804ccc3ad0b6e95f4fa7ad46ddf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Oct 1994 17:05:30 +0000 Subject: entered into RCS --- bsdfsck/inode.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bsdfsck/inode.c b/bsdfsck/inode.c index 293b69c8..7b48aef6 100644 --- a/bsdfsck/inode.c +++ b/bsdfsck/inode.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inode.c 8.4 (Berkeley) 4/18/94";*/ -static char *rcsid = "$Id: inode.c,v 1.5 1994/10/05 02:51:16 root Exp $"; +static char *rcsid = "$Id: inode.c,v 1.6 1994/10/05 17:05:30 mib Exp $"; #endif /* not lint */ #include @@ -48,9 +48,6 @@ static char *rcsid = "$Id: inode.c,v 1.5 1994/10/05 02:51:16 root Exp $"; #include #include "fsck.h" -/* Don't include dirent.h lest we get confused, but we still want this. */ -#define IFTODT(mode) (((mode) & 0170000) >> 12) - static ino_t startinum; ckinode(dp, idesc) -- cgit v1.2.3 From e34d53fc06cf7e40751a7a81e711860b34e65ef0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Oct 1994 17:08:23 +0000 Subject: Formerly fsck.h.~9~ --- bsdfsck/fsck.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index ea6da35a..4b95785b 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.8 1994/09/16 14:56:55 mib Exp $ + * $Id: fsck.h,v 1.9 1994/10/05 17:08:23 mib Exp $ */ /* Begin GNU Hurd */ @@ -107,6 +107,10 @@ struct odirtemplate { ? (fs)->fs_bsize \ : (fragroundup(fs, blkoff(fs, (dip)->di_size)))) +/* Don't include dirent.h lest we get confused, but we still want this. */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DT_DIR IFTODT (S_IFDIR) + /* missing macros */ /* Convert bytes to disk blocks */ -- cgit v1.2.3 From 959caac9acdd848cf120ede7b998353c430a6f8b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Oct 1994 17:09:06 +0000 Subject: entered into RCS --- bsdfsck/fsck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h index 4b95785b..c418f66c 100644 --- a/bsdfsck/fsck.h +++ b/bsdfsck/fsck.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fsck.h 8.1 (Berkeley) 6/5/93 - * $Id: fsck.h,v 1.9 1994/10/05 17:08:23 mib Exp $ + * $Id: fsck.h,v 1.10 1994/10/05 17:09:06 mib Exp $ */ /* Begin GNU Hurd */ @@ -109,7 +109,7 @@ struct odirtemplate { /* Don't include dirent.h lest we get confused, but we still want this. */ #define IFTODT(mode) (((mode) & 0170000) >> 12) -#define DT_DIR IFTODT (S_IFDIR) +#define DT_DIR IFTODT (IFDIR) /* missing macros */ -- cgit v1.2.3 From 587b384923f3968f5a96841550e9af81c91a0b21 Mon Sep 17 00:00:00 2001 From: Hurd Maintainers Date: Thu, 6 Oct 1994 02:18:38 +0000 Subject: entered into RCS --- ufs/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 9321d2e8..e5ba31c9 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -211,10 +211,10 @@ diskfs_new_hardrefs (struct node *np) static error_t read_disknode (struct node *np) { + static int fsid, fsidset; struct stat *st = &np->dn_stat; struct dinode *di = dino (np->dn->number); error_t err; - volatile long long pid = getpid (); err = diskfs_catch_exception (); if (err) @@ -222,8 +222,14 @@ read_disknode (struct node *np) np->istranslated = !! di->di_trans; + if (!fsidset) + { + fsid = getpid (); + fsidset = 1; + } + st->st_fstype = FSTYPE_UFS; - st->st_fsid = pid; + st->st_fsid = fsid; st->st_ino = np->dn->number; st->st_gen = di->di_gen; st->st_rdev = di->di_rdev; -- cgit v1.2.3 From 298e8bc3279155514666d9d80742d6fea511f434 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 6 Oct 1994 17:18:52 +0000 Subject: Formerly dir.c.~3~ --- bsdfsck/dir.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c index a97fd40c..6df56df2 100644 --- a/bsdfsck/dir.c +++ b/bsdfsck/dir.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: dir.c,v 1.2 1994/08/23 20:08:37 mib Exp $"; +static char *rcsid = "$Id: dir.c,v 1.3 1994/10/06 17:18:52 mib Exp $"; #endif /* not lint */ #include @@ -215,9 +215,16 @@ dircheck(idesc, dp) register char *cp; u_char namlen, type; int spaceleft; + spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); + if (dp->d_ino >= maxino || + dp->d_reclen == 0 || + dp->d_reclen > spaceleft || + (dp->d_reclen & 0x3) != 0) + return (0); + if (dp->d_ino == 0) + return (1); size = DIRSIZ(!newinofmt, dp); - spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); # if (BYTE_ORDER == LITTLE_ENDIAN) if (!newinofmt) { type = dp->d_namlen; @@ -230,23 +237,17 @@ dircheck(idesc, dp) namlen = dp->d_namlen; type = dp->d_type; # endif - if (dp->d_ino < maxino && - dp->d_reclen != 0 && - dp->d_reclen <= spaceleft && - (dp->d_reclen & 0x3) == 0 && - dp->d_reclen >= size && - idesc->id_filesize >= size && - namlen <= MAXNAMLEN && - type <= 15) { - if (dp->d_ino == 0) - return (1); - for (cp = dp->d_name, size = 0; size < namlen; size++) - if (*cp == 0 || (*cp++ == '/')) - return (0); - if (*cp == 0) - return (1); - } - return (0); + if (dp->d_reclen < size || + idesc->id_filesize < size || + namlen > MAXNAMLEN || + type > 15) + return (0); + for (cp = dp->d_name, size = 0; size < namlen; size++) + if (*cp == '\0' || (*cp++ == '/')) + return (0); + if (*cp != '\0') + return (0); + return (1); } direrror(ino, errmesg) -- cgit v1.2.3 From 0c57cb06c351c701818d4dcd2e45249486447672 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 7 Oct 1994 05:45:42 +0000 Subject: Formerly main.c.~24~ --- ufs/main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 65da85bb..7fcfa43b 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -27,7 +27,6 @@ char *ufs_version = "0.0 pre-alpha"; -static char **save_argv; /* Parse the arguments for ufs when started as a translator. */ char * @@ -98,8 +97,6 @@ main (int argc, char **argv) error_t err; int sizes[DEV_GET_SIZE_COUNT]; u_int sizescnt = 2; - - save_argv = argv; mutex_init (&printf_lock); /* XXX */ @@ -205,7 +202,7 @@ main (int argc, char **argv) if (bootstrap == MACH_PORT_NULL) /* We are the bootstrap filesystem; do special boot-time setup. */ - diskfs_start_bootstrap (); + diskfs_start_bootstrap (argv); /* Now become a generic request thread. */ diskfs_main_request_loop (); @@ -218,8 +215,7 @@ diskfs_init_completed () mach_port_t proc, startup; error_t err; - _hurd_proc_init (save_argv); - proc = getproc(); + proc = getproc (); proc_register_version (proc, diskfs_host_priv, "ufs", HURD_RELEASE, ufs_version); err = proc_getmsgport (proc, 1, &startup); -- cgit v1.2.3 From a0dcee19103bfaffec41dfbf93ca63afae8b4ca3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 19:23:43 +0000 Subject: Initial revision --- ufs-fsck/pass1.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 ufs-fsck/pass1.c diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c new file mode 100644 index 00000000..650af963 --- /dev/null +++ b/ufs-fsck/pass1.c @@ -0,0 +1,95 @@ +/* Pass one of GNU fsck + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + + +#include "fsck.h" + +/* Find all the blocks in use by files and filesystem reserved blocks. + Set them in the global block map. For each file, if a block is found + allocated twice, then record the block and inode in DUPLIST. + Set ISTATE to be USTATE, FSTATE, or DSTATE as appropriate */ +pass1 () +{ + ino_t number; /* inode number */ + ino_t i; /* cg-relative inode number */ + int cg; /* cylinder group number */ + + /* Account for blocks used by meta data */ + for (cg = 0, cg < sblock.fs_ncg; cg++) + { + daddr_t firstdata, firstcgblock, bno; + + /* Each cylinder group past the first reserves data + from its cylinder group copy to (but not including) + the first datablock. + + The first, however, reserves from the very front of the + cylinder group (thus including the boot block), and it also + reserves the data blocks holding the csum information. */ + firstdata = cgdmin (&sblock, cg); + if (cg == 0) + { + firstcgblock = cgbase (&sblock, cg); + firstdata += howmany (sblock.fs_cssize, sblock.fs_fsize); + } + else + firstdata = cgsblock (&sblock, cg); + + /* Mark the blocks set */ + for (bno = firstcgblock; bno < firstdata; bno++) + set_block_used (bno): + } + + /* Loop through each inode, doing initial checks */ + for (number = 0, cg = 0; cg < sblock.fs_ncg; cg++) + for (i = 0; i < sblock.fs_ipg; i++, number++) + { + struct dinode *dp; + mode_t mode; + + dp = getinode (number); + mode = DI_MODE (dp) & IFMT; + + /* If the node is not allocated, then make sure it's + properly clear */ + if (mode == 0) + { + if (bcmp (dp->di_db, zino.di_db, NDADDR * sizeof (daddr_t)) + || bcmp (dp->di_ib, zino->di_ix, NIADDR * sizeof (daddr_t)) + || dp->di_trans + || DI_MODE (dp) + || dp->di_size) + { + pwarn ("PARTIALLY ALLOCATED INODE I=%lu", number); + if (preen || reply ("CLEAR")) + { + if (preen) + printf (" (CLEARED)\n"); + clear_inode (dp); + } + + + + + + + + -- cgit v1.2.3 From febb6021270a894f18c12f01f92948ecc8d46852 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 21:48:51 +0000 Subject: Initial revision --- ufs-fsck/fsck.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ufs-fsck/fsck.h diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h new file mode 100644 index 00000000..1f8240f4 --- /dev/null +++ b/ufs-fsck/fsck.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +/* Type of an inode */ +enum inodetype +{ + UNALLOC, /* not allocated */ + FILE, /* allocated, not dir */ + DIR, /* dir */ + BADDIR, /* dir with bad block pointers */ +}; + +/* State of each inode */ +enum inodetype *inodestate; + +/* Number of links claimed by each inode */ +nlink_t *linkcount; + +/* DT_foo type of each inode */ +char *typemap; + + -- cgit v1.2.3 From 90e605e177f82d4dfe184aed75bf4c96f6d78538 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 21:59:44 +0000 Subject: Initial revision --- ufs-fsck/pass1b.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 ufs-fsck/pass1b.c diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c new file mode 100644 index 00000000..c259a6ad --- /dev/null +++ b/ufs-fsck/pass1b.c @@ -0,0 +1,77 @@ +/* Pass 1b of fsck + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +pass1b () +{ + struct dinode dino; + struct dinode *dp = &dino; + int cg, i; + ino_t number; + int dupblk; + + /* Check each block of file DP; if the block is in the dup block + list then add it to the dup block list under this file. + Return RET_GOOD or RET_BAD if the block is + good or bad, respectively. */ + int + checkblock (daddr_t bno, int nfrags) + { + struct dups *dlp; + + for (nfrags; nfrags > 0; bno++, nfrags--) + { + if (chkrange (blkno, 1)) + return RET_BAD; + for (dlp = duphead; dlp; dlp = dlp->next) + { + if (dlp->dup == blkno) + { + if (!dupblk) + printf ("I=%lu HAD DUPLICATE BLOCKS\n", number); + dupblk = 1; + printf ("DUPLICATE BLOCK %d\n", bno); + dlp->dup = duphead->dup; + duphead->dup = blkno; + duphead = duphead->next; + } + if (dlp == muldup) + break; + } + if (muldup == 0 || duphead == muldup->next) + return RET_BAD; + } + return RET_GOOD; + } + + /* Call CHECKBLOCK for each block of each node, to see if it holds + a block already found to be a duplicate. */ + for (cg = 0; cg < sblock.fs_ncg; cg++) + for (i = 0; i < sblock.fs_ipg; i++, number++) + { + if (number < ROOTINO) + continue; + if (statemap[inumber] != UNALLOC) + { + getinode (number, dp); + dupblk = 0; + allblock_iterate (dp, checkblock); + } + } +} -- cgit v1.2.3 From 71ab3f0a3ae2534aa8233f966b3ec6e7c5b56b58 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 22:04:42 +0000 Subject: Formerly pass1b.c.~2~ --- ufs-fsck/pass1b.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index c259a6ad..0eaf6198 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -1,4 +1,4 @@ -/* Pass 1b of fsck +/* Pass 1b of fsck -- scan inodes for references to duplicate blocks Copyright (C) 1994 Free Software Foundation, Inc. Written by Michael I. Bushnell. @@ -25,6 +25,7 @@ pass1b () int cg, i; ino_t number; int dupblk; + struct dups *duphead = duplist; /* Check each block of file DP; if the block is in the dup block list then add it to the dup block list under this file. @@ -34,6 +35,7 @@ pass1b () checkblock (daddr_t bno, int nfrags) { struct dups *dlp; + int hadbad = 0; for (nfrags; nfrags > 0; bno++, nfrags--) { @@ -45,19 +47,18 @@ pass1b () { if (!dupblk) printf ("I=%lu HAD DUPLICATE BLOCKS\n", number); - dupblk = 1; + dupblk++; printf ("DUPLICATE BLOCK %d\n", bno); dlp->dup = duphead->dup; duphead->dup = blkno; duphead = duphead->next; + hadbad = 1; } if (dlp == muldup) break; } - if (muldup == 0 || duphead == muldup->next) - return RET_BAD; } - return RET_GOOD; + return hadbad ? RET_BAD : RET_GOOD; } /* Call CHECKBLOCK for each block of each node, to see if it holds @@ -72,6 +73,16 @@ pass1b () getinode (number, dp); dupblk = 0; allblock_iterate (dp, checkblock); + if (dupblk) + { + printf ("I=%ld has %d DUPLICATE BLOCKS\n", number, dupblk); + if (reply ("CLEAR")) + { + clear_inode (number, dp); + inode_state[number] = UNALLOC; + } + else if (inodestate[number] == DIR) + inodestate[number] = BADDIR; } } } -- cgit v1.2.3 From 99bb188fa15c864cba17259dd68899d999d86f11 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 22:39:19 +0000 Subject: Initial revision --- ufs-fsck/pass2.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 ufs-fsck/pass2.c diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c new file mode 100644 index 00000000..cb874712 --- /dev/null +++ b/ufs-fsck/pass2.c @@ -0,0 +1,66 @@ +/* Pass 2 of GNU fsck -- examine all directories for validity + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +/* Verify root inode's basic validity; then traverse all directories + starting at root and mark those we find in inodetype with DIR_REF. */ +pass2 () +{ + switch (statemap [ROOTINO]) + { + default: + errexit ("BAD STATE %d FOR ROOT INODE", statemap [ROOTINO]); + + case DIR: + break; + + case UNALLOC: + pfatal ("ROOT INODE UNALLOCATED"); + if (!reply ("ALLOCATE")) + errexit (""); + if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit ("CANNOT ALLOCATE ROOT INODE\n"); + break; + + case FILE: + pfatal ("ROOT INODE NOT DIRECTORY"); + if (reply ("REALLOCATE")) + freeino (ROOTINO); + if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit ("CANNOT ALLOCATE ROOT INODE\n"); + break; + + case BADDIR: + pfatal ("DUPLICATE or BAD BLOCKS IN ROOT INODE"); + if (reply ("REALLOCATE")) + { + freeino (ROOINO); + if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) + errexit ("CANNOT ALLOCATE ROOT INODE\n"); + } + if (reply ("CONTINUE") == 0) + errexit (""); + break; + } + + statemap[ROOTINO] != DIR_REF; + + + -- cgit v1.2.3 From 69b39a91e22d45f2a12e62860501d8f0416ddd93 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 22:55:00 +0000 Subject: Initial revision --- ufs-fsck/dir.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ufs-fsck/dir.c diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c new file mode 100644 index 00000000..4259aa39 --- /dev/null +++ b/ufs-fsck/dir.c @@ -0,0 +1,65 @@ +/* Directory management subroutines + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + + +/* This routine is used in pass 1 to initialize DIRARRAY and DIRSORTED. + Copy information from DP (for number NUMBER) into a newly allocated + dirinfo structure and add it to the arrays. */ +record_directory (struct dinode *dp, ino_t number) +{ + u_int blks; + struct dirinfo *dnp; + + blks = howmany (dp->di_size, sblock.fs_bsize); + if (blks > NDADDR) + blks = NDADDR * NIADDR; + blks *= sizeof (daddr_t); + dnp = malloc (sizeof (struct dirinfo) + blks); + + dnp->i_number = number; + dnp->i_parent = dnp->i_dotdot = 0; + dnp->i_isize = dnp->di_size; + dnp->i_numblks = blks * sizeof (daddr_t); + bcopy (dp->di_db, dnp->i_blks, blks); + + if (dirarrayused == dirarraysize) + { + if (dirarraysize == 0) + { + dirarraysize = 100; + dirarray = malloc (dirarraysize * sizeof (struct dirinfo *)); + dirsorted = malloc (dirarraysize * sizeof (struct dirinfo *)); + } + else + { + dirarraysize *= 2; + dirarray = realloc (dirarray, + dirarraysize * sizeof (struct dirinfo *)); + dirsorted = realloc (dirsorted, + dirarraysize * sizeof (struct dirinfo *)); + } + } + dirarray[dirarrayused] = dnp; + dirsorted[dirarrayused] = dnp; + dirarrayused++; +} + + -- cgit v1.2.3 From 2dc977771d5176176323cb92e82cef26b783513b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 22:56:49 +0000 Subject: Formerly pass1.c.~2~ --- ufs-fsck/pass1.c | 367 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 352 insertions(+), 15 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 650af963..a59657fc 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -1,4 +1,4 @@ -/* Pass one of GNU fsck +/* Pass one of GNU fsck -- count blocks and verify inodes Copyright (C) 1994 Free Software Foundation, Inc. Written by Michael I. Bushnell. @@ -25,12 +25,108 @@ /* Find all the blocks in use by files and filesystem reserved blocks. Set them in the global block map. For each file, if a block is found allocated twice, then record the block and inode in DUPLIST. - Set ISTATE to be USTATE, FSTATE, or DSTATE as appropriate */ + Initialize INODESTATE, LINKCOUNT, and TYPEMAP. */ pass1 () { - ino_t number; /* inode number */ - ino_t i; /* cg-relative inode number */ - int cg; /* cylinder group number */ + ino_t number; + ino_t i; + int cg; + struct dinode dino; + struct dinode *dp = &dino; + mode_t mode, type; + int ndb; + int holdallblocks; + int lbn; + int nblocks; + int blkerror; + int nblkrngerrors; + int nblkduperrors; + + /* This function is called for each block of DP. Check to see + if the block number is valid. If so, set the entry in the + block map. If the block map entry is already set, then keep + track of this block and see if the user wants to clear the + node. Increment NBLOCKS by the number of data blocks held. + Set BLKERROR if this block is invalid. + Return RET_GOOD, RET_BAD, RET_STOP if the block is good, + bad, or if we should entirely stop checking blocks in this + inode. */ + int + checkblock (daddr_t bno, int nfrags) + { +#define MAXBAD 10 + int outofrange; + struct dups *dlp, *new; + int wasbad = 0; + + /* Check to see if this block is in range */ + if (outofrange = check_range (bno, nfrags)) + { + blkerror = 1; + wasbad = 1; + if (nblkrngerrors == 0) + printf ("I=%lu HAS BAD BLOCKS\n"); + if (nblkrngerrors++ > MAXBAD) + { + pwarn ("EXCESSIVE BAD BLKS I=%lu", number); + if (preen || reply ("SKIP")) + { + if (preen) + printf (" (SKIPPING)\n"); + return RET_STOP; + } + } + } + + for (; nfrags > 0; bno++, nfrags--) + { + if (outofrange && check_range (bno, 1)) + printf ("BAD BLOCK %d\n", bno); + else + { + if (!testbmap (bno)) + setbmap (bno); + else + { + blkerror = 1; + if (nblkduperrors == 0) + printf ("I=%lu HAS DUPLICATE BLOCKS\n"); + printf ("DUPLICATE BLOCK %d\n", bno); + wasbad = 1; + if (nblkduperrors++ > MAXBAD) + { + pwarn ("EXCESSIVE DUP BLKS I=%lu", number); + if (preen || reply ("SKIP")) + { + if (preen) + printf (" (SKIPPING)\n"); + return RET_STOP; + } + } + new = malloc (sizeof (struct dups)); + new->dup = blkno; + if (muldup == 0) + { + duplist = muldup = new; + new->next = 0; + } + else + { + new->next = muldup->next; + muldup->next = new; + } + for (dlp = duplist; dlp != muldup; dlp = dlp->next) + if (dlp->dup == blkno) + break; + if (dlp == muldup && dlp->dup != blkno) + muldup = new; + } + } + nblocks += btodb (sblock->fs_fsize); + } + return wasbad ? RET_BAD : RET_GOOD; + } + /* Account for blocks used by meta data */ for (cg = 0, cg < sblock.fs_ncg; cg++) @@ -55,22 +151,23 @@ pass1 () /* Mark the blocks set */ for (bno = firstcgblock; bno < firstdata; bno++) - set_block_used (bno): + setbmap (bno): } /* Loop through each inode, doing initial checks */ for (number = 0, cg = 0; cg < sblock.fs_ncg; cg++) for (i = 0; i < sblock.fs_ipg; i++, number++) { - struct dinode *dp; - mode_t mode; - - dp = getinode (number); - mode = DI_MODE (dp) & IFMT; + if (number < ROOTINO) + continue; + + getinode (number, dp); + mode = DI_MODE (dp); + type = mode & IFMT; /* If the node is not allocated, then make sure it's properly clear */ - if (mode == 0) + if (type == 0) { if (bcmp (dp->di_db, zino.di_db, NDADDR * sizeof (daddr_t)) || bcmp (dp->di_ib, zino->di_ix, NIADDR * sizeof (daddr_t)) @@ -83,13 +180,253 @@ pass1 () { if (preen) printf (" (CLEARED)\n"); - clear_inode (dp); + clear_inode (number, dp); } - + } + inodestate[number] = UNALLOC; + } + else + { + /* Node is allocated. */ + + /* Check to see if we think the node should be cleared */ + + /* Verify size for basic validity */ + holdallblocks = 0; + + if (dp->di_size + sblock.fs_bsize - 1 < dp->di_size) + { + pfatal ("OVERFLOW IN FILE SIZE I=%lu (SIZE == %lu)", inumber, + dp->di_size); + if (reply ("CLEAR")) + { + clear_inode (number, dp); + inodestate[number] = UNALLOC; + continue; + } + inodestate[number] = UNALLOC; + printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu AS ALLOCATED\n"); + holdallblocks = 1; + } + + /* Decode type and set NDB + also set inodestate correctly. */ + inodestate[number] = FILE; + switch (type) + { + case IFBLK: + case IFCHR: + ndb = 1; + break; + case IFIFO: + ndb = 0; + break; + case IFLNK: + if (sblock.fs_maxsymlinklen != -1) + { + /* Check to see if this is a fastlink. The + old fast link format has fs_maxsymlinklen + of zero and di_blocks zero; the new format has + fs_maxsymlinklen set and we ignore di_blocks. + So check for either. */ + if ((sblock.fs_maxsymlinklen + && dp->di_size < sblock.fs_maxsymlinklen) + || (!sblock.fs_maxsymlinklen && !dp->di_blocks)) + { + /* Fake NDB value so that we will check + all the block pointers past the symlink */ + ndb = howmany (dp->di_size, sizeof (daddr_t)); + if (ndb > NDADDR) + { + int j = ndb - NDADDR; + for (ndb = 1; j > 1; i--) + ndb *= NINDIR (&sblock); + ndb += NDADDR; + } + } + else + ndb = howmany (dp->di_size, sblock.fs_bsize); + } + else + ndb = howmany (dp->di_size, sblock.fs_bsize); + break; + case IFDIR: + inodestate[number] = DIR; + /* Fall through */ + case IFREG: + ndb = howmany (dp->di_size, sblock.fs_bsize); + break; + + default: + pfatal ("UNKNOWN FILE TYPE I=%lu (MODE=%lo)\n", + number, mode); + if (reply ("CLEAR")) + { + clear_inode (number, dp); + inodestate[number] = UNALLOC; + continue; + } + inodestate[number] = UNALLOC; + holdallblocks = 1; + printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu " + "AS ALLOCATED\n", number); + } + if (ndb < 0) + { + pfatal ("BAD FILE SIZE I= %lu (SIZE == %lu)", inumber, + dp->di_size); + if (reply ("CLEAR")) + { + clear_inode (number, dp); + inodestate[number] = UNALLOC; + continue; + } + inodestate[number] = UNALLOC; + printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu AS ALLOCATED\n", + number); + holdallblocks = 1; + } + /* Make sure that direct and indirect block pointers + past the file size are zero. If the size is bogus, then + don't bother (they should all be zero, but the user has + requested that they be treated as allocated). */ + if (!holdallblocks) + { + if (dp->di_size + && (type == IFBLK || type == IFCHR + || type == IFSOCK || type == IFIFO)) + { + pfatal ("SPECIAL NODE I=%du (MODE=%ol) HAS SIZE %lu\n", + number, mode, dp->di_size); + if (reply ("TRUNCATE")) + { + dp->di_size = 0; + write_inode (number, dp); + } + } + + /* If we haven't set NDB speciall above, then it is set from + the file size correctly by the size check. */ + + /* Check all the direct and indirect blocks that are past the + amount necessary to be zero. */ + for (lbn = ndb; lbn < NDADDR; lbn++) + { + int dbwarn = 0; + if (dp->di_db[lbn]) + { + if (!dbwarn) + { + dbwarn = 1; + pwarn ("INODE I=%lu HAS EXTRA DIRECT BLOCKS", + number); + if (preen || reply ("DEALLOCATE")) + { + if (preen) + printf (" (DEALLOCATED)\n"); + dp->di_db[lbn] = 0; + dbwarn = 2; + } + } + else if (dbwarn == 2) + dp->di_db[lbn] = 0; + } + if (dbwarn == 2) + write_inode (number, dp); + } - + for (lbn = 0, ndb -= NDADDR; ndb > 0; lbn++) + ndb /= NINDIR (&sblock); + for (; lbn < NIADDR; lbn++) + { + ind ibwarn = 0; + if (dp->di_ib[lbn]) + { + if (ibwarn) + { + ibwarn = 1; + pwarn ("INODE I=%lu HAS EXTRA INDIRECT BLOCKS", + number); + if (preen || reply ("DEALLOCATE")) + { + if (preen) + printf (" (DEALLOCATED)\n"); + dp->di_ib[lbn] = 0; + ibwarn = 2; + } + } + else if (ibwarn == 2) + dp->di_ib[lbn] = 0; + } + if (ibwarn == 2) + write_inode (number, dp); + } + } + + /* If this node is really allocated (as opposed to something + that we should clear but the user won't) then set LINKCOUNT + and TYPEMAP entries. */ + if (inodestate[number] != UNALLOC) + { + linkcount[number] = dp->di_nlink; + typemap[number] = IFTODT (mode); + } + + /* Iterate over the blocks of the file, + calling CHECKBLOCK for each file. */ + nblocks = 0; + blkerror = 0; + nblkduperrors = 0; + nblkrngerrors = 0; + allblock_iterate (dp, checkblock); + + if (blkerror) + { + if (preen) + pfatal ("DUPLICATE or BAD BLOCKS"); + else + { + printf ("I=%ld has "); + if (nblkduperrors) + { + printf ("%d DUPLICATE BLOCKS", nblkduperrors); + if (nblkrngerrors) + printf (" and "); + } + if (nblkrngerrors) + printf ("%d BAD BLOCKS", nblkrngerrors); + printf ("\n"); + if (reply ("CLEAR")) + { + clear_inode (number, dp); + inodestate[number] = UNALLOC; + } + else if (inodestate[number] == DIR) + inodestate[number] = BADDIR; + } + } + else if (dp->di_blocks != nblocks) + { + pwarn ("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)", + number, di->di_blocks, nblocks); + if (preen || reply ("CORRECT")) + { + if (preen) + printf (" (CORRECTED)"); + dp->di_blocks = nblocks; + write_inode (number, dp); + } + } + + if (type == IFDIR) + record_directory (dp, number); + } + } +} + + -- cgit v1.2.3 From 7ab661dbfeed38cb3cab99000e52ef5d9f086fdb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 23:27:40 +0000 Subject: Formerly pass2.c.~2~ --- ufs-fsck/pass2.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index cb874712..7c00e44c 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -23,6 +23,10 @@ starting at root and mark those we find in inodetype with DIR_REF. */ pass2 () { + int nd; + struct dirinfo *dnp; + struct dinode dino, *di = &dino; + switch (statemap [ROOTINO]) { default: @@ -62,5 +66,60 @@ pass2 () statemap[ROOTINO] != DIR_REF; + /* Sort inpsort */ + qsort (dirsorted, dirarrayused, sizeof (struct dirinfo *), sortfunc); + + /* Check basic integrity of each directory */ + for (nd = 0; nd < dirarrayused; nd++) + { + dnp = dirsorted[nd]; + + if (dnp->i_isize == 0) + continue; + if (dnp->i_isize % DIRBLKSIZ) + { + getpathname (pathbuf, dnp->i_number, dnp->i_number); + pwarn ("DIRECTORY %s: LENGTH %d NOT MULTIPLE OF %d", + pathbuf, dnp->i_isize, DIRBLKSIZ); + if (preen || reply ("ADJUST")) + { + if (preen) + printf (" (ADJUSTED)"); + getinode (number, &dino); + dino.di_size = roundup (dnp->i_isize, DIRBLKSIZ); + write_inode (number, &dino); + } + } + bzero (di, sizeof (struct dinode)); + di->di_size = dnp->i_isize; + bcopy (dnp->i_blks, di->di_db, dnp->i_numblks); + + datablocks_iterate (dp, checkdirblock); + } - + /* At this point for each directory: + If this directory is an entry in another directory, then i_parent is + set to that nodes directory. + If this directory has a `..' entry, then i_dotdot is set to that link. + Check to see that `..' is set correctly. */ + for (nd = 0; nd < dirarrayused; nd++) + { + dnp = dirsorted[nd]; + if (dnp->i_parent == 0 || dnp->i_isize == 0) + continue; + + if (dnp->i_dotdot == dnp->i_parent + || dnp->i_dotdot == -1) + continue; + + if (dnp->i_dotdot == 0) + { + dnp->i_dotdot = dnp->i_parent; + + fileerror (dnp->i_parent, dnp->i_number, "MISSING `..'"); + if (reply ("FIX")) + { + makeentry (dnp->i_number, dnp->i_parent, ".."); + + + -- cgit v1.2.3 From df73e9f502c78be8ff3fd0fb5fb47b5573b1e808 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 23:37:52 +0000 Subject: Formerly dir.c.~4~ --- bsdfsck/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c index 6df56df2..28697827 100644 --- a/bsdfsck/dir.c +++ b/bsdfsck/dir.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: dir.c,v 1.3 1994/10/06 17:18:52 mib Exp $"; +static char *rcsid = "$Id: dir.c,v 1.4 1994/10/07 23:37:52 mib Exp $"; #endif /* not lint */ #include @@ -586,7 +586,7 @@ allocdir(parent, request, mode) { ino_t ino; char *cp; - struct dinode *dp; + register struct bufarea *bp; struct dirtemplate *dirp; -- cgit v1.2.3 From b046d1b77783879e2215079dda7ecfdfbf4bc096 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Oct 1994 23:37:56 +0000 Subject: Formerly fsck.h.~2~ --- ufs-fsck/fsck.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 1f8240f4..b7749330 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -28,13 +28,41 @@ enum inodetype BADDIR, /* dir with bad block pointers */ }; -/* State of each inode */ +/* Added to directories in pass 2 */ +#define DIR_REF 0x80000000 /* dir has been found in connectivity search */ + +/* State of each inode (set by pass 1) */ enum inodetype *inodestate; -/* Number of links claimed by each inode */ +/* Number of links claimed by each inode (set by pass 1) */ nlink_t *linkcount; -/* DT_foo type of each inode */ +/* DT_foo type of each inode (set by pass 1) */ char *typemap; + +/* One of these structures is set up for each directory by + pass 1 and used by passes 2 and 3. */ +struct dirinfo +{ + struct inoinfo *i_nexthash; /* next entry in hash chain */ + ino_t i_number; /* inode entry of this dir */ + ino_t i_parent; /* inode entry of parent */ + ino_t i_dotdot; /* inode number of `..' */ + ino_t i_isize; /* size of inode */ + u_int i_numblks; /* size of block array in bytes */ + daddr_t i_blks[0]; /* array of inode block addresses */ +}; + +/* Array of all the dirinfo structures in inode number order */ +struct **dirarray; + +/* Array of all thi dirinfo structures sorted by their first + block address */ +struct **dirsorted; + +int dirarrayused; /* number of directories */ +int dirarraysize; /* alloced size of dirarray/dirsorted */ + + -- cgit v1.2.3 From 8f28a49e601297336c761b8de1c3ce964f8d7371 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 8 Oct 1994 00:49:28 +0000 Subject: Formerly Makefile.~37~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 3dac8b98..59965946 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -20,7 +20,7 @@ makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o /gd3/gnu/libc/i386/devstream.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h -- cgit v1.2.3 From cab6f58508b5a1b0d44a742bf754bf8a1c99c088 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 10 Oct 1994 06:05:48 +0000 Subject: Formerly Makefile.~38~ --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 59965946..3dac8b98 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -20,7 +20,7 @@ makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o /gd3/gnu/libc/i386/devstream.o +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h -- cgit v1.2.3 From 2ea40a9c69b4cbdf81299a02f4a9f27d4b56dc74 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 18:57:39 +0000 Subject: Initial revision --- ufs-fsck/pass3.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 ufs-fsck/pass3.c diff --git a/ufs-fsck/pass3.c b/ufs-fsck/pass3.c new file mode 100644 index 00000000..ca5e3da7 --- /dev/null +++ b/ufs-fsck/pass3.c @@ -0,0 +1,64 @@ +/* Pass 3 of GNU fsck -- Look for disconnected directories + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +pass3 () +{ + struct dirinfo *dnp; + int nd; + int change; + + /* Mark all the directories that can be found from the root. */ + + statemap[ROOTINO] != DIR_REF; + + do + { + change = 0; + for (nd = 0; nd < dirarrayused; nd++) + { + dnp = dirsorted[nd]; + if (dnp->i_parent + && inodestate[dnp->i_parent] == (DIR | DIR_REF) + && inodestate[dnp->i_number] == DIR) + { + inodestate[dnp->i_number] |= DIR_REF; + change = 1; + } + } + } + while (change); + + /* Check for orphaned directories */ + for (nd = 0; nd < dirarrayused; nd++) + { + dnp = dirsorted[nd]; + + if (dnp->i_parent == 0) + { + assert (!(inodestate[dnp->i_number] & DIR_REF)); + linkup (dnp->i_number, dnp->i_dotdot); + } + } +} + + + + + -- cgit v1.2.3 From 98936db7451b56c5085f2eef070127984577faae Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 19:01:02 +0000 Subject: Formerly fsck.h.~3~ --- ufs-fsck/fsck.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index b7749330..3ca8d80e 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -37,6 +37,9 @@ enum inodetype *inodestate; /* Number of links claimed by each inode (set by pass 1) */ nlink_t *linkcount; +/* Number of links found to each inode (set by pass 2) */ +nlink_t *linkfound; + /* DT_foo type of each inode (set by pass 1) */ char *typemap; @@ -50,6 +53,7 @@ struct dirinfo ino_t i_number; /* inode entry of this dir */ ino_t i_parent; /* inode entry of parent */ ino_t i_dotdot; /* inode number of `..' */ + ino_t i_dot; /* inode number of `.' */ ino_t i_isize; /* size of inode */ u_int i_numblks; /* size of block array in bytes */ daddr_t i_blks[0]; /* array of inode block addresses */ -- cgit v1.2.3 From 6040005f491d7e4719fbe3bd5b115f3f1999f8fc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 19:08:44 +0000 Subject: Initial revision --- ufs-fsck/pass4.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ufs-fsck/pass4.c diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c new file mode 100644 index 00000000..69691e4e --- /dev/null +++ b/ufs-fsck/pass4.c @@ -0,0 +1,55 @@ +/* Pass 4 of GNU fsck -- Check reference counts + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +pass4() +{ + ino_t number; + + for (number = ROOTINO; number < lastino; number++) + { + /* If it's correct, then there's nothing to do */ + if (linkcount[number] == linkfound[number] + && (!!(inodestate[number] == UNALLOC) == !linkfound[number])) + + if (linkfound[number] && inodestate[number] != UNALLOC) + { + if (linkcount[number] != linkfound[number]) + { + struct dinode dino; + getinode (number, &dino); + pwarn ("LINK COUNT %s", + (DI_MODE (dp) & IFMT) == IFDIR ? "DIR" : "FILE"); + pinode (dino); + printf (" COUNT %d SHOULD BE %d", linkcount[number], + linkfound[number]); + if (preen) + printf (" (ADJUSTED)"); + if (preen || reply ("ADJUST")) + { + dino.di_nlink = linkfound[number]; + write_inode (number, &dino); + } + } + } + else if (inodestate[number + { + + + -- cgit v1.2.3 From 828684ec41933d8eb3f92b4b7f0bf4f9d1cb04c1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 19:32:39 +0000 Subject: Formerly pass2.c.~3~ --- ufs-fsck/pass2.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 198 insertions(+), 17 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 7c00e44c..ee1d09df 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -19,13 +19,170 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* Verify root inode's basic validity; then traverse all directories - starting at root and mark those we find in inodetype with DIR_REF. */ +/* Verify root inode's allocation and check all directories for + viability. Set DIRSORTED array fully and check to make sure + each directory has a correct . and .. in it. */ pass2 () { int nd; + int change; struct dirinfo *dnp; - struct dinode dino, *di = &dino; + struct dinode dino; + + /* Called for each DIRBLKSIZ chunk of the directory. + BUF is the data of the directory block. Return + 1 if this block has been modified and should be written + to disk; otherwise return 0. */ + int + check1block (void *buf) + { + struct directory_entry *dp; + int mod = 0; + u_char namlen = DIRECT_NAMLEN (dp); + u_char type = DIRECT_TYPE (dp); + int i; + + + for (dp = buf; (void *)dp - buf < DIRBLKSIZ; + dp = (struct directory_entry *) ((void *) dp + dp->d_reclen)) + { + /* Check RECLEN for basic validity */ + if (dp->d_reclen == 0 + || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) + { + pfatal ("BAD RECLEN IN DIRECTORY"); + if (reply ("SALVAGE")) + { + /* Skip over everything else in this dirblock; + mark this entry free. */ + dp->d_ino = 0; + dp->d_reclen = DIRBLKSIZ - ((void *)dp - buf); + return 1; + } + else + /* But give up regardless */ + return mod; + } + + /* Check INO */ + if (dp->d_ino > maxino) + { + pfatal ("BAD INODE NUMBER IN DIRECTORY"); + if (reply ("SALVAGE")) + { + /* Mark this entry clear */ + dp->d_ino = 0; + mod = 1; + } + } + + if (!dp->d_ino) + continue; + + /* Check INO */ + if (inodetype[dp->d_ino] == UNALLOC) + { + fileerror (dnp->i_number, dp->d_ino, "UNALLOCATED"); + if (reply ("REMOVE")) + { + dp->d_ino = 0; + mode = 1; + continue; + } + } + + /* Check NAMLEN */ + namlen = DIRECT_NAMLEN (dp); + if (namlen > MAXNAMLEN) + { + pfatal ("BAD NAMLEN IN DIRECTORY"); + if (reply ("SALVAGE")) + { + /* Mark this entry clear */ + dp->d_ino = 0; + mod = 1 + } + } + else + { + /* Check for illegal characters */ + for (i = 0; i < dp->d_namlen; i++) + if (dp->d_name[i] == '\0' || dp->d_name[i] == '/') + { + pfatal ("ILLEGAL CHARACTER IN FILE NAME"); + if (reply ("SALVAGE")) + { + /* Mark this entry clear */ + dp->d_ino = 0; + mod = 1; + break; + } + } + if (dp->d_name[dp->d_namlen]) + { + pfatal ("DIRECTORY NAME NOT TERMINATED"); + if (reply ("SALVAGE")) + { + /* Mark this entry clear */ + dp->d_ino = 0; + mod = 1; + } + } + } + + if (!dp->d_ino) + continue; + + /* Check TYPE */ + if (type != DT_UNKNOWN && type != typemap[dp->d_ino]) + { + pfatal ("INCORRECT NODE TYPE IN DIRECTORY"); + if (reply ("FIX")) + { + assert (direct_symlink_extension); + dp->d_type = typemap[dp->d_ino]; + mod = 1; + } + } + + /* Here we should check for duplicate directory entries; + that's too much trouble right now. */ + + /* Account for the inode in the linkfound map */ + if (inodestate[number] != UNALLOC) + linkfound[dp->d_ino]++; + + /* If this is `.' or `..' then note the value for + later examination. */ + if (dp->d_namlen == 1 && dp->d_name[0] == '.') + dnp->d_dot = dp->d_ino; + if (dp->d_namlen == 2 + && dp->d_name[0] == '.' && dp->d_name[1] == '.') + dnp->d_dotdot = dp->d_ino; + } + } + + /* Called for each filesystem block of the directory. Load BNO + into core and then call CHECK1BLOCK for each DIRBLKSIZ chunk. */ + void + checkdirblock (daddr_t bno, int nfrags) + { + void *buf = alloca (nfrags * sblock->fs_fsize); + void *bufp; + int rewrite; + + readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + rewrite = 0; + for (bufp = buf; + bufp - buf < nfrags * sblock->fs_fsize; + bufp += DIRBLKSIZ) + { + if (check1block (bufp)) + rewrite = 1; + } + if (rewrite) + writeblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + } switch (statemap [ROOTINO]) { @@ -64,8 +221,6 @@ pass2 () break; } - statemap[ROOTINO] != DIR_REF; - /* Sort inpsort */ qsort (dirsorted, dirarrayused, sizeof (struct dirinfo *), sortfunc); @@ -90,9 +245,9 @@ pass2 () write_inode (number, &dino); } } - bzero (di, sizeof (struct dinode)); - di->di_size = dnp->i_isize; - bcopy (dnp->i_blks, di->di_db, dnp->i_numblks); + bzero (&dino, sizeof (struct dinode)); + dino.di_size = dnp->i_isize; + bcopy (dnp->i_blks, dino.di_db, dnp->i_numblks); datablocks_iterate (dp, checkdirblock); } @@ -105,21 +260,47 @@ pass2 () for (nd = 0; nd < dirarrayused; nd++) { dnp = dirsorted[nd]; - if (dnp->i_parent == 0 || dnp->i_isize == 0) - continue; - - if (dnp->i_dotdot == dnp->i_parent - || dnp->i_dotdot == -1) + if (dnp->i_isize == 0) continue; - if (dnp->i_dotdot == 0) + /* Check `..' to make sure it exists and is correct */ + if (dnp->i_parent && dnp->i_dotdot == 0) { dnp->i_dotdot = dnp->i_parent; fileerror (dnp->i_parent, dnp->i_number, "MISSING `..'"); + if (reply ("FIX")) + makeentry (dnp->i_number, dnp->i_parent, ".."); +} + else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) + { + fileerror (dnp->i_parent, dnp->i_number, + "BAD INODE NUMBER FOR `..'"); if (reply ("FIX")) { - makeentry (dnp->i_number, dnp->i_parent, ".."); - + dnp->i_dotdot = dnp->i_parent; + changeino (dnp->i_number, "..", dnp->i_parent); + } + } + + /* Check `.' to make sure it exists and is correct */ + if (dnp->i_dot == 0) + { + dnp->i_dot = dnp->i_number; + fileerror (dnp->i_number, dnp->i_number, "MISSING `.'"); + if (reply ("FIX")) + makeentry (dnp->i_number, dnp->i_number, "."); + } + else if (dnp->i_dot != dnp->i_number) + { + fileerror (dnp->i_number, dnp->i_number, + "MAD INODE NUMBER FOR `.'"); + if (reply ("FIX")) + { + dnp->i_dot = dnp->i_number; + changeino (dnp->i_number, ".", dnp->i_number); + } + } + } +} - -- cgit v1.2.3 From e811cfa77e93e899b2dd2b9f95bc21bd579fddcc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 19:42:32 +0000 Subject: Formerly pass3.c.~2~ --- ufs-fsck/pass3.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass3.c b/ufs-fsck/pass3.c index ca5e3da7..1d366f21 100644 --- a/ufs-fsck/pass3.c +++ b/ufs-fsck/pass3.c @@ -53,7 +53,13 @@ pass3 () if (dnp->i_parent == 0) { assert (!(inodestate[dnp->i_number] & DIR_REF)); - linkup (dnp->i_number, dnp->i_dotdot); + pwarn ("UNREF DIR"); + pinode (number); + if (preen) + printf (" (RECONNECTED)"); + if (preen || reply ("RECONNECT")) + if (linkup (dnp->i_number, dnp->i_dotdot)) + dnp->i_parent = dnp->i_dotdot = lfdir; } } } -- cgit v1.2.3 From 8ddb49a4164b109cef6f58bd540f5506af80e816 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 19:50:49 +0000 Subject: Formerly pass4.c.~2~ --- ufs-fsck/pass4.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 69691e4e..64d53e38 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -24,10 +24,6 @@ pass4() for (number = ROOTINO; number < lastino; number++) { - /* If it's correct, then there's nothing to do */ - if (linkcount[number] == linkfound[number] - && (!!(inodestate[number] == UNALLOC) == !linkfound[number])) - if (linkfound[number] && inodestate[number] != UNALLOC) { if (linkcount[number] != linkfound[number]) @@ -48,8 +44,60 @@ pass4() } } } - else if (inodestate[number + else if (linkfound[number] && inodestate[number] == UNALLOC) + { + /* This can't happen because we never count links to unallocated + nodes. */ + errexit ("LINK RECORDED FOR UNALLOCATED NODE"); + } + else if (!linkfound[number] && inodestate[number] != UNALLOC) { + /* No links to allocated node. If the size is zero, then + we want to clear it; if the size is positive, then we + want to reattach in. */ + struct dinode dino; + getinode (number, &dino); + + if (dino.st_size) + { + /* This can't happen for dirctories because pass 3 should + already have reset them up. */ + if ((DI_MODE (&dino) & IFMT) == IFDIR) + errexit ("NO LINKS TO NONZERO DIRECTORY"); + + pwarn ("UNREF FILE"); + pinode (number); + if (preen) + printf (" (RECONNECTED)"); + if (preen || reply ("RECONNECT")) + linkup (number, 0); + } + else + { + pwarn ("UNREF %s", + (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE"); + pinode (number); + if (preen) + printf (" (CLEARED)"); + if (preen || reply ("CLEAR")) + { + inodestate[number] = UNALLOC; + clear_inode (number, &dino); + } + } + } + } +} + + + + + + + + + + -- cgit v1.2.3 From b20c2452cbaa1b0701ff83f9139b6ebd0a38cd11 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Oct 1994 20:53:28 +0000 Subject: Initial revision --- ufs-fsck/pass5.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ufs-fsck/pass5.c diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c new file mode 100644 index 00000000..9a8818f7 --- /dev/null +++ b/ufs-fsck/pass5.c @@ -0,0 +1,35 @@ +/* Pass 5 of GNU fsck -- check allocation maps and summaries + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +pass5 () +{ + char cgbuf[MAXBSIZE]; + struct cg *newcg = cgbuf; + struct cg *cg; + + + + + + + + + -- cgit v1.2.3 From 83013be3d14d27f29dc3ddd6d4db90c45cfabd68 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 16:58:58 +0000 Subject: Formerly mkfs.c.~5~ --- ufs-utils/mkfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index f069e600..b92ea346 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.4 1994/09/09 16:48:27 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.5 1994/10/12 16:58:58 mib Exp $"; #endif /* not lint */ #include @@ -250,7 +250,8 @@ main (int argc, char **argv) minfree = MINFREE; opt = DEFAULTOPT ; density = 4 * fsize; - maxcontig = MAX (1, MIN (MAXPHYS, MAXBSIZE) / bsize - 1); +/* maxcontig = MAX (1, MIN (MAXPHYS, MAXBSIZE) / bsize - 1); */ + makcontig = 0; rotdelay = 4; #define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) maxbpg = MAXBLKPG (bsize); -- cgit v1.2.3 From c03fddede6f27566df37e234ef846447c448fa95 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 18:20:01 +0000 Subject: Formerly pass5.c.~2~ --- ufs-fsck/pass5.c | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 295 insertions(+), 4 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 9a8818f7..631e634c 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -23,13 +23,304 @@ pass5 () { char cgbuf[MAXBSIZE]; struct cg *newcg = cgbuf; - struct cg *cg; - - - + struct ocg *ocg = (struct ocg *)cgbuf; + int savednrpos; + struct csum cstotal; + int i, j; + int c; + struct cg *cg = alloca (sblock.fs_cgsize); + char csumbuf[fragroundup (sizeof (struct csum) * sblock.fs_ncg)]; + struct csum *sbcsums = (struct csum *)csumbuf; + + int basesize; /* size of cg not counting flexibly sized */ + int sumsize; /* size of block totals and pos tbl */ + int mapsize; /* size of inode map + block map */ + + int writesb; + int writecg; + int writecsum; + + writesb = 0; + writecsum = 0; + + readblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, + fsbtodb (&sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); + + /* Construct a CG structure; initialize everything that's the same + in each cylinder group. */ + bzero (newcg, sblock.fs_cgsize); + newcg->cg_niblk = sblock.fs_ipg; + switch (sblock.fs_postblformat) + { + case FS_42POSTBLFMT: + /* Initialize size information */ + basesize = (char *)(&ocg->cg_btot[0]) - (char *)(&ocg->cg_link); + sumsize = &ocg->cg_iused[0] - (char *)(&ocg->cg_btot[0]); + mapsize = (&ocg->cg_free[howmany(sblock.fs_fpg, NBBY)] + - (u_char *)&ocg->cg_iused[0]); + savednrpos = sblock.fs_nrpos; + sblock.fs_nrpos = 8; + break; + + case FS_DYNAMICPOSTBLFMT; + /* Set fields unique to new cg structure */ + newcg->cg_btotoff = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); + newcg->cg_boff = newcg->cg_btotoff + sblock.fs_cpg * sizeof (long); + newcg->cg_iusedoff = newcg->cg_boff + (sblock.fs_cpg + * block.fs_nrpos + * sizeof (short)); + newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock.fs_ipg, NBBY); + /* Only support sblock.fs_contigsumsize == 0 here */ + /* If we supported clustered filesystems, then we would set + clustersumoff and clusteroff and nextfree off would be past + them. */ + newcg->cg_nextfreeoff = + (newcg->cg_freeoff + + howmany (sblock.fs_cpg * sblock.fs_spc / NSPF (&sblock), NBBY)); + newcg->cg_magic = CG_MAGIC; + + /* Set map sizes */ + basesize = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); + sumsize = newcg->cg_iusedoff - newcg->cg_btotoff; + mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff; + break; + } + bzero (&cstotal, sizeof (struct csum)); + /* Mark fragments past the end of the filesystem as used. */ + j = blknum (&sblock, sblock->fs_size + fs->fs_frag - 1); + for (i = sblock.fs_size; i < j; i++) + setbmap (i); + /* Now walk through the cylinder groups, checking each one. */ + for (c = 0; c < sblock.fs_ncg; c++) + { + int dbase, dmax; + + /* Read the cylinder group structure */ + readblock (fsbtodb (cgtod (&sblock, c)), cg, + sblock.fs_cgsize / DEV_BSIZE); + writecg = 0; + + if (!cg_chkmagic (cg)) + pfatal ("CG %d: BAD MAGIC NUMBER\n", c); + + /* Compute first and last data block addresses in this group */ + dbase = cgbase (&sblock, c); + dmax = dbase + sblock.fs_fpg; + if (dmax > sblock.fs_size) + dmax = sblock.fs_size; + + /* Initialize newcg fully; values from cg for those + we can't check. */ + newcg->cg_time = cg->cg_time; + newcg->cg_cgx = c; + if (c == sblock.fs_ncg - 1) + newcg->cg_ncyl = sblock.fs_ncyl % sblock.fs_cpg; + else + newcg->cg_ncyl = sblock.fs_cpg; + newcg->cg_ndblk = dmax - dbase; + /* Don't set nclusterblks; we don't support that */ + + newcg->cg_cs.cs_ndir = 0; + newcg->cg_cs.cs_nffree = 0; + newcg->cg_cs.cs_nbfree = 0; + newcg->cg_cs.cs_nifree = sblock.fs_ipg; + + /* Check these for basic viability; if they are wrong + then clear them. */ + newcg->cg_rotor = cg->cg_rotor; + newcg->cg_frotor = cg->cg_frotor; + newcg->cg_irotor = cg->cg_irotor; + if (newcg->cg_rotor > newcg->cg_ndblk) + { + pwarn ("ILLEGAL ROTOR VALUE IN CG %d", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + newcg->cg_rotor = 0; + cg->cg_rotor = 0; + writecg = 1; + } + } + if (newcg->cg_frotor > newcg->cg_ndblk) + { + pwarn ("ILLEGAL FROTOR VALUE IN CG %d", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + newcg->cg_frotor = 0; + cg->cg_frotor = 0; + writecg = 1; + } + } + if (newcg->cg_irotor > newcg->cg_niblk) + { + pwarn ("ILLEGAL IROTOR VALUE IN CG %d", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + newcg->cg_irotor = 0; + cg->cg_irotor = 0; + writecg = 1; + } + } + + /* Zero the block maps and summary areas */ + bzero (&newcg->cg_frsum[0], sizeof newcg->cg_frsum); + bzero (&cg_blktot (newcg)[0], sumsize + mapsize); + if (sblock.fs_postblformat == FS_42POSTBLFMT) + ocg->cg_magic = CG_MAGIC; + + /* Walk through each inode, accounting for it in + the inode map and in newcg->cg_cs. */ + j = fs->fs_ipg * c; + for (i = 0; i < fs->fs_ipg; j++, i++) + switch (inodestate[i]) + { + case DIR: + case DIR | DIR_REF: + newcg->cg_cs.cs_ndir++; + /* Fall through... */ + case FILE: + newcg->cg_cs.cs_nifree--; + setbit (cg_inosused (newcg), i); + } + /* Account for inodes 0 and 1 */ + if (c == 0) + for (i = 0; i < ROOTINO; i++) + { + setbit (cg_inosused (newcg), i); + newcg->cg_cs.cs_nifree--; + } + + /* Walk through each data block, accounting for it in + the block map and in newcg->cg_cs. */ + for (i = 0, d = dbase; + d < dmax; + d += sblock.fs_frag, i += sblock.fs_frag) + { + int frags = 0; + + /* Set each free frag of this block in the block map; + count how many frags were free. */ + for (j = 0; j < fs->fs_frag; j++) + { + if (testbmap (d + j)) + continue; + setbit (cg_blksfree (newcg), i + j); + frags++; + } + + /* If all the frags were free, then count this as + a free block too. */ + if (frags == fs->fs_frag) + { + newcg->cg_cs.cs_nbfree++; + j = cbtocylno (&sblock, i); + cg_blktot(newcg)[j]++; + cg_blks(&sblock, newcg, j)[cktorpos(&sblock, i)]++; + /* If we support clustering, then we'd account for this + in the cluster map too. */ + } + else if (frags) + { + /* Partial; account for the frags. */ + newcg->cg_cs.cs_nffree += frags; + blk = blkmap (&sblock, cg_blksfree (newcg), i); + ffs_fragacct (&sblock, blk, newcg->cg_frsum, 1); + } + } + + /* Add this cylinder group's totals into the superblock's + totals. */ + cstotal.cs.nffree += newcg->cg_cs.cs_nffree; + cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; + cstotal.cs_nifree += newcg->cg_cs.cs_nifree; + cstotal.cs_ndir += newcg->cg_cs.cs_ndir; + /* Check counts in superblock */ + if (bcmp (&newcg->cg_cs, cs, sizeof (struct csum))) + { + pwarn ("FREE BLK COUNTS FOR CG %d WRONG IN SUPERBLOCK", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + bcopy (newcg->cg_cs, cs, sizeof (struct csum)); + writecsum = 1; + } + } + + /* Check inode and block maps */ + if (bcmp (cg_inosused (newcg), cg_inosused (cg), mapsize)) + { + pwarn ("BLKS OR INOS MISSING IN CG %d BIT MAPS", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + bcopy (cg_inosused (newcg), cg_inosused (cg), mapsize); + writecg = 1; + } + } + + if (bcmp (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize)) + { + pwarn ("SUMMARY INFORMATION FOR CG %d BAD", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + bcopy (cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize); + writecg = 1; + } + } + + if (bcmp (newcg, cg, basesize)) + { + pwarn ("CYLINDER GROUP %d BAD", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + bcopy (newcg, cg, basesize); + writecg = 1; + } + } + + if (writecg) + writeblock (fsbtodb (cgtod (&sblock, c)), cg, + sblock.fs_cgsize / DEV_BSIZE); + } + + /* Restore nrpos */ + if (sblock.fs_postblformat == FS_42POSTBLFMT) + sblock.fs_nrpos = savednrpos; + if (bcmp (cstotal, sblock.fs_cstotal, sizeof (struct csum))) + { + pwarn ("TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK", c); + if (preen || reply ("FIX")) + { + if (preen) + printf (" (FIXED)"); + bcopy (&cstotal, sblock.fs_cstotal, sizeof (struct csum)); + sblock.fs_ronly = 0; + sblock.fs_fmod = 0; + writesb = 1; + } + } + + if (writesb) + writeblock (SBLOCK, &sblock, btodb (SBSIZE)); + if (writecsum) + writeblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, + fsbtodb (&sblock, howmany (sblock->fs_cssize, + sblock->fs_fsize))); +} -- cgit v1.2.3 From 686c0f5782d0d71acef2d87dc636d7577d7bb559 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 18:45:49 +0000 Subject: Formerly dir.c.~2~ --- ufs-fsck/dir.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 4259aa39..a4b31e34 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -19,7 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - /* This routine is used in pass 1 to initialize DIRARRAY and DIRSORTED. Copy information from DP (for number NUMBER) into a newly allocated dirinfo structure and add it to the arrays. */ @@ -63,3 +62,128 @@ record_directory (struct dinode *dp, ino_t number) } +/* Link node INO into lost+found. If PARENT is positive then INO is + a directory, and PARENT is the number of `..' as found in INO. + If PARENT is zero then INO is a directory without any .. entry. */ +void +linkup (ino_t ino, ino_t parent) +{ + struct dinode lfdino; + char tempnam[MAXNAMLEN]; + + if (lfdir == 0) + { + struct dinode rootdino; + getinode (ROOTINO, &rootdino); + + scan_dir (lfname, &lfdir); + if (lfdir == 0) + { + pwarn ("NO lost+found DIRECTORY"); + if (preen || reply ("CREATE")) + { + lfdir = allocdir (ROOTINO, 0, lfmode); + if (lfdir != 0) + { + if (makeentry (ROOTINO, lfdir, lfname)) + { + if (preen) + printf (" (CREATED)"); + } + else + { + freedir (lfdir, ROOTINO); + lfdir = 0; + if (preen) + printf ("\n"); + } + } + } + if (!lfdir) + { + pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); + printf ("\n\n"); + return; + } + } + } + + getinode (lfdir, &lfdino); + if ((DI_MODE (&lfdino) & IFMT) != IFDIR) + { + ino_t oldlfdir; + + pfatal ("lost+found IS NOT A DIRECTORY"); + if (!reply ("REALLOCATE")) + return; + + oldlfdir = lfdir; + + lfdir = allocdir (ROOTINO, 0, lfmode); + if (!lfdir) + { + pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); + printf ("\n\n"); + return; + } + if (!changeino (ROOTINO, lfname, lfdir)) + { + pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); + printf ("\n\n"); + return; + } + + /* One less link to the old one */ + linkfound[oldlfdir]--; + + getinode (lfdir, &lfdino); + } + + if (inodestate[lfdir] != DIR && inodestate[lfdir] != (DIR|DIR_REF)) + { + pfatal ("SORRY. lost+found DIRECTORY NOT ALLOCATED.\n\n"); + return; + } + lftempnam (tempname, ino); + if (makeentry (lfdir, ino, tempname)) + { + pfatal("SORRY. NO SPACE IN lost+found DIRECTORY"); + printf("\n\n"); + return; + } + linkfound[ino]++; + + if (parent >= 0) + { + /* Reset `..' in ino */ + if (parent) + { + if (!changeino (ino, "..", lfdir)) + { + pfatal ("CANNOT ADJUST .. link I=%lu", ino); + return; + } + /* Forget about link to old parent */ + linkfound[parent]--; + } + else if (!makeentry (ino, lfdir, "..")) + { + pfatal ("CANNOT CREAT .. link I=%lu", ino); + return; + } + + /* Account for link to lost+found; update inode directly + here to avoid confusing warning later. */ + linkfound[lfdir]++; + lfdino.di_nlink++; + write_inode (lfdir, &lfdino); + + pwarn ("DIR I=%lu CONNECTED. ", ino); + if (parentdir) + printf ("PARENT WAS I=%lu\n", parentdir); + if (!preen) + printf ("\n"); + } +} + + -- cgit v1.2.3 From 6853065d2555a7fb3bdab5162804aa6133c4f0a4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 19:07:09 +0000 Subject: Formerly pass2.c.~4~ --- ufs-fsck/pass2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index ee1d09df..f3353325 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -44,7 +44,7 @@ pass2 () for (dp = buf; (void *)dp - buf < DIRBLKSIZ; - dp = (struct directory_entry *) ((void *) dp + dp->d_reclen)) + dp = (struct directory_entry *) ((void *)dp + dp->d_reclen)) { /* Check RECLEN for basic validity */ if (dp->d_reclen == 0 @@ -163,8 +163,9 @@ pass2 () } /* Called for each filesystem block of the directory. Load BNO - into core and then call CHECK1BLOCK for each DIRBLKSIZ chunk. */ - void + into core and then call CHECK1BLOCK for each DIRBLKSIZ chunk. + Always return 1. */ + int checkdirblock (daddr_t bno, int nfrags) { void *buf = alloca (nfrags * sblock->fs_fsize); @@ -182,6 +183,7 @@ pass2 () } if (rewrite) writeblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + return 1; } switch (statemap [ROOTINO]) -- cgit v1.2.3 From 276812505c6d67733aa9682c501b6e72eefa2651 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 19:11:26 +0000 Subject: Formerly dir.c.~3~ --- ufs-fsck/dir.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index a4b31e34..150719ca 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -61,6 +61,163 @@ record_directory (struct dinode *dp, ino_t number) dirarrayused++; } +/* Check to see if DIR is really a readable directory; if it + isn't, then bail with an appropriate message and return 0; + else return 1. MSG identifies the action contemplated */ +static int +validdir (ino_t dir, char *action) +{ + switch (inodestate[dir]) + { + case DIR: + case DIR|DIR_REF: + return 1; + + case UNALLOC: + pfatal ("CANNOT %s I=%d; NOT ALLOCATED\n", action, dir); + return 0; + + case BADDIR: + pfatal ("CANNOT %s I=%d; BAD BLOCKS\n", action, dir); + return 0; + + case FILE: + pfatal ("CANNOT %s I=%d; NOT DIRECTORY\n", action, dir); + return 0; + } +} + +/* Search directory DIR for name NAME. If NAME is found, then + set *INO to the inode of the entry; otherwise clear INO. */ +void +searchdir (ino_t dir, char *name, ino_t *ino) +{ + struct dinode dino; + int len; + + /* Scan through one directory block and see if it + contains NAME. */ + void + check1block (void *buf) + { + struct directory_entry *dp; + + for (dp = buf; (void *)dp - buf < DIRBLKSIZ; + dp = (struct directory_entry *) ((void *)dp + dp->d_reclen)) + { + if (dp->d_reclen == 0 + || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) + return; + if (dp->d_ino == 0 || dp->d_ino > maxino) + continue; + if (dp->d_namlen != len) + continue; + if (!strcmp (dp->d_name, name)) + continue; + + *ino = dp->d_ino; + return; + } + } + + /* Read part of a directory and look to see if it contains + NAME. Return 1 if we should keep looking at more + blocks. */ + int + checkdirblock (daddr_t bno, int nfrags) + { + void *buf = alloca (nfrags * sblock.fs_fsize); + void *bufp; + + readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + for (bufp = buf; + bufp - buf < nflags * sblock.fs_fsize; + bufp += DIRBLKSIZ) + { + check1block (bufp); + if (*ino) + return 0; + } + return 1; + } + + *ino = 0; + + if (!validdir (dir)) + return; + + getinode (dir, &dino); + + len = strlen (name); + datablocks_iterate (&dino, checkdirblock); +} + +/* Change the existing entry in DIR for name NAME to be + inode INO. Return 1 if the entry was found and + replaced, else return 0. */ +int +changeino (ino_t dir, char *name, ino_t ino) +{ + struct dinode dino; + int len; + + /* Scan through a directory block looking for NAME; + if we find it then change the inode pointer to point + at INO and return 1; if we don't find it then return 0. */ + int + check1block (void *bufp) + { + struct directory_entry *dp; + + for (dp = buf; (void *)dp - buf < DIRBLKSIZ; + dp = (struct directory_entry *) ((void *)dp + dp->d_reclen)) + { + if (dp->d_reclen == 0 + || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) + return; + if (dp->d_ino == 0 || dp->d_ino > maxino) + continue; + if (dp->d_namlen != len) + continue; + if (!strcmp (dp->d_name, name)) + continue; + + dp->d_ino = ino; + return 1; + } + return 0; + } + + /* Read part of a directory and look to see if it + contains NAME. Return 1 if we should keep looking + at more blocks. */ + int + checkdirblock (daddr_t bno, int nfrags) + { + void *buf = alloca (nfrags * sblock.fs_fsize); + void *bufp; + + readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + for (bufp = buf; + bufp - buf < nflags * sblock.fs_fsize; + bufp += DIRBLKSIZ) + { + if (check1block (bufp)) + { + writeblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + return 0; + } + } + return 1; + } + + if (!validdir (dir)) + return 0; + + getinode (dir, &dino); + len = strlen (name); + datablocks_iterate (&dino, checkdirblock); +} /* Link node INO into lost+found. If PARENT is positive then INO is a directory, and PARENT is the number of `..' as found in INO. @@ -73,10 +230,7 @@ linkup (ino_t ino, ino_t parent) if (lfdir == 0) { - struct dinode rootdino; - getinode (ROOTINO, &rootdino); - - scan_dir (lfname, &lfdir); + searchdir (ROOTINO, lfname, &lfdir); if (lfdir == 0) { pwarn ("NO lost+found DIRECTORY"); @@ -175,6 +329,7 @@ linkup (ino_t ino, ino_t parent) /* Account for link to lost+found; update inode directly here to avoid confusing warning later. */ linkfound[lfdir]++; + linkcount[lfdir]++; lfdino.di_nlink++; write_inode (lfdir, &lfdino); @@ -186,4 +341,4 @@ linkup (ino_t ino, ino_t parent) } } - + -- cgit v1.2.3 From 659c439b7cc6d4c63a8560cb7515f9471ea044c0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 22:58:18 +0000 Subject: Initial revision --- ufs-fsck/Makefile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ufs-fsck/Makefile diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile new file mode 100644 index 00000000..ba6c61a9 --- /dev/null +++ b/ufs-fsck/Makefile @@ -0,0 +1,31 @@ +# +# Copyright (C) 1994 Free Software Foundation +# Written by Michael I. Bushnell. +# +# 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. + +dir := newfsck +makemode := utility + +SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ + pass5.c setup.c utilities.c +OBJS = $(subst .c,.o,$(SRCS)) +LCLHDRS = fsck.h +target = newfsck + +include ../Makeconf + -- cgit v1.2.3 From abf524db4e30a864cac633c1f66fc3f7d869fa8a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:33:48 +0000 Subject: Initial revision --- ufs-fsck/setup.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 ufs-fsck/setup.c diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c new file mode 100644 index 00000000..592e66db --- /dev/null +++ b/ufs-fsck/setup.c @@ -0,0 +1,156 @@ +/* + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + + +/* Get ready to run on device with pathname DEV. */ +setup (char *dev) +{ + struct stat st; + int changedsb; + + if (stat (dev, &st) == -1) + { + perror (dev); + return 0; + } + if (!S_ISDIR (st.st_mode)) + { + pfatal ("%s is not a character device", dev); + if (!reply ("CONTINUE")) + return 0; + } + readfd = open (dev, O_RDONLY); + if (readfd == -1) + { + perror (dev); + return 0; + } + if (preen == 0) + printf ("** %s", dev); + if (nflag) + writefd = -1; + else + writefd = open (dev, O_WRONLY); + if (nflag || writefd == -1) + { + if (preen) + pfatal ("NO WRITE ACCESS"); + printf (" (NO WRITE)"); + } + if (preen == 0) + printf ("\n"); + + lfdir = 0; + + /* We don't do the alternate superblock stuff here (yet). */ + readblock (SBLOCK, sblock, SBSIZE); + changedsb = 0; + + if (sblock->fs_magic != FS_MAGIC) + { + pfatal ("BAD MAGIC NUMBER"); + return 0; + } + if (sblock->fs_ncg < 1) + { + pfatal ("NCG OUT OF RANGE"); + return 0; + } + if (sblock->fs_cpg < 1) + { + pfatal ("CPG OUT OF RANGE"); + return 0; + } + if (sblock->fs_ncg * sblock->fs_cpg > sblock->fs_ncyl) + { + pfatal ("NCYL LESS THAN NCG*CPG"); + return 0; + } + if (sblock->fs_sbsize > SBSIZE) + { + pfatal ("SBLOCK SIZE PREPONTEROUSLY LARGE"); + return 0; + } + if (sblock->fs_optim != FS_OPTTIME && sblock->fs_optim != FS_OPTSPACE) + { + pfatal ("UNDEFINED OPTIMIZATION IN SUPERBLOCK"); + if (reply ("SET TO DEFAULT")) + { + sblock->fs_optim = FS_OPTTIME; + changedsb = 1; + } + } + if (sblock->fs_minfree < 0 || sblock->fs_minfree > 99) + { + pfatal ("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK", sblock->fs_minfree); + if (reply ("SET TO DEFAULT")) + { + sblock->fs_minfree = 10; + changedsb = 1; + } + } + if (sblock->fs_interleave < 1 + || sblock->fs_interleave > sblock->fs_nsect) + { + pwarn ("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK", sblock->fs_interleave); + if (preen || reply ("SET TO DEFAULT")) + { + if (preen) + printf (" (SET TO DEFAULT)"); + sblock->fs_interleave = 1; + changedsb = 1; + } + } + if (sblock->fs_npsect < sblock->fs_nsect + || sblock->npsect > sblock->fs_nsect * 2) + { + pwarn ("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK", sblock->fs_npsect); + if (preen || reply ("SET TO DEFAULT")) + { + if (preen) + printf (" (SET TO DEFAULT)"); + sblock->fs_npsect = sblock->fs_nsect; + changedsb = 1; + } + } + if (sblock->fs_inodefmt >= FS_44INODEFMT) + newinofmt = 1; + else + { + sblock->fs_qbmask = ~sblock->fs_bmask; + sblock->fs_qfmask = ~sblock->fs_fmask; + newinofmt = 0; + } + + if (changedsb) + writeblock (SBLOCK, sblock, SBSIZE); + + /* Allocate and initialize maps */ + bmapsize = roundup (howmany (maxfsblock, NBBY), sizeof (short)); + blockmap = calloc (bmapsize, sizeof (char)); + inodestate = calloc (maxino + 1, sizeof (char)); + typemap = calloc (maxino + 1, sizeof (char)); + linkcount = calloc (maxino + 1, sizeof (nlink_t)); + linkfound = calloc (maxino + 1, sizeof (nlink_t)); + return 1; +} + + + -- cgit v1.2.3 From 5294a2422d453ea08f8e8efb7e74ea8f081b16d3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:40:04 +0000 Subject: Initial revision --- ufs-fsck/main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ufs-fsck/main.c diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c new file mode 100644 index 00000000..87a5ff09 --- /dev/null +++ b/ufs-fsck/main.c @@ -0,0 +1,62 @@ +/* Main program for GNU fsck + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +#include "fsck.h" + + +/* Pretty primitive, I'm afraid. */ + +main (int argc, char **argv) +{ + if (argc != 2) + { + fprintf (stderr, "Usage: %s device", argv[0]); + exit (1); + } + + preen = 0; + + if (!setup (argv[1])) + exit (1); + + printf ("** Phase 1 -- Check Blocks and Sizes\n"); + pass1 (); + + if (duplist) + { + printf ("** Phase 1b -- Rescan for More Duplicates\n"); + pass1b (); + } + + printf ("** Phase 2 -- Check Pathnames\n"); + pass2 (); + + printf ("** Phase 3 -- Check Connectivity\n"); + pass3 (); + + printf ("** Phase 4 -- Check Reference Counts\n"); + pass4 (); + + printf ("** Phase 5 -- Check Cyl Groups\n"); + pass5 (); + + if (fsmodified) + printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n"); +} -- cgit v1.2.3 From 5f1ad1678c6f0afdaf2dff224e5096b60be4650a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:44:11 +0000 Subject: Initial revision --- ufs-fsck/utilities.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ufs-fsck/utilities.c diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c new file mode 100644 index 00000000..c4846445 --- /dev/null +++ b/ufs-fsck/utilities.c @@ -0,0 +1,41 @@ +/* Miscellaneous functions for fsck + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +#include "fsck.h" + +/* Read disk block ADDR into BUF of SIZE bytes. */ +void +readblock (daddr_t addr, void *buf, size_t size) +{ + if (lseek (readfd, addr * DEV_BSIZE, L_SET) == -1) + errexit ("CANNOT SEEK TO BLOCK %d", addr); + if (read (readfd, buf, size) != size) + errexit ("CANNOT READ BLOCK %d", addr); +} + +/* Write disk block BLKNO from BUF of SIZE bytes. */ +void +writeblock (daddr_t addr, void *buf, size_t size) +{ + if (lseek (writefd, addr * DEV_BSIZE, L_SET) == -1) + errexit ("CANNOT SEEK TO BLOCK %d", addr); + if (write (writefd, buf, size) != size) + errexit ("CANNOT READ BLOCK %d", addr); +} -- cgit v1.2.3 From fcd4d641b9f4ccea6fc0cd13fd2146e44f4bb31b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:52:17 +0000 Subject: Formerly utilities.c.~2~ --- ufs-fsck/utilities.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index c4846445..aad3429b 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -38,4 +38,39 @@ writeblock (daddr_t addr, void *buf, size_t size) errexit ("CANNOT SEEK TO BLOCK %d", addr); if (write (writefd, buf, size) != size) errexit ("CANNOT READ BLOCK %d", addr); + fsmodified = 1 } + +/* Read inode number INO into DINODE. */ +void +getinode (ino_t ino, struct dinode *di) +{ + daddr_t iblk; + char buf[sblock->fs_fsize]; + + iblk = ino_to_fsba (sblock, ino); + readblock (fsbtodb (iblk), buf, sblock->fs_fsize); + bcopy (buf + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); +} + +/* Write inode number INO from DINODE. */ +void +write_inode (ino_t ino, struct dinode *di) +{ + daddr_t iblk; + char buf[sblock->fs_fsize]; + + iblk = ino_to_fsba (sblock, ino); + readblock (fsbtodb (iblk), buf, sblock->fs_fsize); + bcopy (di, buf + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); + writeblock (fsbtodb (iblk, buf, sblock->fs_fsize)); +} + +/* Clear inode number INO and zero DI. */ +void +clear_inode (ino_t ino, struct dinode *di) +{ + bzero (di, sizeof (struct dinode)); + write_inote (ino, di); +} + -- cgit v1.2.3 From 45cd136e46e9839e008e57f39fe4706e5b42ebc2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:52:24 +0000 Subject: Formerly Makefile.~2~ --- ufs-fsck/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index ba6c61a9..ed36d389 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -21,7 +21,7 @@ dir := newfsck makemode := utility -SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ +SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c OBJS = $(subst .c,.o,$(SRCS)) LCLHDRS = fsck.h @@ -29,3 +29,4 @@ target = newfsck include ../Makeconf +$(OBJS): fsck.h -- cgit v1.2.3 From 2e4c8f04c94b143951f7af37629e43214d7f9422 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:03:16 +0000 Subject: entered into RCS --- ufs-fsck/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 87a5ff09..65f60453 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -20,9 +20,9 @@ #include "fsck.h" - /* Pretty primitive, I'm afraid. */ +int main (int argc, char **argv) { if (argc != 2) @@ -59,4 +59,5 @@ main (int argc, char **argv) if (fsmodified) printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n"); + return 0; } -- cgit v1.2.3 From 223bec5489d66307002be72ca0453f9b7fc1f866 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:04:51 +0000 Subject: Formerly pass5.c.~3~ --- ufs-fsck/pass5.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 631e634c..47086cff 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" pass5 () { @@ -44,7 +45,7 @@ pass5 () writecsum = 0; readblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, - fsbtodb (&sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); + fragroundup (sizeof (struct csum) * sblock.fs_ncg)); /* Construct a CG structure; initialize everything that's the same in each cylinder group. */ @@ -100,8 +101,7 @@ pass5 () int dbase, dmax; /* Read the cylinder group structure */ - readblock (fsbtodb (cgtod (&sblock, c)), cg, - sblock.fs_cgsize / DEV_BSIZE); + readblock (fsbtodb (cgtod (&sblock, c)), cg, sblock.fs_cgsize); writecg = 0; if (!cg_chkmagic (cg)) @@ -187,7 +187,7 @@ pass5 () case DIR | DIR_REF: newcg->cg_cs.cs_ndir++; /* Fall through... */ - case FILE: + case REG: newcg->cg_cs.cs_nifree--; setbit (cg_inosused (newcg), i); } @@ -295,8 +295,7 @@ pass5 () } if (writecg) - writeblock (fsbtodb (cgtod (&sblock, c)), cg, - sblock.fs_cgsize / DEV_BSIZE); + writeblock (fsbtodb (cgtod (&sblock, c)), cg, sblock.fs_cgsize); } /* Restore nrpos */ @@ -318,9 +317,8 @@ pass5 () } if (writesb) - writeblock (SBLOCK, &sblock, btodb (SBSIZE)); + writeblock (SBLOCK, &sblock, SBSIZE); if (writecsum) writeblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, - fsbtodb (&sblock, howmany (sblock->fs_cssize, - sblock->fs_fsize))); + fragroundup (sizeof (struct csum) * sblock.fs_ncg)); } -- cgit v1.2.3 From 5079e13af2c5ad22d0800e9bcc4b2dda7571a5a5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:04:57 +0000 Subject: Formerly pass2.c.~5~ --- ufs-fsck/pass2.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index f3353325..1bae70bc 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -172,7 +172,7 @@ pass2 () void *bufp; int rewrite; - readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + readblock (fsbtodb (bno), buf, nfrags * sblock.fs_fsize); rewrite = 0; for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize; @@ -182,7 +182,7 @@ pass2 () rewrite = 1; } if (rewrite) - writeblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + writeblock (fsbtodb (bno), buf, nfrags * sblock.fs_fsize); return 1; } @@ -202,7 +202,7 @@ pass2 () errexit ("CANNOT ALLOCATE ROOT INODE\n"); break; - case FILE: + case REG: pfatal ("ROOT INODE NOT DIRECTORY"); if (reply ("REALLOCATE")) freeino (ROOTINO); @@ -235,9 +235,8 @@ pass2 () continue; if (dnp->i_isize % DIRBLKSIZ) { - getpathname (pathbuf, dnp->i_number, dnp->i_number); - pwarn ("DIRECTORY %s: LENGTH %d NOT MULTIPLE OF %d", - pathbuf, dnp->i_isize, DIRBLKSIZ); + pwarn ("DIRECTORY INO=%d: LENGTH %d NOT MULTIPLE OF %d", + dnp->i_number, dnp->i_isize, DIRBLKSIZ); if (preen || reply ("ADJUST")) { if (preen) @@ -256,7 +255,7 @@ pass2 () /* At this point for each directory: If this directory is an entry in another directory, then i_parent is - set to that nodes directory. + set to that node's number. If this directory has a `..' entry, then i_dotdot is set to that link. Check to see that `..' is set correctly. */ for (nd = 0; nd < dirarrayused; nd++) @@ -273,7 +272,7 @@ pass2 () fileerror (dnp->i_parent, dnp->i_number, "MISSING `..'"); if (reply ("FIX")) makeentry (dnp->i_number, dnp->i_parent, ".."); -} + } else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) { fileerror (dnp->i_parent, dnp->i_number, -- cgit v1.2.3 From 08a4e356eba9fa8cc72ba7ec1f6a22d68fc4ef02 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:04:58 +0000 Subject: Formerly pass1.c.~3~ --- ufs-fsck/pass1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index a59657fc..5d4c8dd8 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -26,6 +26,7 @@ Set them in the global block map. For each file, if a block is found allocated twice, then record the block and inode in DUPLIST. Initialize INODESTATE, LINKCOUNT, and TYPEMAP. */ +void pass1 () { ino_t number; @@ -211,7 +212,7 @@ pass1 () /* Decode type and set NDB also set inodestate correctly. */ - inodestate[number] = FILE; + inodestate[number] = REG; switch (type) { case IFBLK: -- cgit v1.2.3 From 2bf0b679d4de596fbb5df8bd019bb67ccf2b412e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:39:07 +0000 Subject: Formerly pass4.c.~3~ --- ufs-fsck/pass4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 64d53e38..708674ca 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -71,7 +71,7 @@ pass4() if (preen) printf (" (RECONNECTED)"); if (preen || reply ("RECONNECT")) - linkup (number, 0); + linkup (number, -1); } else { -- cgit v1.2.3 From 4fe0f0d2da215f2dd03c3ddb2e41b173dce5ebf5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 00:42:13 +0000 Subject: Formerly dir.c.~4~ --- ufs-fsck/dir.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 204 insertions(+), 22 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 150719ca..565c0d3f 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -18,16 +18,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" /* This routine is used in pass 1 to initialize DIRARRAY and DIRSORTED. Copy information from DP (for number NUMBER) into a newly allocated dirinfo structure and add it to the arrays. */ +void record_directory (struct dinode *dp, ino_t number) { u_int blks; struct dirinfo *dnp; - blks = howmany (dp->di_size, sblock.fs_bsize); + blks = howmany (dp->di_size, sblock->fs_bsize); if (blks > NDADDR) blks = NDADDR * NIADDR; blks *= sizeof (daddr_t); @@ -35,7 +37,7 @@ record_directory (struct dinode *dp, ino_t number) dnp->i_number = number; dnp->i_parent = dnp->i_dotdot = 0; - dnp->i_isize = dnp->di_size; + dnp->i_isize = dnp->i_isize; dnp->i_numblks = blks * sizeof (daddr_t); bcopy (dp->di_db, dnp->i_blks, blks); @@ -81,9 +83,12 @@ validdir (ino_t dir, char *action) pfatal ("CANNOT %s I=%d; BAD BLOCKS\n", action, dir); return 0; - case FILE: + case REG: pfatal ("CANNOT %s I=%d; NOT DIRECTORY\n", action, dir); return 0; + + default: + errexit ("ILLEGAL STATE"); } } @@ -126,12 +131,12 @@ searchdir (ino_t dir, char *name, ino_t *ino) int checkdirblock (daddr_t bno, int nfrags) { - void *buf = alloca (nfrags * sblock.fs_fsize); + void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; - readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; - bufp - buf < nflags * sblock.fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize; bufp += DIRBLKSIZ) { check1block (bufp); @@ -143,7 +148,7 @@ searchdir (ino_t dir, char *name, ino_t *ino) *ino = 0; - if (!validdir (dir)) + if (!validdir (dir, "READ")) return; getinode (dir, &dino); @@ -160,12 +165,13 @@ changeino (ino_t dir, char *name, ino_t ino) { struct dinode dino; int len; + int madechange; /* Scan through a directory block looking for NAME; if we find it then change the inode pointer to point at INO and return 1; if we don't find it then return 0. */ int - check1block (void *bufp) + check1block (void *buf) { struct directory_entry *dp; @@ -174,7 +180,7 @@ changeino (ino_t dir, char *name, ino_t ino) { if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) - return; + return 0; if (dp->d_ino == 0 || dp->d_ino > maxino) continue; if (dp->d_namlen != len) @@ -183,6 +189,7 @@ changeino (ino_t dir, char *name, ino_t ino) continue; dp->d_ino = ino; + madechange = 1; return 1; } return 0; @@ -194,29 +201,204 @@ changeino (ino_t dir, char *name, ino_t ino) int checkdirblock (daddr_t bno, int nfrags) { - void *buf = alloca (nfrags * sblock.fs_fsize); + void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; - readblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; - bufp - buf < nflags * sblock.fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize; bufp += DIRBLKSIZ) { if (check1block (bufp)) { - writeblock (fsbtodb (bno), buf, fsbtodb (nfrags)); + writeblock (fsbtodb (sblock, bno), buf, + nfrags * sblock->fs_fsize); return 0; } } return 1; } - if (!validdir (dir)) + if (!validdir (dir, "REWRITE")) return 0; getinode (dir, &dino); len = strlen (name); + madechange = 0; datablocks_iterate (&dino, checkdirblock); + return madechange; +} + +/* Attempt to expand the size of a directory. Return + 1 if we succeeded. */ +static int +expanddir (struct dinode *dp) +{ + daddr_t lastbn, newblk; + char *cp, buf[sblock->fs_bsize]; + + lastbn = lblkno (sblock, dp->di_size); + if (blkoff (sblock, dp->di_size) && lastbn >= NDADDR - 1) + return 0; + else if (!blkoff (sblock, dp->di_size) && lastbn >= NDADDR) + return 0; + else if (blkoff (sblock, dp->di_size) && !dp->di_db[lastbn]) + return 0; + else if (!blkoff (sblock, dp->di_size) && dp->di_db[lastbn]) + return 0; + + newblk = allocblk (sblock->fs_frag); + if (!newblk) + return 0; + + if (blkoff (sblock, dp->di_size)) + dp->di_db[lastbn + 1] = dp->di_db[lastbn]; + dp->di_db[lastbn] = newblk; + dp->di_size += sblock->fs_bsize; + dp->di_blocks += sblock->fs_bsize / DEV_BSIZE; + + for (cp = buf; cp < buf + sblock->fs_bsize; cp += DIRBLKSIZ) + { + struct directory_entry *dir = (struct directory_entry *) cp; + dir->d_ino = 0; + dir->d_reclen = DIRBLKSIZ; + } + + writeblock (fsbtodb (sblock, newblk), buf, sblock->fs_bsize); + return 1; +} + +/* Add a new link into directory DIR with name NAME and target + INO. Return 1 if we succeeded and 0 if we failed. It is + an error to call this routine if NAME is already present + in DIR. */ +int +makeentry (ino_t dir, ino_t ino, char *name) +{ + int len; + struct dinode dino; + int needed; + int madeentry; + + /* Read a directory block and see if it contains room for the + new entry. If so, add it and return 1; otherwise return 0. */ + int + check1block (void *buf) + { + struct directory_entry *dp; + + for (dp = buf; (void *)dp - buf < DIRBLKSIZ; + dp = (struct directory_entry *) ((void *)dp + dp->d_reclen)) + { + if (dp->d_reclen == 0 + || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) + return 0; + if (dp->d_ino && dp->d_reclen - DIRSIZ (dp->d_namlen) >= needed) + { + struct directory_entry *newdp; + newdp = (struct directory_entry *) + ((void *)dp + DIRSIZ (DIRECT_NAMLEN (dp))); + + newdp->d_reclen = dp->d_reclen - DIRSIZ (DIRECT_NAMLEN (dp)); + DIRECT_NAMLEN (newdp) = len; + newdp->d_ino = ino; + if (direct_symlink_extension) + newdp->d_type = typemap[ino]; + bcopy (name, newdp->d_name, len + 1); + + dp->d_reclen -= newdp->d_reclen; + madeentry = 1; + return 1; + } + else if (!dp->d_ino && dp->d_reclen >= needed) + { + DIRECT_NAMLEN (dp) = len; + dp->d_ino = ino; + if (direct_symlink_extension) + dp->d_type = typemap[ino]; + bcopy (name, dp->d_name, len + 1); + madeentry = 1; + return 1; + } + } + return 0; + } + + /* Read part of a directory and look to see if it + contains NAME. Return 1 if we should keep looking + at more blocks. */ + int + checkdirblock (daddr_t bno, int nfrags) + { + void *buf = alloca (nfrags * sblock->fs_fsize); + void *bufp; + + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); + for (bufp = buf; + bufp - buf < nfrags * sblock->fs_fsize; + bufp += DIRBLKSIZ) + { + if (check1block (bufp)) + { + writeblock (fsbtodb (sblock, bno), buf, + nfrags * sblock->fs_fsize); + return 0; + } + } + return 1; + } + + if (!validdir (dir, "MODIFY")) + return 0; + + getinode (dir, &dino); + len = strlen (name); + needed = DIRSIZ (len); + madeentry = 0; + datablocks_iterate (&dino, checkdirblock); + if (!madeentry) + { + /* Attempt to expand the directory. */ + pwarn ("NO SPACE LEFT IN DIR INO=%d", dir); + if (preen || reply ("EXPAND")) + { + if (expanddir (&dino)) + { + if (preen) + printf (" (EXPANDED)"); + datablock_iterate (&dino, checkdirblock); + } + else + pfatal ("CANNOT EXPAND DIRECTORY"); + } + } + return madeentry; +} + +/* Create a directory node whose parent is to be PARENT, whose inode + is REQUEST, and whose mode is to be MODE. If REQUEST is zero, then + allocate any inode. Initialze the contents of the + directory. Return the inode of the new directory. */ +ino_t +allocdir (ino_t parent, ino_t request, mode_t mode) +{ + ino_t ino; + + ino = allocino (request, (mode & IFMT) == IFDIR); + if (!ino) + return 0; + if (!makeentry (ino, ino, ".")) + goto bad; + if (!makeentry (ino, ino, "..")) + goto bad; + + linkfound[ino]++; + linkfound[parent]++; + return ino; + + bad: + freeino (ino); + return 0; } /* Link node INO into lost+found. If PARENT is positive then INO is @@ -226,7 +408,7 @@ void linkup (ino_t ino, ino_t parent) { struct dinode lfdino; - char tempnam[MAXNAMLEN]; + char tempname[MAXNAMLEN]; if (lfdir == 0) { @@ -263,7 +445,7 @@ linkup (ino_t ino, ino_t parent) } getinode (lfdir, &lfdino); - if ((DI_MODE (&lfdino) & IFMT) != IFDIR) + if ((lfdino.di_model & IFMT) != IFDIR) { ino_t oldlfdir; @@ -307,14 +489,14 @@ linkup (ino_t ino, ino_t parent) } linkfound[ino]++; - if (parent >= 0) + if (parent != -1) { /* Reset `..' in ino */ if (parent) { if (!changeino (ino, "..", lfdir)) { - pfatal ("CANNOT ADJUST .. link I=%lu", ino); + pfatal ("CANNOT ADJUST .. link I=%u", ino); return; } /* Forget about link to old parent */ @@ -322,7 +504,7 @@ linkup (ino_t ino, ino_t parent) } else if (!makeentry (ino, lfdir, "..")) { - pfatal ("CANNOT CREAT .. link I=%lu", ino); + pfatal ("CANNOT CREAT .. link I=%u", ino); return; } @@ -333,9 +515,9 @@ linkup (ino_t ino, ino_t parent) lfdino.di_nlink++; write_inode (lfdir, &lfdino); - pwarn ("DIR I=%lu CONNECTED. ", ino); - if (parentdir) - printf ("PARENT WAS I=%lu\n", parentdir); + pwarn ("DIR I=%u CONNECTED. ", ino); + if (parent) + printf ("PARENT WAS I=%u\n", parent); if (!preen) printf ("\n"); } -- cgit v1.2.3 From 1758f49fb3a9f9bd422b1f157446e46a4a8654ab Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 01:05:40 +0000 Subject: Formerly fsck.h.~4~ --- ufs-fsck/fsck.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 3ca8d80e..aa6d1a45 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -18,12 +18,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include +#include +#include +#include +#include "../ufs/fs.h" +#include "../ufs/dinode.h" +#include "../ufs/dir.h" /* Type of an inode */ enum inodetype { UNALLOC, /* not allocated */ - FILE, /* allocated, not dir */ + REG, /* allocated, not dir */ DIR, /* dir */ BADDIR, /* dir with bad block pointers */ }; @@ -43,6 +51,13 @@ nlink_t *linkfound; /* DT_foo type of each inode (set by pass 1) */ char *typemap; + +enum contret +{ + RET_STOP, + RET_GOOD, + RET_BAD, +}; /* One of these structures is set up for each directory by @@ -60,13 +75,62 @@ struct dirinfo }; /* Array of all the dirinfo structures in inode number order */ -struct **dirarray; +struct dirinfo **dirarray; /* Array of all thi dirinfo structures sorted by their first block address */ -struct **dirsorted; +struct dirinfo **dirsorted; int dirarrayused; /* number of directories */ int dirarraysize; /* alloced size of dirarray/dirsorted */ +struct dups { + struct dups *next; + daddr_t dup; +}; +struct dups *duplist; /* head of dup list */ +struct dups *muldup; /* end of unique duplicate dup block numbers */ + + +char sblockbuf[SBSIZE]; +struct fs *sblock = (struct fs *)sblockbuf; + +daddr_t maxfsblock; +int maxino; +int direct_symlink_extension; + +int newinofmt; + +int preen; + +int readfd, writefd; + +int fsmodified; + +int lfdir; +char lfname[] = "lost+found"; +mode_t lfmode = IFDIR | 0755; + + +#define howmany(x,y) (((x)+((y)-1))/(y)) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define DEV_BSIZE 512 + + + +int setup (char *); +void pass1 (), pass1b (), pass2 (), pass3 (), pass4 (), pass5 (); + +void readblock (daddr_t, void *, size_t); +void writeblock (daddr_t, void *, size_t); + +void getinode (ino_t, struct dinode *); +void write_inode (ino_t, struct dinode *); +void clear_inode (ino_t, struct dinode *); + +int reply (char *); +void pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); +void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), + noreturn)); +void pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); -- cgit v1.2.3 From 190f91d4bdc364fc06b2cb93bb4b8d2ded7d2607 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 01:09:51 +0000 Subject: Initial revision --- ufs-fsck/inode.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 ufs-fsck/inode.c diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c new file mode 100644 index 00000000..44b79de3 --- /dev/null +++ b/ufs-fsck/inode.c @@ -0,0 +1,60 @@ +/* Inode allocation, deallocation, etc. + Copyright (C) 1994 Free Software Foundation, Inc. + Written by Michael I. Bushnell. + + 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. */ + +static void +inode_iterate (struct dinode *dp, + int (*fn (daddr_t, int)), + int doaddrblocks) +{ + mode_t mode = dp->di_model & IFMT; + int nb, maxb; + + if (mode == IFBLK || mode == IFCHR + || (mode == IFLNK && sblock->fs_maxsymlinklen != -1 + && (dp->di_size < sblock->fs_maxsymlinklen + || (sblock->fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) + return; + + maxb = howmany (dp->di_size, sblock->fs_bsize); + for (nb = 0; nb < NDADDR; nb++) + { + int offset; + int nfrags; + int cont; + + if (nb == maxb && (offset = blkoff (sblock, dp->di_size))) + nfrags = numfrags (sblock, fragroundup (sblock, offset)); + else + nfrags = sblock->fs_frag; + + if (dp->di_db[nb] != 0) + if ((*fn)(dp->di_db[nb], nfrags) != RET_GOOD) + return; + } + + for (nb = 0; nb < NIADDR; nb++) + if (scaniblock (dp->di_db[nb], nb) != RET_GOOD) + return; + + if (doaddrblocks && dp->di_trans) + (*fn)(dp->di_trans, sblock->fs_frag); +} + + -- cgit v1.2.3 From 6d625633cb546bfa11899b24c163a17e83ccf9c5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 13 Oct 1994 01:28:04 +0000 Subject: Formerly inode.c.~2~ --- ufs-fsck/inode.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index 44b79de3..e8924e1a 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -20,12 +20,43 @@ static void inode_iterate (struct dinode *dp, - int (*fn (daddr_t, int)), + int (*fn) (daddr_t, int), int doaddrblocks) { mode_t mode = dp->di_model & IFMT; int nb, maxb; + /* Call FN for iblock IBLOCK of level LEVEL and recurse down + the indirect block pointers. */ + int + scaniblock (daddr_t iblock, int level) + { + int cont; + daddr_t ptrs[NIADDR(sblock)]; + int i; + + if (doaddrblocks) + { + cont = (*fn)(iblock, sblock->fs_frag); + if (cont == RET_STOP) + return RET_STOP; + else if (cont == RET_BAD) + return RET_GOOD; + } + + readblock (fsbtodb (iblock), buf, sblock->fs_bsize); + for (i = 0; i < NIADDR (sblock); i++) + { + if (level == 0) + cont = (*fn)(ptrs[i], sblock->fs_frag); + else + cont = scaniblock (ptrs[i], level - 1); + if (cont == RET_STOP) + return RET_STOP; + } + return RET_GOOD; + } + if (mode == IFBLK || mode == IFCHR || (mode == IFLNK && sblock->fs_maxsymlinklen != -1 && (dp->di_size < sblock->fs_maxsymlinklen @@ -44,17 +75,29 @@ inode_iterate (struct dinode *dp, else nfrags = sblock->fs_frag; - if (dp->di_db[nb] != 0) - if ((*fn)(dp->di_db[nb], nfrags) != RET_GOOD) - return; + if (dp->di_db[nb] && (*fn)(dp->di_db[nb], nfrags) != RET_GOOD) + return; } for (nb = 0; nb < NIADDR; nb++) - if (scaniblock (dp->di_db[nb], nb) != RET_GOOD) + if (dp->di_ib[nb] && scaniblock (dp->di_ib[nb], nb) != RET_GOOD) return; if (doaddrblocks && dp->di_trans) (*fn)(dp->di_trans, sblock->fs_frag); } - +void +datablocks_iterate (struct dinode *dp, + int (*fn) (daddr_t, int)) +{ + inode_iterate (dp, fn, 0); +} + +void +allblock_iterate (struct dinode *dp, + int (*fn) (daddr_t, int)) +{ + inode_iterate (dp, fn, 1); +} + -- cgit v1.2.3 From 3ad6a8bea357a778bd394d2dc98499ac3d7402d4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 02:33:51 +0000 Subject: Formerly pass1.c.~4~ --- ufs-fsck/pass1.c | 94 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 5d4c8dd8..fb6b5f45 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -22,6 +22,8 @@ #include "fsck.h" +static struct dinode zino; + /* Find all the blocks in use by files and filesystem reserved blocks. Set them in the global block map. For each file, if a block is found allocated twice, then record the block and inode in DUPLIST. @@ -66,10 +68,10 @@ pass1 () blkerror = 1; wasbad = 1; if (nblkrngerrors == 0) - printf ("I=%lu HAS BAD BLOCKS\n"); + printf ("I=%d HAS BAD BLOCKS\n", number); if (nblkrngerrors++ > MAXBAD) { - pwarn ("EXCESSIVE BAD BLKS I=%lu", number); + pwarn ("EXCESSIVE BAD BLKS I=%d", number); if (preen || reply ("SKIP")) { if (preen) @@ -82,7 +84,7 @@ pass1 () for (; nfrags > 0; bno++, nfrags--) { if (outofrange && check_range (bno, 1)) - printf ("BAD BLOCK %d\n", bno); + printf ("BAD BLOCK %lu\n", bno); else { if (!testbmap (bno)) @@ -91,12 +93,12 @@ pass1 () { blkerror = 1; if (nblkduperrors == 0) - printf ("I=%lu HAS DUPLICATE BLOCKS\n"); - printf ("DUPLICATE BLOCK %d\n", bno); + printf ("I=%d HAS DUPLICATE BLOCKS\n", number); + printf ("DUPLICATE BLOCK %ld\n", bno); wasbad = 1; if (nblkduperrors++ > MAXBAD) { - pwarn ("EXCESSIVE DUP BLKS I=%lu", number); + pwarn ("EXCESSIVE DUP BLKS I=%d", number); if (preen || reply ("SKIP")) { if (preen) @@ -105,7 +107,7 @@ pass1 () } } new = malloc (sizeof (struct dups)); - new->dup = blkno; + new->dup = bno; if (muldup == 0) { duplist = muldup = new; @@ -117,20 +119,20 @@ pass1 () muldup->next = new; } for (dlp = duplist; dlp != muldup; dlp = dlp->next) - if (dlp->dup == blkno) + if (dlp->dup == bno) break; - if (dlp == muldup && dlp->dup != blkno) + if (dlp == muldup && dlp->dup != bno) muldup = new; } } - nblocks += btodb (sblock->fs_fsize); + nblocks += sblock->fs_fsize / DEV_BSIZE; } return wasbad ? RET_BAD : RET_GOOD; } /* Account for blocks used by meta data */ - for (cg = 0, cg < sblock.fs_ncg; cg++) + for (cg = 0; cg < sblock->fs_ncg; cg++) { daddr_t firstdata, firstcgblock, bno; @@ -141,23 +143,23 @@ pass1 () The first, however, reserves from the very front of the cylinder group (thus including the boot block), and it also reserves the data blocks holding the csum information. */ - firstdata = cgdmin (&sblock, cg); + firstdata = cgdmin (sblock, cg); if (cg == 0) { - firstcgblock = cgbase (&sblock, cg); - firstdata += howmany (sblock.fs_cssize, sblock.fs_fsize); + firstcgblock = cgbase (sblock, cg); + firstdata += howmany (sblock->fs_cssize, sblock->fs_fsize); } else - firstdata = cgsblock (&sblock, cg); + firstcgblock = cgsblock (sblock, cg); /* Mark the blocks set */ for (bno = firstcgblock; bno < firstdata; bno++) - setbmap (bno): + setbmap (bno); } /* Loop through each inode, doing initial checks */ - for (number = 0, cg = 0; cg < sblock.fs_ncg; cg++) - for (i = 0; i < sblock.fs_ipg; i++, number++) + for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++) + for (i = 0; i < sblock->fs_ipg; i++, number++) { if (number < ROOTINO) continue; @@ -171,12 +173,12 @@ pass1 () if (type == 0) { if (bcmp (dp->di_db, zino.di_db, NDADDR * sizeof (daddr_t)) - || bcmp (dp->di_ib, zino->di_ix, NIADDR * sizeof (daddr_t)) + || bcmp (dp->di_ib, zino.di_ib, NIADDR * sizeof (daddr_t)) || dp->di_trans || DI_MODE (dp) || dp->di_size) { - pwarn ("PARTIALLY ALLOCATED INODE I=%lu", number); + pwarn ("PARTIALLY ALLOCATED INODE I=%d", number); if (preen || reply ("CLEAR")) { if (preen) @@ -195,9 +197,9 @@ pass1 () /* Verify size for basic validity */ holdallblocks = 0; - if (dp->di_size + sblock.fs_bsize - 1 < dp->di_size) + if (dp->di_size + sblock->fs_bsize - 1 < dp->di_size) { - pfatal ("OVERFLOW IN FILE SIZE I=%lu (SIZE == %lu)", inumber, + pfatal ("OVERFLOW IN FILE SIZE I=%d (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -206,7 +208,8 @@ pass1 () continue; } inodestate[number] = UNALLOC; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu AS ALLOCATED\n"); + printf ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", + number); holdallblocks = 1; } @@ -225,16 +228,16 @@ pass1 () break; case IFLNK: - if (sblock.fs_maxsymlinklen != -1) + if (sblock->fs_maxsymlinklen != -1) { /* Check to see if this is a fastlink. The old fast link format has fs_maxsymlinklen of zero and di_blocks zero; the new format has fs_maxsymlinklen set and we ignore di_blocks. So check for either. */ - if ((sblock.fs_maxsymlinklen - && dp->di_size < sblock.fs_maxsymlinklen) - || (!sblock.fs_maxsymlinklen && !dp->di_blocks)) + if ((sblock->fs_maxsymlinklen + && dp->di_size < sblock->fs_maxsymlinklen) + || (!sblock->fs_maxsymlinklen && !dp->di_blocks)) { /* Fake NDB value so that we will check all the block pointers past the symlink */ @@ -243,26 +246,26 @@ pass1 () { int j = ndb - NDADDR; for (ndb = 1; j > 1; i--) - ndb *= NINDIR (&sblock); + ndb *= NINDIR (sblock); ndb += NDADDR; } } else - ndb = howmany (dp->di_size, sblock.fs_bsize); + ndb = howmany (dp->di_size, sblock->fs_bsize); } else - ndb = howmany (dp->di_size, sblock.fs_bsize); + ndb = howmany (dp->di_size, sblock->fs_bsize); break; case IFDIR: - inodestate[number] = DIR; + inodestate[number] = DIRECTORY; /* Fall through */ case IFREG: - ndb = howmany (dp->di_size, sblock.fs_bsize); + ndb = howmany (dp->di_size, sblock->fs_bsize); break; default: - pfatal ("UNKNOWN FILE TYPE I=%lu (MODE=%lo)\n", + pfatal ("UNKNOWN FILE TYPE I=%d (MODE=%uo)\n", number, mode); if (reply ("CLEAR")) { @@ -272,13 +275,14 @@ pass1 () } inodestate[number] = UNALLOC; holdallblocks = 1; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu " + printf ("WILL TREAT ANY BLOCKS HELD BY I=%d " "AS ALLOCATED\n", number); + ndb = 0; } if (ndb < 0) { - pfatal ("BAD FILE SIZE I= %lu (SIZE == %lu)", inumber, + pfatal ("BAD FILE SIZE I= %d (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -287,7 +291,7 @@ pass1 () continue; } inodestate[number] = UNALLOC; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%lu AS ALLOCATED\n", + printf ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", number); holdallblocks = 1; } @@ -302,7 +306,7 @@ pass1 () && (type == IFBLK || type == IFCHR || type == IFSOCK || type == IFIFO)) { - pfatal ("SPECIAL NODE I=%du (MODE=%ol) HAS SIZE %lu\n", + pfatal ("SPECIAL NODE I=%d (MODE=%ol) HAS SIZE %lld\n", number, mode, dp->di_size); if (reply ("TRUNCATE")) { @@ -324,7 +328,7 @@ pass1 () if (!dbwarn) { dbwarn = 1; - pwarn ("INODE I=%lu HAS EXTRA DIRECT BLOCKS", + pwarn ("INODE I=%d HAS EXTRA DIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { @@ -342,16 +346,16 @@ pass1 () } for (lbn = 0, ndb -= NDADDR; ndb > 0; lbn++) - ndb /= NINDIR (&sblock); + ndb /= NINDIR (sblock); for (; lbn < NIADDR; lbn++) { - ind ibwarn = 0; + int ibwarn = 0; if (dp->di_ib[lbn]) { if (ibwarn) { ibwarn = 1; - pwarn ("INODE I=%lu HAS EXTRA INDIRECT BLOCKS", + pwarn ("INODE I=%d HAS EXTRA INDIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { @@ -392,7 +396,7 @@ pass1 () pfatal ("DUPLICATE or BAD BLOCKS"); else { - printf ("I=%ld has "); + printf ("I=%d has ", number); if (nblkduperrors) { printf ("%d DUPLICATE BLOCKS", nblkduperrors); @@ -407,14 +411,14 @@ pass1 () clear_inode (number, dp); inodestate[number] = UNALLOC; } - else if (inodestate[number] == DIR) + else if (inodestate[number] == DIRECTORY) inodestate[number] = BADDIR; } } else if (dp->di_blocks != nblocks) { - pwarn ("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)", - number, di->di_blocks, nblocks); + pwarn ("INCORRECT BLOCK COUNT I=%d (%ld should be %d)", + number, dp->di_blocks, nblocks); if (preen || reply ("CORRECT")) { if (preen) -- cgit v1.2.3 From 08628f092564705b648fa4cf9f017169b58cf627 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 02:33:51 +0000 Subject: Formerly pass1b.c.~3~ --- ufs-fsck/pass1b.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index 0eaf6198..ac6c299f 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -18,6 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" + +void pass1b () { struct dinode dino; @@ -37,20 +40,20 @@ pass1b () struct dups *dlp; int hadbad = 0; - for (nfrags; nfrags > 0; bno++, nfrags--) + for (; nfrags > 0; bno++, nfrags--) { - if (chkrange (blkno, 1)) + if (check_range (bno, 1)) return RET_BAD; for (dlp = duphead; dlp; dlp = dlp->next) { - if (dlp->dup == blkno) + if (dlp->dup == bno) { if (!dupblk) - printf ("I=%lu HAD DUPLICATE BLOCKS\n", number); + printf ("I=%d HAD DUPLICATE BLOCKS\n", number); dupblk++; - printf ("DUPLICATE BLOCK %d\n", bno); + printf ("DUPLICATE BLOCK %ld\n", bno); dlp->dup = duphead->dup; - duphead->dup = blkno; + duphead->dup = bno; duphead = duphead->next; hadbad = 1; } @@ -63,26 +66,29 @@ pass1b () /* Call CHECKBLOCK for each block of each node, to see if it holds a block already found to be a duplicate. */ - for (cg = 0; cg < sblock.fs_ncg; cg++) - for (i = 0; i < sblock.fs_ipg; i++, number++) + for (cg = 0; cg < sblock->fs_ncg; cg++) + for (i = 0; i < sblock->fs_ipg; i++, number++) { if (number < ROOTINO) continue; - if (statemap[inumber] != UNALLOC) + if (inodestate[number] != UNALLOC) { getinode (number, dp); dupblk = 0; allblock_iterate (dp, checkblock); if (dupblk) { - printf ("I=%ld has %d DUPLICATE BLOCKS\n", number, dupblk); + printf ("I=%d has %d DUPLICATE BLOCKS\n", number, dupblk); if (reply ("CLEAR")) { clear_inode (number, dp); - inode_state[number] = UNALLOC; + inodestate[number] = UNALLOC; } - else if (inodestate[number] == DIR) + else if (inodestate[number] == DIRECTORY) inodestate[number] = BADDIR; + } } } } + + -- cgit v1.2.3 From d4c8209635a6d104f643139aa0f8436a627bed2e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 02:46:06 +0000 Subject: entered into RCS --- ufs-fsck/pass3.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/pass3.c b/ufs-fsck/pass3.c index 1d366f21..2af148ee 100644 --- a/ufs-fsck/pass3.c +++ b/ufs-fsck/pass3.c @@ -18,6 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" + +void pass3 () { struct dirinfo *dnp; @@ -26,7 +29,7 @@ pass3 () /* Mark all the directories that can be found from the root. */ - statemap[ROOTINO] != DIR_REF; + inodestate[ROOTINO] |= DIR_REF; do { @@ -35,8 +38,8 @@ pass3 () { dnp = dirsorted[nd]; if (dnp->i_parent - && inodestate[dnp->i_parent] == (DIR | DIR_REF) - && inodestate[dnp->i_number] == DIR) + && inodestate[dnp->i_parent] == (DIRECTORY | DIR_REF) + && inodestate[dnp->i_number] == DIRECTORY) { inodestate[dnp->i_number] |= DIR_REF; change = 1; @@ -52,9 +55,10 @@ pass3 () if (dnp->i_parent == 0) { - assert (!(inodestate[dnp->i_number] & DIR_REF)); + if (inodestate[dnp->i_number] & DIR_REF) + errexit ("ORPHANED DIR MARKED WITH CONNECT"); pwarn ("UNREF DIR"); - pinode (number); + pinode (dnp->i_number); if (preen) printf (" (RECONNECTED)"); if (preen || reply ("RECONNECT")) -- cgit v1.2.3 From 56d9814fc90633a8d09d5212179a34c14c6f5835 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 02:52:31 +0000 Subject: Formerly pass4.c.~4~ --- ufs-fsck/pass4.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 708674ca..e70fa411 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -18,11 +18,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" + +void pass4() { ino_t number; - for (number = ROOTINO; number < lastino; number++) + for (number = ROOTINO; number < maxino; number++) { if (linkfound[number] && inodestate[number] != UNALLOC) { @@ -31,7 +34,7 @@ pass4() struct dinode dino; getinode (number, &dino); pwarn ("LINK COUNT %s", - (DI_MODE (dp) & IFMT) == IFDIR ? "DIR" : "FILE"); + (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE"); pinode (dino); printf (" COUNT %d SHOULD BE %d", linkcount[number], linkfound[number]); @@ -59,7 +62,7 @@ pass4() getinode (number, &dino); - if (dino.st_size) + if (dino.di_size) { /* This can't happen for dirctories because pass 3 should already have reset them up. */ -- cgit v1.2.3 From 187abfdaa2d5c524d4e62f9b085c4704114ece69 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:38:26 +0000 Subject: Formerly pass5.c.~4~ --- ufs-fsck/pass5.c | 126 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 47086cff..1311db28 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -20,17 +20,19 @@ #include "fsck.h" +void pass5 () { - char cgbuf[MAXBSIZE]; - struct cg *newcg = cgbuf; + char cgbuf[sblock->fs_cgsize]; + struct cg *newcg = (struct cg *)cgbuf; struct ocg *ocg = (struct ocg *)cgbuf; - int savednrpos; + int savednrpos = 0; struct csum cstotal; int i, j; int c; - struct cg *cg = alloca (sblock.fs_cgsize); - char csumbuf[fragroundup (sizeof (struct csum) * sblock.fs_ncg)]; + daddr_t d; + struct cg *cg = alloca (sblock->fs_cgsize); + char csumbuf[fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)]; struct csum *sbcsums = (struct csum *)csumbuf; int basesize; /* size of cg not counting flexibly sized */ @@ -44,41 +46,41 @@ pass5 () writesb = 0; writecsum = 0; - readblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, - fragroundup (sizeof (struct csum) * sblock.fs_ncg)); + readblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, + fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)); /* Construct a CG structure; initialize everything that's the same in each cylinder group. */ - bzero (newcg, sblock.fs_cgsize); - newcg->cg_niblk = sblock.fs_ipg; - switch (sblock.fs_postblformat) + bzero (newcg, sblock->fs_cgsize); + newcg->cg_niblk = sblock->fs_ipg; + switch (sblock->fs_postblformat) { case FS_42POSTBLFMT: /* Initialize size information */ basesize = (char *)(&ocg->cg_btot[0]) - (char *)(&ocg->cg_link); sumsize = &ocg->cg_iused[0] - (char *)(&ocg->cg_btot[0]); - mapsize = (&ocg->cg_free[howmany(sblock.fs_fpg, NBBY)] + mapsize = (&ocg->cg_free[howmany(sblock->fs_fpg, NBBY)] - (u_char *)&ocg->cg_iused[0]); - savednrpos = sblock.fs_nrpos; - sblock.fs_nrpos = 8; + savednrpos = sblock->fs_nrpos; + sblock->fs_nrpos = 8; break; - case FS_DYNAMICPOSTBLFMT; + case FS_DYNAMICPOSTBLFMT: /* Set fields unique to new cg structure */ newcg->cg_btotoff = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); - newcg->cg_boff = newcg->cg_btotoff + sblock.fs_cpg * sizeof (long); - newcg->cg_iusedoff = newcg->cg_boff + (sblock.fs_cpg - * block.fs_nrpos + newcg->cg_boff = newcg->cg_btotoff + sblock->fs_cpg * sizeof (long); + newcg->cg_iusedoff = newcg->cg_boff + (sblock->fs_cpg + * sblock->fs_nrpos * sizeof (short)); - newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock.fs_ipg, NBBY); + newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock->fs_ipg, NBBY); - /* Only support sblock.fs_contigsumsize == 0 here */ + /* Only support sblock->fs_contigsumsize == 0 here */ /* If we supported clustered filesystems, then we would set clustersumoff and clusteroff and nextfree off would be past them. */ newcg->cg_nextfreeoff = (newcg->cg_freeoff - + howmany (sblock.fs_cpg * sblock.fs_spc / NSPF (&sblock), NBBY)); + + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY)); newcg->cg_magic = CG_MAGIC; /* Set map sizes */ @@ -86,48 +88,51 @@ pass5 () sumsize = newcg->cg_iusedoff - newcg->cg_btotoff; mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff; break; + + default: + errexit ("UNKNOWN POSTBL FORMAT"); } bzero (&cstotal, sizeof (struct csum)); /* Mark fragments past the end of the filesystem as used. */ - j = blknum (&sblock, sblock->fs_size + fs->fs_frag - 1); - for (i = sblock.fs_size; i < j; i++) + j = blknum (sblock, sblock->fs_size + sblock->fs_frag - 1); + for (i = sblock->fs_size; i < j; i++) setbmap (i); /* Now walk through the cylinder groups, checking each one. */ - for (c = 0; c < sblock.fs_ncg; c++) + for (c = 0; c < sblock->fs_ncg; c++) { int dbase, dmax; /* Read the cylinder group structure */ - readblock (fsbtodb (cgtod (&sblock, c)), cg, sblock.fs_cgsize); + readblock (fsbtodb (sblock, cgtod (sblock, c)), cg, sblock->fs_cgsize); writecg = 0; if (!cg_chkmagic (cg)) pfatal ("CG %d: BAD MAGIC NUMBER\n", c); /* Compute first and last data block addresses in this group */ - dbase = cgbase (&sblock, c); - dmax = dbase + sblock.fs_fpg; - if (dmax > sblock.fs_size) - dmax = sblock.fs_size; + dbase = cgbase (sblock, c); + dmax = dbase + sblock->fs_fpg; + if (dmax > sblock->fs_size) + dmax = sblock->fs_size; /* Initialize newcg fully; values from cg for those we can't check. */ newcg->cg_time = cg->cg_time; newcg->cg_cgx = c; - if (c == sblock.fs_ncg - 1) - newcg->cg_ncyl = sblock.fs_ncyl % sblock.fs_cpg; + if (c == sblock->fs_ncg - 1) + newcg->cg_ncyl = sblock->fs_ncyl % sblock->fs_cpg; else - newcg->cg_ncyl = sblock.fs_cpg; + newcg->cg_ncyl = sblock->fs_cpg; newcg->cg_ndblk = dmax - dbase; /* Don't set nclusterblks; we don't support that */ newcg->cg_cs.cs_ndir = 0; newcg->cg_cs.cs_nffree = 0; newcg->cg_cs.cs_nbfree = 0; - newcg->cg_cs.cs_nifree = sblock.fs_ipg; + newcg->cg_cs.cs_nifree = sblock->fs_ipg; /* Check these for basic viability; if they are wrong then clear them. */ @@ -174,22 +179,25 @@ pass5 () /* Zero the block maps and summary areas */ bzero (&newcg->cg_frsum[0], sizeof newcg->cg_frsum); bzero (&cg_blktot (newcg)[0], sumsize + mapsize); - if (sblock.fs_postblformat == FS_42POSTBLFMT) + if (sblock->fs_postblformat == FS_42POSTBLFMT) ocg->cg_magic = CG_MAGIC; /* Walk through each inode, accounting for it in the inode map and in newcg->cg_cs. */ - j = fs->fs_ipg * c; - for (i = 0; i < fs->fs_ipg; j++, i++) + j = sblock->fs_ipg * c; + for (i = 0; i < sblock->fs_ipg; j++, i++) switch (inodestate[i]) { - case DIR: - case DIR | DIR_REF: + case DIRECTORY: + case DIRECTORY | DIR_REF: + case BADDIR: newcg->cg_cs.cs_ndir++; /* Fall through... */ case REG: newcg->cg_cs.cs_nifree--; setbit (cg_inosused (newcg), i); + default: + errexit ("UNKNOWN STATE I=%d", i); } /* Account for inodes 0 and 1 */ if (c == 0) @@ -203,13 +211,13 @@ pass5 () the block map and in newcg->cg_cs. */ for (i = 0, d = dbase; d < dmax; - d += sblock.fs_frag, i += sblock.fs_frag) + d += sblock->fs_frag, i += sblock->fs_frag) { int frags = 0; /* Set each free frag of this block in the block map; count how many frags were free. */ - for (j = 0; j < fs->fs_frag; j++) + for (j = 0; j < sblock->fs_frag; j++) { if (testbmap (d + j)) continue; @@ -219,40 +227,41 @@ pass5 () /* If all the frags were free, then count this as a free block too. */ - if (frags == fs->fs_frag) + if (frags == sblock->fs_frag) { newcg->cg_cs.cs_nbfree++; - j = cbtocylno (&sblock, i); + j = cbtocylno (sblock, i); cg_blktot(newcg)[j]++; - cg_blks(&sblock, newcg, j)[cktorpos(&sblock, i)]++; + cg_blks(sblock, newcg, j)[cbtorpos(sblock, i)]++; /* If we support clustering, then we'd account for this in the cluster map too. */ } else if (frags) { /* Partial; account for the frags. */ + int blk; newcg->cg_cs.cs_nffree += frags; - blk = blkmap (&sblock, cg_blksfree (newcg), i); - ffs_fragacct (&sblock, blk, newcg->cg_frsum, 1); + blk = blkmap (sblock, cg_blksfree (newcg), i); + ffs_fragacct (sblock, blk, newcg->cg_frsum, 1); } } /* Add this cylinder group's totals into the superblock's totals. */ - cstotal.cs.nffree += newcg->cg_cs.cs_nffree; + cstotal.cs_nffree += newcg->cg_cs.cs_nffree; cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; cstotal.cs_nifree += newcg->cg_cs.cs_nifree; cstotal.cs_ndir += newcg->cg_cs.cs_ndir; /* Check counts in superblock */ - if (bcmp (&newcg->cg_cs, cs, sizeof (struct csum))) + if (bcmp (&newcg->cg_cs, &sbcsums[c], sizeof (struct csum))) { pwarn ("FREE BLK COUNTS FOR CG %d WRONG IN SUPERBLOCK", c); if (preen || reply ("FIX")) { if (preen) printf (" (FIXED)"); - bcopy (newcg->cg_cs, cs, sizeof (struct csum)); + bcopy (&newcg->cg_cs, &sbcsums[c], sizeof (struct csum)); writecsum = 1; } } @@ -277,7 +286,7 @@ pass5 () { if (preen) printf (" (FIXED)"); - bcopy (cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize); + bcopy (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize); writecg = 1; } } @@ -295,23 +304,24 @@ pass5 () } if (writecg) - writeblock (fsbtodb (cgtod (&sblock, c)), cg, sblock.fs_cgsize); + writeblock (fsbtodb (sblock, cgtod (sblock, c)), + cg, sblock->fs_cgsize); } /* Restore nrpos */ - if (sblock.fs_postblformat == FS_42POSTBLFMT) - sblock.fs_nrpos = savednrpos; + if (sblock->fs_postblformat == FS_42POSTBLFMT) + sblock->fs_nrpos = savednrpos; - if (bcmp (cstotal, sblock.fs_cstotal, sizeof (struct csum))) + if (bcmp (&cstotal, &sblock->fs_cstotal, sizeof (struct csum))) { - pwarn ("TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK", c); + pwarn ("TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK"); if (preen || reply ("FIX")) { if (preen) printf (" (FIXED)"); - bcopy (&cstotal, sblock.fs_cstotal, sizeof (struct csum)); - sblock.fs_ronly = 0; - sblock.fs_fmod = 0; + bcopy (&cstotal, &sblock->fs_cstotal, sizeof (struct csum)); + sblock->fs_ronly = 0; + sblock->fs_fmod = 0; writesb = 1; } } @@ -319,6 +329,6 @@ pass5 () if (writesb) writeblock (SBLOCK, &sblock, SBSIZE); if (writecsum) - writeblock (fsbtodb (&sblock, sblock.fs_csaddr), csumbuf, - fragroundup (sizeof (struct csum) * sblock.fs_ncg)); + writeblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, + fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)); } -- cgit v1.2.3 From 2ee9b09738f55745accbb0726c6783247b55c1b1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:42:16 +0000 Subject: Formerly utilities.c.~3~ --- ufs-fsck/utilities.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 9 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index aad3429b..c80cfd57 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -19,15 +19,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "fsck.h" +#include +#include +#include /* Read disk block ADDR into BUF of SIZE bytes. */ void readblock (daddr_t addr, void *buf, size_t size) { if (lseek (readfd, addr * DEV_BSIZE, L_SET) == -1) - errexit ("CANNOT SEEK TO BLOCK %d", addr); + errexit ("CANNOT SEEK TO BLOCK %ld", addr); if (read (readfd, buf, size) != size) - errexit ("CANNOT READ BLOCK %d", addr); + errexit ("CANNOT READ BLOCK %ld", addr); } /* Write disk block BLKNO from BUF of SIZE bytes. */ @@ -35,10 +38,10 @@ void writeblock (daddr_t addr, void *buf, size_t size) { if (lseek (writefd, addr * DEV_BSIZE, L_SET) == -1) - errexit ("CANNOT SEEK TO BLOCK %d", addr); + errexit ("CANNOT SEEK TO BLOCK %ld", addr); if (write (writefd, buf, size) != size) - errexit ("CANNOT READ BLOCK %d", addr); - fsmodified = 1 + errexit ("CANNOT READ BLOCK %ld", addr); + fsmodified = 1; } /* Read inode number INO into DINODE. */ @@ -49,7 +52,7 @@ getinode (ino_t ino, struct dinode *di) char buf[sblock->fs_fsize]; iblk = ino_to_fsba (sblock, ino); - readblock (fsbtodb (iblk), buf, sblock->fs_fsize); + readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); bcopy (buf + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); } @@ -61,9 +64,9 @@ write_inode (ino_t ino, struct dinode *di) char buf[sblock->fs_fsize]; iblk = ino_to_fsba (sblock, ino); - readblock (fsbtodb (iblk), buf, sblock->fs_fsize); + readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); bcopy (di, buf + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); - writeblock (fsbtodb (iblk, buf, sblock->fs_fsize)); + writeblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); } /* Clear inode number INO and zero DI. */ @@ -71,6 +74,74 @@ void clear_inode (ino_t ino, struct dinode *di) { bzero (di, sizeof (struct dinode)); - write_inote (ino, di); + write_inode (ino, di); } +/* Allocate and return a block and account for it in all the block + maps locally. Don't trust or change the disk block maps. + The block should be NFRAGS fragments long. */ +daddr_t +allocblk (int nfrags) +{ + daddr_t i; + int j, k; + + if (nfrags <= 0 || nfrags > sblock->fs_frag) + return 0; + + /* Examine each block of the filesystem. */ + for (i = 0; i < maxfsblock - sblock->fs_frag; i += sblock->fs_frag) + { + /* For each piece of the block big enough to hold this frag... */ + for (j = 0; j <= sblock->fs_frag - nfrags; j++) + { + /* For each frag of this piece... */ + for (k = 0; k < nfrags; k++) + if (testbmap (i + j + k)) + break; + + /* If one of the frags was allocated... */ + if (k < nfrags) + { + /* Skip at least that far (short cut) */ + j += k; + continue; + } + + /* It's free (at address i + j) */ + + /* Mark the frags allocated in our map */ + for (k = 0; k < nfrags; k++) + setbmap (i + j + k); + + return (i + j); + } + } + return 0; +} + +/* Check if a block starting at BLK and extending for CNT + fragments is out of range; if it is, then return 1; otherwise return 0. */ +int +check_range (daddr_t blk, int cnt) +{ + int c; + + if ((unsigned)(blk + cnt) > maxfsblock) + return 1; + + c = dtog (sblock, blk); + if (blk < cgdmin (sblock, c)) + { + if (blk + cnt > cgsblock (sblock, c)) + return 1; + } + else + { + if (blk + cnt > cgbase (sblock, c + 1)) + return 1; + } + + return 0; +} + -- cgit v1.2.3 From 1446730430400b176ca727948695124132886110 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:47:41 +0000 Subject: Formerly setup.c.~2~ --- ufs-fsck/setup.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index 592e66db..9b61ac81 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -18,12 +18,23 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" +#include +#include + +static char sblockbuf[SBSIZE]; +struct fs *sblock = (struct fs *)sblockbuf; + +char lfname[] = "lost+found"; +mode_t lfmode = IFDIR | 0755; /* Get ready to run on device with pathname DEV. */ +int setup (char *dev) { struct stat st; int changedsb; + size_t bmapsize; if (stat (dev, &st) == -1) { @@ -44,11 +55,11 @@ setup (char *dev) } if (preen == 0) printf ("** %s", dev); - if (nflag) + if (nowrite) writefd = -1; else writefd = open (dev, O_WRONLY); - if (nflag || writefd == -1) + if (nowrite || writefd == -1) { if (preen) pfatal ("NO WRITE ACCESS"); @@ -99,7 +110,7 @@ setup (char *dev) } if (sblock->fs_minfree < 0 || sblock->fs_minfree > 99) { - pfatal ("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK", sblock->fs_minfree); + pfatal ("IMPOSSIBLE MINFREE=%ld IN SUPERBLOCK", sblock->fs_minfree); if (reply ("SET TO DEFAULT")) { sblock->fs_minfree = 10; @@ -109,7 +120,7 @@ setup (char *dev) if (sblock->fs_interleave < 1 || sblock->fs_interleave > sblock->fs_nsect) { - pwarn ("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK", sblock->fs_interleave); + pwarn ("IMPOSSIBLE INTERLEAVE=%ld IN SUPERBLOCK", sblock->fs_interleave); if (preen || reply ("SET TO DEFAULT")) { if (preen) @@ -119,9 +130,9 @@ setup (char *dev) } } if (sblock->fs_npsect < sblock->fs_nsect - || sblock->npsect > sblock->fs_nsect * 2) + || sblock->fs_npsect > sblock->fs_nsect * 2) { - pwarn ("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK", sblock->fs_npsect); + pwarn ("IMPOSSIBLE NPSECT=%ld IN SUPERBLOCK", sblock->fs_npsect); if (preen || reply ("SET TO DEFAULT")) { if (preen) -- cgit v1.2.3 From f66374d42525fb94b1d2c950f9255a8b9bef01f0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:54:51 +0000 Subject: Formerly Makefile.~3~ --- ufs-fsck/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index ed36d389..e45fed74 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -22,7 +22,7 @@ dir := newfsck makemode := utility SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ - pass5.c setup.c utilities.c + pass5.c setup.c utilities.c inode.c OBJS = $(subst .c,.o,$(SRCS)) LCLHDRS = fsck.h target = newfsck -- cgit v1.2.3 From 3a6583f255226dbb072df89f5cd7e932d99eb181 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:55:01 +0000 Subject: Formerly fsck.h.~5~ --- ufs-fsck/fsck.h | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index aa6d1a45..6c68959b 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "../ufs/fs.h" #include "../ufs/dinode.h" #include "../ufs/dir.h" @@ -32,7 +33,7 @@ enum inodetype { UNALLOC, /* not allocated */ REG, /* allocated, not dir */ - DIR, /* dir */ + DIRECTORY, /* dir */ BADDIR, /* dir with bad block pointers */ }; @@ -51,6 +52,13 @@ nlink_t *linkfound; /* DT_foo type of each inode (set by pass 1) */ char *typemap; +/* Map of blocks allocated */ +char *blockmap; + + +/* Command line flags */ +int nowrite; + enum contret { @@ -92,8 +100,7 @@ struct dups *duplist; /* head of dup list */ struct dups *muldup; /* end of unique duplicate dup block numbers */ -char sblockbuf[SBSIZE]; -struct fs *sblock = (struct fs *)sblockbuf; +struct fs *sblock; daddr_t maxfsblock; int maxino; @@ -108,14 +115,25 @@ int readfd, writefd; int fsmodified; int lfdir; -char lfname[] = "lost+found"; -mode_t lfmode = IFDIR | 0755; +char lfname[]; +mode_t lfmode; +#define NBBY 8 #define howmany(x,y) (((x)+((y)-1))/(y)) #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define isclr(a, i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +#define isset(a, i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<(i)%NBBY)) #define DEV_BSIZE 512 +#define setbmap(blkno) setbit (blockmap, blkno) +#define testbmap(blkno) isset (blockmap, blkno) +#define clrbmap(blkno) clrbit (blockmap, blkno) + +#define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model) + int setup (char *); @@ -128,6 +146,23 @@ void getinode (ino_t, struct dinode *); void write_inode (ino_t, struct dinode *); void clear_inode (ino_t, struct dinode *); +daddr_t allocblk (int); +int check_range (daddr_t, int); + +ino_t allocino (ino_t, mode_t); +void freeino (ino_t); +ino_t allocdir (ino_t, ino_t, mode_t); + +int makeentry (ino_t, ino_t, char *); +int changeino (ino_t, char *, ino_t); + +int linkup (ino_t, ino_t); + +void datablocks_iterate (struct dinode *, int (*)(daddr_t, int)); +void allblock_iterate (struct dinode *, int (*)(daddr_t, int)); + +void record_directory (struct dinode *, ino_t); + int reply (char *); void pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), -- cgit v1.2.3 From aca276e1cb3b6dc072abc318dab38b633d060f7b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 03:56:54 +0000 Subject: Formerly dir.c.~5~ --- ufs-fsck/dir.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 565c0d3f..b1061587 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -71,8 +71,8 @@ validdir (ino_t dir, char *action) { switch (inodestate[dir]) { - case DIR: - case DIR|DIR_REF: + case DIRECTORY: + case DIRECTORY|DIR_REF: return 1; case UNALLOC: @@ -366,7 +366,7 @@ makeentry (ino_t dir, ino_t ino, char *name) { if (preen) printf (" (EXPANDED)"); - datablock_iterate (&dino, checkdirblock); + datablocks_iterate (&dino, checkdirblock); } else pfatal ("CANNOT EXPAND DIRECTORY"); @@ -384,7 +384,7 @@ allocdir (ino_t parent, ino_t request, mode_t mode) { ino_t ino; - ino = allocino (request, (mode & IFMT) == IFDIR); + ino = allocino (request, mode); if (!ino) return 0; if (!makeentry (ino, ino, ".")) @@ -403,12 +403,14 @@ allocdir (ino_t parent, ino_t request, mode_t mode) /* Link node INO into lost+found. If PARENT is positive then INO is a directory, and PARENT is the number of `..' as found in INO. - If PARENT is zero then INO is a directory without any .. entry. */ -void + If PARENT is zero then INO is a directory without any .. entry. + If the node could be linked, return 1; else return 0. */ +int linkup (ino_t ino, ino_t parent) { struct dinode lfdino; - char tempname[MAXNAMLEN]; + char *tempname; + ino_t foo; if (lfdir == 0) { @@ -428,7 +430,8 @@ linkup (ino_t ino, ino_t parent) } else { - freedir (lfdir, ROOTINO); + freeino (lfdir); + linkfound[ROOTINO]--; lfdir = 0; if (preen) printf ("\n"); @@ -439,7 +442,7 @@ linkup (ino_t ino, ino_t parent) { pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); printf ("\n\n"); - return; + return 0; } } } @@ -451,7 +454,7 @@ linkup (ino_t ino, ino_t parent) pfatal ("lost+found IS NOT A DIRECTORY"); if (!reply ("REALLOCATE")) - return; + return 0; oldlfdir = lfdir; @@ -460,13 +463,13 @@ linkup (ino_t ino, ino_t parent) { pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); printf ("\n\n"); - return; + return 0; } if (!changeino (ROOTINO, lfname, lfdir)) { pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); printf ("\n\n"); - return; + return 0; } /* One less link to the old one */ @@ -475,18 +478,29 @@ linkup (ino_t ino, ino_t parent) getinode (lfdir, &lfdino); } - if (inodestate[lfdir] != DIR && inodestate[lfdir] != (DIR|DIR_REF)) + if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF)) { pfatal ("SORRY. lost+found DIRECTORY NOT ALLOCATED.\n\n"); - return; + return 0; + } + asprintf (&tempname, "#%d", ino); + searchdir (lfdir, tempname, &foo); + while (foo) + { + char *newname; + asprintf (&newname, "%sa", tempname); + free (tempname); + tempname = newname; + searchdir (lfdir, tempname, &foo); } - lftempnam (tempname, ino); if (makeentry (lfdir, ino, tempname)) { + free (tempname); pfatal("SORRY. NO SPACE IN lost+found DIRECTORY"); printf("\n\n"); - return; + return 0; } + free (tempname); linkfound[ino]++; if (parent != -1) @@ -497,7 +511,7 @@ linkup (ino_t ino, ino_t parent) if (!changeino (ino, "..", lfdir)) { pfatal ("CANNOT ADJUST .. link I=%u", ino); - return; + return 0; } /* Forget about link to old parent */ linkfound[parent]--; @@ -505,7 +519,7 @@ linkup (ino_t ino, ino_t parent) else if (!makeentry (ino, lfdir, "..")) { pfatal ("CANNOT CREAT .. link I=%u", ino); - return; + return 0; } /* Account for link to lost+found; update inode directly @@ -521,6 +535,7 @@ linkup (ino_t ino, ino_t parent) if (!preen) printf ("\n"); } + return 1; } -- cgit v1.2.3 From 1217c85606e7f84e3ca3e02ff821a682534b5b91 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 04:03:27 +0000 Subject: Formerly pass2.c.~6~ --- ufs-fsck/pass2.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 1bae70bc..0f421168 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -18,17 +18,28 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" /* Verify root inode's allocation and check all directories for viability. Set DIRSORTED array fully and check to make sure each directory has a correct . and .. in it. */ +void pass2 () { int nd; - int change; struct dirinfo *dnp; struct dinode dino; + /* Return negative, zero, or positive according to the + ordering of the first data block of **DNP1 and **DNP2. */ + int + sortfunc (const void *ptr1, const void *ptr2) + { + struct dirinfo * const *dnp1 = ptr1; + struct dirinfo * const *dnp2 = ptr2; + return ((*dnp1)->i_blks[0] - (*dnp2)->i_blks[0]); + } + /* Called for each DIRBLKSIZ chunk of the directory. BUF is the data of the directory block. Return 1 if this block has been modified and should be written @@ -38,11 +49,10 @@ pass2 () { struct directory_entry *dp; int mod = 0; - u_char namlen = DIRECT_NAMLEN (dp); - u_char type = DIRECT_TYPE (dp); + u_char namlen; + char type; int i; - for (dp = buf; (void *)dp - buf < DIRBLKSIZ; dp = (struct directory_entry *) ((void *)dp + dp->d_reclen)) { @@ -80,13 +90,13 @@ pass2 () continue; /* Check INO */ - if (inodetype[dp->d_ino] == UNALLOC) + if (inodestate[dp->d_ino] == UNALLOC) { fileerror (dnp->i_number, dp->d_ino, "UNALLOCATED"); if (reply ("REMOVE")) { dp->d_ino = 0; - mode = 1; + mod = 1; continue; } } @@ -100,7 +110,7 @@ pass2 () { /* Mark this entry clear */ dp->d_ino = 0; - mod = 1 + mod = 1; } } else @@ -134,12 +144,13 @@ pass2 () continue; /* Check TYPE */ + type = DIRECT_TYPE (dp); if (type != DT_UNKNOWN && type != typemap[dp->d_ino]) { pfatal ("INCORRECT NODE TYPE IN DIRECTORY"); if (reply ("FIX")) { - assert (direct_symlink_extension); + errexit ("NODE TYPE FOUND WHEN NOT SUPPORTED"); dp->d_type = typemap[dp->d_ino]; mod = 1; } @@ -149,17 +160,18 @@ pass2 () that's too much trouble right now. */ /* Account for the inode in the linkfound map */ - if (inodestate[number] != UNALLOC) + if (inodestate[dp->d_ino] != UNALLOC) linkfound[dp->d_ino]++; /* If this is `.' or `..' then note the value for later examination. */ if (dp->d_namlen == 1 && dp->d_name[0] == '.') - dnp->d_dot = dp->d_ino; + dnp->i_dot = dp->d_ino; if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.') - dnp->d_dotdot = dp->d_ino; + dnp->i_dotdot = dp->d_ino; } + return mod; } /* Called for each filesystem block of the directory. Load BNO @@ -172,7 +184,7 @@ pass2 () void *bufp; int rewrite; - readblock (fsbtodb (bno), buf, nfrags * sblock.fs_fsize); + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); rewrite = 0; for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize; @@ -182,22 +194,22 @@ pass2 () rewrite = 1; } if (rewrite) - writeblock (fsbtodb (bno), buf, nfrags * sblock.fs_fsize); + writeblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); return 1; } - switch (statemap [ROOTINO]) + switch (inodestate [ROOTINO]) { default: - errexit ("BAD STATE %d FOR ROOT INODE", statemap [ROOTINO]); + errexit ("BAD STATE %d FOR ROOT INODE", (int) (inodestate[ROOTINO])); - case DIR: + case DIRECTORY: break; case UNALLOC: pfatal ("ROOT INODE UNALLOCATED"); if (!reply ("ALLOCATE")) - errexit (""); + errexit ("\n"); if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) errexit ("CANNOT ALLOCATE ROOT INODE\n"); break; @@ -214,12 +226,12 @@ pass2 () pfatal ("DUPLICATE or BAD BLOCKS IN ROOT INODE"); if (reply ("REALLOCATE")) { - freeino (ROOINO); + freeino (ROOTINO); if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) errexit ("CANNOT ALLOCATE ROOT INODE\n"); } if (reply ("CONTINUE") == 0) - errexit (""); + errexit ("\n"); break; } @@ -241,16 +253,16 @@ pass2 () { if (preen) printf (" (ADJUSTED)"); - getinode (number, &dino); + getinode (dnp->i_number, &dino); dino.di_size = roundup (dnp->i_isize, DIRBLKSIZ); - write_inode (number, &dino); + write_inode (dnp->i_number, &dino); } } bzero (&dino, sizeof (struct dinode)); dino.di_size = dnp->i_isize; bcopy (dnp->i_blks, dino.di_db, dnp->i_numblks); - datablocks_iterate (dp, checkdirblock); + datablocks_iterate (&dino, checkdirblock); } /* At this point for each directory: -- cgit v1.2.3 From d127b2fc22daa9906c04d2d31694544e1eae8cdd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 04:07:46 +0000 Subject: Formerly inode.c.~3~ --- ufs-fsck/inode.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index e8924e1a..5cf8e279 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "fsck.h" + static void inode_iterate (struct dinode *dp, int (*fn) (daddr_t, int), @@ -32,7 +34,7 @@ inode_iterate (struct dinode *dp, scaniblock (daddr_t iblock, int level) { int cont; - daddr_t ptrs[NIADDR(sblock)]; + daddr_t ptrs[NINDIR(sblock)]; int i; if (doaddrblocks) @@ -44,8 +46,8 @@ inode_iterate (struct dinode *dp, return RET_GOOD; } - readblock (fsbtodb (iblock), buf, sblock->fs_bsize); - for (i = 0; i < NIADDR (sblock); i++) + readblock (fsbtodb (sblock, iblock), ptrs, sblock->fs_bsize); + for (i = 0; i < NINDIR (sblock); i++) { if (level == 0) cont = (*fn)(ptrs[i], sblock->fs_frag); @@ -68,7 +70,6 @@ inode_iterate (struct dinode *dp, { int offset; int nfrags; - int cont; if (nb == maxb && (offset = blkoff (sblock, dp->di_size))) nfrags = numfrags (sblock, fragroundup (sblock, offset)); @@ -101,3 +102,92 @@ allblock_iterate (struct dinode *dp, inode_iterate (dp, fn, 1); } +/* Allocate an inode. If INUM is nonzero, then allocate that + node specifically, otherwise allocate any available inode. + MODE is the mode of the new file. Return the allocated + inode number (or 0 if the allocation failed). */ +ino_t +allocino (ino_t request, mode_t mode) +{ + ino_t ino; + struct dinode dino; + struct timeval tv; + + if (request) + { + if (inodestate[request] != UNALLOC) + return 0; + ino = request; + } + else + { + for (ino = ROOTINO; ino < maxino; ino++) + if (inodestate[ino] == UNALLOC) + break; + if (ino == maxino) + return 0; + } + + if (mode & IFMT == IFDIR) + inodestate[ino] = DIRECTORY | DIR_REF; + else + inodestate[ino] = REG; + + getinode (ino, &dino); + dino.di_modeh = (mode & 0xffff0000) >> 16; + dino.di_model = (mode & 0x0000ffff); + gettimeofday (&tv, 0); + dino.di_atime.ts_sec = tv.tv_sec; + dino.di_atime.ts_nsec = tv.tv_usec * 1000; + dino.di_mtime = dino.di_ctime = dino.di_atime; + dino.di_size = 0; + dino.di_blocks = 0; + write_inode (ino, &dino); + typemap[ino] = IFTODT (mode); + return ino; +} + +/* Deallocate inode INUM. */ +void +freeino (ino_t inum) +{ + struct dinode dino; + + int + clearblock (daddr_t bno, int nfrags) + { + int i; + + for (i = 0; i < nfrags; i++) + { + if (check_range (bno + i, 1)) + return RET_BAD; + if (testbmap (bno + i)) + { + struct dups *dlp; + for (dlp = duplist; dlp; dlp = dlp->next) + { + if (dlp->dup != bno + i) + continue; + dlp->dup = duplist->dup; + dlp = duplist; + duplist = duplist->next; + free (dlp); + break; + } + if (dlp == 0) + clrbmap (bno + i); + } + } + return RET_GOOD; + } + + getinode (inum, &dino); + allblock_iterate (&dino, clearblock); + + clear_inode (inum, &dino); + inodestate[inum] = UNALLOC; +} + + + -- cgit v1.2.3 From 49105ac78372aa88489857e625e56e7d37698462 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 20:44:05 +0000 Subject: Formerly fsck.h.~6~ --- ufs-fsck/fsck.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 6c68959b..7cbee23c 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -1,3 +1,4 @@ + /* Copyright (C) 1994 Free Software Foundation, Inc. Written by Michael I. Bushnell. @@ -57,7 +58,8 @@ char *blockmap; /* Command line flags */ -int nowrite; +int nowrite; /* all questions fail */ +int noquery; /* all questions succeed */ enum contret @@ -164,8 +166,8 @@ void allblock_iterate (struct dinode *, int (*)(daddr_t, int)); void record_directory (struct dinode *, ino_t); int reply (char *); -void pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); +int pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), noreturn)); -void pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); +int pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); -- cgit v1.2.3 From ecf2027d408e47c5be3c4a920fbd8c3ba01b6c08 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 20:48:19 +0000 Subject: Formerly utilities.c.~4~ --- ufs-fsck/utilities.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index c80cfd57..7dacaa95 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Read disk block ADDR into BUF of SIZE bytes. */ void @@ -145,3 +146,89 @@ check_range (daddr_t blk, int cnt) return 0; } +/* Like printf, but exit if we are preening. */ +int +pfatal (char *fmt, ...) +{ + va_list args; + int ret; + + va_start (args, fmt); + ret = vprintf (fmt, args); + va_end (args); + putchar ('\n'); + if (preen) + exit (1); + + return ret; +} + +/* Like printf, but exit after printing. */ +void +errexit (char *fmt, ...) +{ + va_list args; + + va_start (args, fmt); + vprintf (fmt, args); + va_end (args); + exit (1); +} + +/* Like printf, but give more information (when we fully support it) + when preening. */ +int +pwarn (char *fmt, ...) +{ + va_list args; + int ret; + + va_start (args, fmt); + ret = vprintf (fmt, args); + va_end (args); + return ret; +} + +/* Ask the user a question; return 1 if the user says yes, and 0 + if the user says no. */ +int +reply (char *question) +{ + int persevere; + char c; + + if (preen) + pfatal ("INTERNAL ERROR: GOT TO reply ()"); + + persevere = !strcmp (question, "CONTINUE"); + putchar ('\n'); + if (!persevere && (nowrite || writefd < 0)) + { + printf ("%s? no\n\n", question); + return 0; + } + else if (noquery || (persevere && nowrite)) + { + printf ("%s? yes\n\n", question); + return 1; + } + else + { + do + { + printf ("%s? [yn] ", question); + fflush (stdout); + c = getchar (); + while (c != '\n' && getchar () != '\n') + if (feof (stdin)) + return 0; + } + while (c != 'y' && c != 'Y' && c != 'n' && c != 'N'); + putchar ('\n'); + return c == 'y' || c == 'Y'; + } +} + + + + -- cgit v1.2.3 From f29b9ddb7a140375580818cd5007513050b6e7b0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:13:48 +0000 Subject: Formerly fsck.h.~7~ --- ufs-fsck/fsck.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 7cbee23c..2c72d46f 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -165,6 +165,8 @@ void allblock_iterate (struct dinode *, int (*)(daddr_t, int)); void record_directory (struct dinode *, ino_t); +void pinode (ino_t); + int reply (char *); int pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), -- cgit v1.2.3 From 2d4dcb353adf733064a5a63208f218ad4211e26f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:17:19 +0000 Subject: Formerly pass2.c.~7~ --- ufs-fsck/pass2.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 0f421168..19d8ba8c 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -92,7 +92,8 @@ pass2 () /* Check INO */ if (inodestate[dp->d_ino] == UNALLOC) { - fileerror (dnp->i_number, dp->d_ino, "UNALLOCATED"); + printf ("REF TO UNALLOCATED NODE; DIR"); + pinode (dnp->i_number); if (reply ("REMOVE")) { dp->d_ino = 0; @@ -281,14 +282,15 @@ pass2 () { dnp->i_dotdot = dnp->i_parent; - fileerror (dnp->i_parent, dnp->i_number, "MISSING `..'"); + printf ("MISSING `..' IN DIR"); + pinode (dnp->i_number); if (reply ("FIX")) makeentry (dnp->i_number, dnp->i_parent, ".."); } else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) { - fileerror (dnp->i_parent, dnp->i_number, - "BAD INODE NUMBER FOR `..'"); + printf ("BAD INODE NUMBER FOR `..' IN DIR"); + pinode (dnp->i_number); if (reply ("FIX")) { dnp->i_dotdot = dnp->i_parent; @@ -300,14 +302,15 @@ pass2 () if (dnp->i_dot == 0) { dnp->i_dot = dnp->i_number; - fileerror (dnp->i_number, dnp->i_number, "MISSING `.'"); + printf ("MISSING `.' IN DIR"); + pinode (dnp->i_number); if (reply ("FIX")) makeentry (dnp->i_number, dnp->i_number, "."); } else if (dnp->i_dot != dnp->i_number) { - fileerror (dnp->i_number, dnp->i_number, - "MAD INODE NUMBER FOR `.'"); + printf ("BAD INODE NUMBER FOR `.' IN DIR"); + pinode (dnp->i_number); if (reply ("FIX")) { dnp->i_dot = dnp->i_number; -- cgit v1.2.3 From 35372ce18ca8e12a5b8a74e2f8a752197946965f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:20:03 +0000 Subject: entered into RCS --- ufs-fsck/pass4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index e70fa411..7ba50baf 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -35,7 +35,7 @@ pass4() getinode (number, &dino); pwarn ("LINK COUNT %s", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE"); - pinode (dino); + pinode (number); printf (" COUNT %d SHOULD BE %d", linkcount[number], linkfound[number]); if (preen) -- cgit v1.2.3 From 32240511feea3e5d7fcda255788128c8010af6d8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:23:31 +0000 Subject: Formerly utilities.c.~5~ --- ufs-fsck/utilities.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 7dacaa95..4780ac8a 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Read disk block ADDR into BUF of SIZE bytes. */ void @@ -229,6 +230,28 @@ reply (char *question) } } +/* Print a helpful description of the given inode number. */ +void +pinode (ino_t ino) +{ + struct dinode dino; + struct passwd *pw; + char *p; + + printf (" I=%d ", ino); + if (ino < ROOTINO || ino > maxino) + return; + getinode (ino, &dino); + printf (" OWNER="); + if (pw = getpwuid (dino.di_uid)) + printf ("%s ", pw->pw_name); + else + printf ("%lu ", dino.di_uid); - + printf (" MODE=%o\n", DI_MODE (&dino)); + printf ("SIZE=%llu ", dino.di_size); + p = ctime (&dino.di_mtime.ts_sec); + printf ("MTIME=%12.12s %4.4s ", &p[4], &p[20]); +} + -- cgit v1.2.3 From 246f8a9691797e2bc8a8d647dee0d00a9d955c76 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:27:36 +0000 Subject: Formerly pass5.c.~5~ --- ufs-fsck/pass5.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 1311db28..c2c94a5b 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -20,6 +20,43 @@ #include "fsck.h" +/* From ../ufs/subr.c: */ + +/* + * Update the frsum fields to reflect addition or deletion + * of some frags. + */ +static void +ffs_fragacct(fs, fragmap, fraglist, cnt) + struct fs *fs; + int fragmap; + long fraglist[]; + int cnt; +{ + int inblk; + register int field, subfield; + register int siz, pos; + + inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1; + fragmap <<= 1; + for (siz = 1; siz < fs->fs_frag; siz++) { + if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0) + continue; + field = around[siz]; + subfield = inside[siz]; + for (pos = siz; pos <= fs->fs_frag; pos++) { + if ((fragmap & field) == subfield) { + fraglist[siz] += cnt; + pos += siz; + field <<= siz; + subfield <<= siz; + } + field <<= 1; + subfield <<= 1; + } + } +} + void pass5 () { -- cgit v1.2.3 From d3f29599e87d2e68b26bc409dcc96b33e2a58fd7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:30:57 +0000 Subject: Formerly Makefile.~4~ --- ufs-fsck/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index e45fed74..75b2207a 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -23,10 +23,13 @@ makemode := utility SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c inode.c -OBJS = $(subst .c,.o,$(SRCS)) +OBJS = $(subst .c,.o,$(SRCS)) tables.o LCLHDRS = fsck.h target = newfsck include ../Makeconf $(OBJS): fsck.h + +tables.o: ../ufs/tables.c + $(CC) $(CFLAGS) -c -o $@ $< -- cgit v1.2.3 From 0a3d26c2d6c561b353d183fdd1037ba351e96ade Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 21:44:26 +0000 Subject: Formerly setup.c.~3~ --- ufs-fsck/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index 9b61ac81..a3f67a09 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -41,7 +41,7 @@ setup (char *dev) perror (dev); return 0; } - if (!S_ISDIR (st.st_mode)) + if (!S_ISCHR (st.st_mode)) { pfatal ("%s is not a character device", dev); if (!reply ("CONTINUE")) -- cgit v1.2.3 From 39468ab583899412a0f399800bb1f2289e21e645 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 14 Oct 1994 22:03:42 +0000 Subject: Formerly setup.c.~4~ --- ufs-fsck/setup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index a3f67a09..10521ce1 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -89,9 +89,10 @@ setup (char *dev) pfatal ("CPG OUT OF RANGE"); return 0; } - if (sblock->fs_ncg * sblock->fs_cpg > sblock->fs_ncyl) + if (sblock->fs_ncg * sblock->fs_cpg < sblock->fs_ncyl + || (sblock->fs_ncg - 1) * sblock->fs_cpg >= sblock->fs_ncyl) { - pfatal ("NCYL LESS THAN NCG*CPG"); + pfatal ("NCYL INCONSISTENT WITH NCG AND CPG"); return 0; } if (sblock->fs_sbsize > SBSIZE) @@ -153,6 +154,11 @@ setup (char *dev) if (changedsb) writeblock (SBLOCK, sblock, SBSIZE); + /* Constants */ + maxfsblock = sblock->fs_size; + maxino = sblock->fs_ncg * sblock->fs_ipg; + direct_symlink_extension = sblock->fs_maxsymlinklen > 0; + /* Allocate and initialize maps */ bmapsize = roundup (howmany (maxfsblock, NBBY), sizeof (short)); blockmap = calloc (bmapsize, sizeof (char)); -- cgit v1.2.3 From e7f0c91ea2cacb940a2b15c4f565dfeed39683fa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 15 Oct 1994 01:09:10 +0000 Subject: Formerly utilities.c.~6~ --- ufs-fsck/utilities.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 4780ac8a..db603831 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -46,16 +46,24 @@ writeblock (daddr_t addr, void *buf, size_t size) fsmodified = 1; } +/* Last filesystem fragment that we read an inode from */ +static char *lastifrag; +static daddr_t lastifragaddr; + /* Read inode number INO into DINODE. */ void getinode (ino_t ino, struct dinode *di) { daddr_t iblk; - char buf[sblock->fs_fsize]; + if (!lastifrag) + lastifrag = malloc (sblock->fs_fsize); + iblk = ino_to_fsba (sblock, ino); - readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); - bcopy (buf + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); + if (iblk != lastifragaddr) + readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); + lastifragaddr = iblk; + bcopy (lastifrag + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); } /* Write inode number INO from DINODE. */ @@ -63,12 +71,13 @@ void write_inode (ino_t ino, struct dinode *di) { daddr_t iblk; - char buf[sblock->fs_fsize]; iblk = ino_to_fsba (sblock, ino); - readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); - bcopy (di, buf + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); - writeblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize); + if (iblk != lastifragaddr) + readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); + lastifragaddr = iblk; + bcopy (di, lastifrag + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); + writeblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); } /* Clear inode number INO and zero DI. */ -- cgit v1.2.3 From 1993ddda86f28d950ce2c0c8ab8b004fc927bdfb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 17 Oct 1994 19:40:20 +0000 Subject: Formerly pass1.c.~5~ --- ufs-fsck/pass1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index fb6b5f45..c96d0f7f 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -161,6 +161,9 @@ pass1 () for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++) for (i = 0; i < sblock->fs_ipg; i++, number++) { + if (!(number % 1000)) + printf ("I=%d\n", number); + if (number < ROOTINO) continue; -- cgit v1.2.3 From 1d8a2d453361842cc72c2c54fe89b32bacbd704d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 17 Oct 1994 20:10:28 +0000 Subject: Formerly utilities.c.~7~ --- ufs-fsck/utilities.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index db603831..f66204f9 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -57,13 +57,14 @@ getinode (ino_t ino, struct dinode *di) daddr_t iblk; if (!lastifrag) - lastifrag = malloc (sblock->fs_fsize); + lastifrag = malloc (sblock->fs_bsize); iblk = ino_to_fsba (sblock, ino); if (iblk != lastifragaddr) - readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); + readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize); lastifragaddr = iblk; - bcopy (lastifrag + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); + bcopy (lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode), + di, sizeof (struct dinode)); } /* Write inode number INO from DINODE. */ @@ -74,10 +75,11 @@ write_inode (ino_t ino, struct dinode *di) iblk = ino_to_fsba (sblock, ino); if (iblk != lastifragaddr) - readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); + readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize); lastifragaddr = iblk; - bcopy (di, lastifrag + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); - writeblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize); + bcopy (di, lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode), + sizeof (struct dinode)); + writeblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize); } /* Clear inode number INO and zero DI. */ -- cgit v1.2.3 From 20bc9b801818cad5fd7d0ff47ce7427bf256e2ed Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 17 Oct 1994 20:36:23 +0000 Subject: entered into RCS --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 3dac8b98..59965946 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -20,7 +20,7 @@ makemode := server SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o +OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o /gd3/gnu/libc/i386/devstream.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h -- cgit v1.2.3 From 53cfa287f777ab33bf94496a46fd4570667b3703 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 17 Oct 1994 20:37:08 +0000 Subject: Formerly pass2.c.~8~ --- ufs-fsck/pass2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 19d8ba8c..a261ff1d 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -266,6 +266,7 @@ pass2 () datablocks_iterate (&dino, checkdirblock); } + /* At this point for each directory: If this directory is an entry in another directory, then i_parent is set to that node's number. @@ -277,6 +278,11 @@ pass2 () if (dnp->i_isize == 0) continue; + /* Root is considered to be its own parent even though it isn't + listed. */ + if (dnp->i_number == ROOTINO && !dnp->i_parent) + dnp->i_parent = ROOTINO; + /* Check `..' to make sure it exists and is correct */ if (dnp->i_parent && dnp->i_dotdot == 0) { -- cgit v1.2.3 From 73babc1f497bf2ecb0c397fe274107dab23dd042 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 00:33:00 +0000 Subject: Formerly pass2.c.~9~ --- ufs-fsck/pass2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index a261ff1d..a04b475e 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -177,9 +177,10 @@ pass2 () /* Called for each filesystem block of the directory. Load BNO into core and then call CHECK1BLOCK for each DIRBLKSIZ chunk. + OFFSET is the offset this block occupies ithe file. Always return 1. */ int - checkdirblock (daddr_t bno, int nfrags) + checkdirblock (daddr_t bno, int nfrags, off_t offset) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; @@ -188,7 +189,8 @@ pass2 () readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); rewrite = 0; for (bufp = buf; - bufp - buf < nfrags * sblock->fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize + && offset + (bufp - buf) + DIRBLKSIZ <= dnp->i_isize; bufp += DIRBLKSIZ) { if (check1block (bufp)) -- cgit v1.2.3 From 1598f99ac09a2c34439326ed18e05dc06864a269 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 00:33:03 +0000 Subject: Formerly pass1.c.~6~ --- ufs-fsck/pass1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index c96d0f7f..49200337 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -55,7 +55,7 @@ pass1 () bad, or if we should entirely stop checking blocks in this inode. */ int - checkblock (daddr_t bno, int nfrags) + checkblock (daddr_t bno, int nfrags, off_t offset) { #define MAXBAD 10 int outofrange; -- cgit v1.2.3 From 3c8b9378ce4127d457ec788353bf78881617931b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 00:33:04 +0000 Subject: Formerly dir.c.~6~ --- ufs-fsck/dir.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index b1061587..0a0c0ac2 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -37,7 +37,7 @@ record_directory (struct dinode *dp, ino_t number) dnp->i_number = number; dnp->i_parent = dnp->i_dotdot = 0; - dnp->i_isize = dnp->i_isize; + dnp->i_isize = dp->di_size; dnp->i_numblks = blks * sizeof (daddr_t); bcopy (dp->di_db, dnp->i_blks, blks); @@ -129,14 +129,15 @@ searchdir (ino_t dir, char *name, ino_t *ino) NAME. Return 1 if we should keep looking at more blocks. */ int - checkdirblock (daddr_t bno, int nfrags) + checkdirblock (daddr_t bno, int nfrags, off_t offset) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; - bufp - buf < nfrags * sblock->fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize + && offset + (bufp - buf) + DIRBLKSIZ <= dino.di_size; bufp += DIRBLKSIZ) { check1block (bufp); @@ -199,14 +200,15 @@ changeino (ino_t dir, char *name, ino_t ino) contains NAME. Return 1 if we should keep looking at more blocks. */ int - checkdirblock (daddr_t bno, int nfrags) + checkdirblock (daddr_t bno, int nfrags, off_t offset) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; - bufp - buf < nfrags * sblock->fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize + && offset + (bufp - buf) + DIRBLKSIZ <= dino.di_size; bufp += DIRBLKSIZ) { if (check1block (bufp)) @@ -328,14 +330,15 @@ makeentry (ino_t dir, ino_t ino, char *name) contains NAME. Return 1 if we should keep looking at more blocks. */ int - checkdirblock (daddr_t bno, int nfrags) + checkdirblock (daddr_t bno, int nfrags, off_t offset) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; - bufp - buf < nfrags * sblock->fs_fsize; + bufp - buf < nfrags * sblock->fs_fsize + && offset + (bufp - buf) + DIRBLKSIZ <= dino.di_size; bufp += DIRBLKSIZ) { if (check1block (bufp)) -- cgit v1.2.3 From fe6042be593748cb951706994491fd6f582ab19e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 00:34:14 +0000 Subject: entered into RCS --- ufs-fsck/fsck.h | 19 ++++++++----------- ufs-fsck/pass1b.c | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 2c72d46f..ca8f2dfd 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -30,19 +30,16 @@ #include "../ufs/dir.h" /* Type of an inode */ -enum inodetype -{ - UNALLOC, /* not allocated */ - REG, /* allocated, not dir */ - DIRECTORY, /* dir */ - BADDIR, /* dir with bad block pointers */ -}; +#define UNALLOC 0 +#define REG 1 +#define DIRECTORY 2 +#define BADDIR 3 /* Added to directories in pass 2 */ -#define DIR_REF 0x80000000 /* dir has been found in connectivity search */ +#define DIR_REF 4 /* dir has been found in connectivity search */ /* State of each inode (set by pass 1) */ -enum inodetype *inodestate; +char *inodestate; /* Number of links claimed by each inode (set by pass 1) */ nlink_t *linkcount; @@ -160,8 +157,8 @@ int changeino (ino_t, char *, ino_t); int linkup (ino_t, ino_t); -void datablocks_iterate (struct dinode *, int (*)(daddr_t, int)); -void allblock_iterate (struct dinode *, int (*)(daddr_t, int)); +void datablocks_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); +void allblock_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); void record_directory (struct dinode *, ino_t); diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index ac6c299f..50973eae 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -35,7 +35,7 @@ pass1b () Return RET_GOOD or RET_BAD if the block is good or bad, respectively. */ int - checkblock (daddr_t bno, int nfrags) + checkblock (daddr_t bno, int nfrags, off_t offset) { struct dups *dlp; int hadbad = 0; -- cgit v1.2.3 From 40e6645d8569fe44b40c32daac68570e1b198ef9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 00:38:01 +0000 Subject: Formerly inode.c.~4~ --- ufs-fsck/inode.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index 5cf8e279..c10906ff 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -22,11 +22,12 @@ static void inode_iterate (struct dinode *dp, - int (*fn) (daddr_t, int), + int (*fn) (daddr_t, int, off_t), int doaddrblocks) { mode_t mode = dp->di_model & IFMT; int nb, maxb; + off_t totaloffset = 0; /* Call FN for iblock IBLOCK of level LEVEL and recurse down the indirect block pointers. */ @@ -39,7 +40,7 @@ inode_iterate (struct dinode *dp, if (doaddrblocks) { - cont = (*fn)(iblock, sblock->fs_frag); + cont = (*fn)(iblock, sblock->fs_frag, totaloffset); if (cont == RET_STOP) return RET_STOP; else if (cont == RET_BAD) @@ -50,7 +51,10 @@ inode_iterate (struct dinode *dp, for (i = 0; i < NINDIR (sblock); i++) { if (level == 0) - cont = (*fn)(ptrs[i], sblock->fs_frag); + { + cont = (*fn)(ptrs[i], sblock->fs_frag, totaloffset); + totaloffset += sblock->fs_bsize; + } else cont = scaniblock (ptrs[i], level - 1); if (cont == RET_STOP) @@ -65,7 +69,8 @@ inode_iterate (struct dinode *dp, || (sblock->fs_maxsymlinklen == 0 && dp->di_blocks == 0)))) return; - maxb = howmany (dp->di_size, sblock->fs_bsize); + maxb = lblkno (sblock, dp->di_size - 1); + totaloffset = 0; for (nb = 0; nb < NDADDR; nb++) { int offset; @@ -76,8 +81,10 @@ inode_iterate (struct dinode *dp, else nfrags = sblock->fs_frag; - if (dp->di_db[nb] && (*fn)(dp->di_db[nb], nfrags) != RET_GOOD) + if (dp->di_db[nb] + && (*fn)(dp->di_db[nb], nfrags, totaloffset) != RET_GOOD) return; + totaloffset += nfrags * sizeof (sblock->fs_fsize); } for (nb = 0; nb < NIADDR; nb++) @@ -85,19 +92,19 @@ inode_iterate (struct dinode *dp, return; if (doaddrblocks && dp->di_trans) - (*fn)(dp->di_trans, sblock->fs_frag); + (*fn)(dp->di_trans, sblock->fs_frag, totaloffset); } void datablocks_iterate (struct dinode *dp, - int (*fn) (daddr_t, int)) + int (*fn) (daddr_t, int, off_t)) { inode_iterate (dp, fn, 0); } void allblock_iterate (struct dinode *dp, - int (*fn) (daddr_t, int)) + int (*fn) (daddr_t, int, off_t)) { inode_iterate (dp, fn, 1); } @@ -154,7 +161,7 @@ freeino (ino_t inum) struct dinode dino; int - clearblock (daddr_t bno, int nfrags) + clearblock (daddr_t bno, int nfrags, off_t offset) { int i; -- cgit v1.2.3 From d9a476c467a9dd9e5a7b24668fd62e6656f35f8d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 17:00:11 +0000 Subject: entered into RCS --- ufs-fsck/pass1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 49200337..621d40ec 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -161,7 +161,7 @@ pass1 () for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++) for (i = 0; i < sblock->fs_ipg; i++, number++) { - if (!(number % 1000)) + if (!(number % 10000)) printf ("I=%d\n", number); if (number < ROOTINO) -- cgit v1.2.3 From e6fe942584d3e678b28dab10ba3eeb78b4d87c3d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 17:11:40 +0000 Subject: Formerly dir.c.~7~ --- ufs-fsck/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 0a0c0ac2..c8ad46ed 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -38,7 +38,7 @@ record_directory (struct dinode *dp, ino_t number) dnp->i_number = number; dnp->i_parent = dnp->i_dotdot = 0; dnp->i_isize = dp->di_size; - dnp->i_numblks = blks * sizeof (daddr_t); + dnp->i_numblks = blks; bcopy (dp->di_db, dnp->i_blks, blks); if (dirarrayused == dirarraysize) @@ -392,7 +392,7 @@ allocdir (ino_t parent, ino_t request, mode_t mode) return 0; if (!makeentry (ino, ino, ".")) goto bad; - if (!makeentry (ino, ino, "..")) + if (!makeentry (ino, parent, "..")) goto bad; linkfound[ino]++; -- cgit v1.2.3 From 3aa84bd05022da72bbca8c3bf0f791471101d7ce Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 17:12:59 +0000 Subject: Formerly utilities.c.~8~ --- ufs-fsck/utilities.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index f66204f9..3914bf9c 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -184,6 +184,7 @@ errexit (char *fmt, ...) va_start (args, fmt); vprintf (fmt, args); va_end (args); + putchar ('\n'); exit (1); } -- cgit v1.2.3 From 97c1681126488c74142e41800b7f53677ec8ee4c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 17:21:17 +0000 Subject: Formerly pass5.c.~6~ --- ufs-fsck/pass5.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index c2c94a5b..e3547da1 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -233,6 +233,10 @@ pass5 () case REG: newcg->cg_cs.cs_nifree--; setbit (cg_inosused (newcg), i); + /* Fall through... */ + case UNALLOC: + break; + default: errexit ("UNKNOWN STATE I=%d", i); } -- cgit v1.2.3 From 5b2b513c953ed9953de9304b0df4b4b7f96930c4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 18:26:04 +0000 Subject: entered into RCS --- ufs-utils/mkfs.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index b92ea346..7246505b 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.5 1994/10/12 16:58:58 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.6 1994/10/18 18:26:04 mib Exp $"; #endif /* not lint */ #include @@ -47,6 +47,7 @@ static char *rcsid = "$Id: mkfs.c,v 1.5 1994/10/12 16:58:58 mib Exp $"; /* #include */ #include #include +#include /* Begin misc additions for GNU Hurd */ @@ -56,11 +57,11 @@ static char *rcsid = "$Id: mkfs.c,v 1.5 1994/10/12 16:58:58 mib Exp $"; #if (BYTE_ORDER == LITTLE_ENDIAN) #define DIRSIZ(oldfmt, dp) \ ((oldfmt) ? \ - ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ - ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) + ((sizeof (struct directory_entry) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ + ((sizeof (struct directory_entry) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) #else #define DIRSIZ(oldfmt, dp) \ - ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) + ((sizeof (struct directory_entry) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) #endif #define NBBY 8 @@ -251,7 +252,7 @@ main (int argc, char **argv) opt = DEFAULTOPT ; density = 4 * fsize; /* maxcontig = MAX (1, MIN (MAXPHYS, MAXBSIZE) / bsize - 1); */ - makcontig = 0; + maxcontig = 0; rotdelay = 4; #define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) maxbpg = MAXBLKPG (bsize); @@ -945,34 +946,34 @@ struct dinode node; #define PREDEFDIR 2 #endif -struct direct root_dir[] = { - { ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, +struct directory_entry root_dir[] = { + { ROOTINO, sizeof(struct directory_entry), DT_DIR, 1, "." }, + { ROOTINO, sizeof(struct directory_entry), DT_DIR, 2, ".." }, #ifdef LOSTDIR - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found" }, + { LOSTFOUNDINO, sizeof(struct directory_entry), DT_DIR, 10, "lost+found" }, #endif }; -struct odirect { +struct odirectory_entry { u_long d_ino; u_short d_reclen; u_short d_namlen; u_char d_name[MAXNAMLEN + 1]; } oroot_dir[] = { - { ROOTINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, + { ROOTINO, sizeof(struct directory_entry), 1, "." }, + { ROOTINO, sizeof(struct directory_entry), 2, ".." }, #ifdef LOSTDIR - { LOSTFOUNDINO, sizeof(struct direct), 10, "lost+found" }, + { LOSTFOUNDINO, sizeof(struct directory_entry), 10, "lost+found" }, #endif }; #ifdef LOSTDIR -struct direct lost_found_dir[] = { - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, +struct directory_entry lost_found_dir[] = { + { LOSTFOUNDINO, sizeof(struct directory_entry), DT_DIR, 1, "." }, + { ROOTINO, sizeof(struct directory_entry), DT_DIR, 2, ".." }, { 0, DIRBLKSIZ, 0, 0, 0 }, }; -struct odirect olost_found_dir[] = { - { LOSTFOUNDINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, +struct odirectory_entry olost_found_dir[] = { + { LOSTFOUNDINO, sizeof(struct directory_entry), 1, "." }, + { ROOTINO, sizeof(struct directory_entry), 2, ".." }, { 0, DIRBLKSIZ, 0, 0 }, }; #endif @@ -994,7 +995,7 @@ fsinit(utime) * create the lost+found directory */ if (Oflag) { - (void)makedir((struct direct *)olost_found_dir, 2); + (void)makedir((struct directory_entry *)olost_found_dir, 2); for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ) bcopy(&olost_found_dir[2], &buf[i], DIRSIZ(0, &olost_found_dir[2])); @@ -1023,7 +1024,7 @@ fsinit(utime) node.di_modeh = 0; node.di_nlink = PREDEFDIR; if (Oflag) - node.di_size = makedir((struct direct *)oroot_dir, PREDEFDIR); + node.di_size = makedir((struct directory_entry *)oroot_dir, PREDEFDIR); else node.di_size = makedir(root_dir, PREDEFDIR); node.di_db[0] = alloc(sblock.fs_fsize, DI_MODE (&node)); @@ -1037,7 +1038,7 @@ fsinit(utime) * return size of directory. */ makedir(protodir, entries) - register struct direct *protodir; + register struct directory_entry *protodir; int entries; { char *cp; -- cgit v1.2.3 From f38cdf24f1f65e1e1ec8ac403f850d0217fff7a7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 18 Oct 1994 18:26:16 +0000 Subject: Formerly pass5.c.~7~ --- ufs-fsck/pass5.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index e3547da1..84c37285 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -221,9 +221,11 @@ pass5 () /* Walk through each inode, accounting for it in the inode map and in newcg->cg_cs. */ + /* In this loop, J is the inode number, and I is the + inode number relative to this CG. */ j = sblock->fs_ipg * c; for (i = 0; i < sblock->fs_ipg; j++, i++) - switch (inodestate[i]) + switch (inodestate[j]) { case DIRECTORY: case DIRECTORY | DIR_REF: @@ -238,7 +240,7 @@ pass5 () break; default: - errexit ("UNKNOWN STATE I=%d", i); + errexit ("UNKNOWN STATE I=%d", j); } /* Account for inodes 0 and 1 */ if (c == 0) @@ -250,6 +252,8 @@ pass5 () /* Walk through each data block, accounting for it in the block map and in newcg->cg_cs. */ + /* In this look, D is the block number and I is the + block number relative to this CG. */ for (i = 0, d = dbase; d < dmax; d += sblock->fs_frag, i += sblock->fs_frag) -- cgit v1.2.3 From e543e20420ef268692133fef6722d640a9cd55e6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 19 Oct 1994 18:01:25 +0000 Subject: entered into RCS --- ufs-fsck/utilities.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 3914bf9c..e8475506 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -42,7 +42,7 @@ writeblock (daddr_t addr, void *buf, size_t size) if (lseek (writefd, addr * DEV_BSIZE, L_SET) == -1) errexit ("CANNOT SEEK TO BLOCK %ld", addr); if (write (writefd, buf, size) != size) - errexit ("CANNOT READ BLOCK %ld", addr); + errexit ("CANNOT WRITE BLOCK %ld", addr); fsmodified = 1; } -- cgit v1.2.3 From e64d292339af9468d089cf41bba2c273c118c7a7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 19 Oct 1994 18:02:27 +0000 Subject: Formerly pass5.c.~8~ --- ufs-fsck/pass5.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 84c37285..4a045e7f 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -69,7 +69,7 @@ pass5 () int c; daddr_t d; struct cg *cg = alloca (sblock->fs_cgsize); - char csumbuf[fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)]; + char csumbuf[fragroundup (sblock, sblock->fs_cssize)]; struct csum *sbcsums = (struct csum *)csumbuf; int basesize; /* size of cg not counting flexibly sized */ @@ -84,7 +84,7 @@ pass5 () writecsum = 0; readblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, - fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)); + fragroundup (sblock, sblock->fs_cssize)); /* Construct a CG structure; initialize everything that's the same in each cylinder group. */ @@ -375,5 +375,6 @@ pass5 () writeblock (SBLOCK, &sblock, SBSIZE); if (writecsum) writeblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, - fragroundup (sblock, sizeof (struct csum) * sblock->fs_ncg)); + fragroundup (sblock, sblock->fs_cssize)); + } -- cgit v1.2.3 From a228ad7ad2766a016dec2b7c426ac08f29a86035 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 20 Oct 1994 16:45:02 +0000 Subject: Formerly pass5.c.~9~ --- ufs-fsck/pass5.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 4a045e7f..323ae48e 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -60,17 +60,14 @@ ffs_fragacct(fs, fragmap, fraglist, cnt) void pass5 () { - char cgbuf[sblock->fs_cgsize]; - struct cg *newcg = (struct cg *)cgbuf; - struct ocg *ocg = (struct ocg *)cgbuf; + struct cg *newcg, *cg; + struct ocg *newocg; int savednrpos = 0; struct csum cstotal; int i, j; int c; daddr_t d; - struct cg *cg = alloca (sblock->fs_cgsize); - char csumbuf[fragroundup (sblock, sblock->fs_cssize)]; - struct csum *sbcsums = (struct csum *)csumbuf; + struct csum *sbcsums; int basesize; /* size of cg not counting flexibly sized */ int sumsize; /* size of block totals and pos tbl */ @@ -83,7 +80,14 @@ pass5 () writesb = 0; writecsum = 0; - readblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, + cg = alloca (sblock->fs_cgsize); + + newcg = alloca (sblock->fs_cgsize); + newocg = (struct ocg *)newcg; + + sbcsums = alloca (fragroundup (sblock, sblock->fs_cssize)); + + readblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, fragroundup (sblock, sblock->fs_cssize)); /* Construct a CG structure; initialize everything that's the same @@ -94,10 +98,10 @@ pass5 () { case FS_42POSTBLFMT: /* Initialize size information */ - basesize = (char *)(&ocg->cg_btot[0]) - (char *)(&ocg->cg_link); - sumsize = &ocg->cg_iused[0] - (char *)(&ocg->cg_btot[0]); - mapsize = (&ocg->cg_free[howmany(sblock->fs_fpg, NBBY)] - - (u_char *)&ocg->cg_iused[0]); + basesize = (char *)(&newocg->cg_btot[0]) - (char *)(&newocg->cg_link); + sumsize = &newocg->cg_iused[0] - (char *)(&newocg->cg_btot[0]); + mapsize = (&newocg->cg_free[howmany(sblock->fs_fpg, NBBY)] + - (u_char *)&newocg->cg_iused[0]); savednrpos = sblock->fs_nrpos; sblock->fs_nrpos = 8; break; @@ -217,7 +221,7 @@ pass5 () bzero (&newcg->cg_frsum[0], sizeof newcg->cg_frsum); bzero (&cg_blktot (newcg)[0], sumsize + mapsize); if (sblock->fs_postblformat == FS_42POSTBLFMT) - ocg->cg_magic = CG_MAGIC; + newocg->cg_magic = CG_MAGIC; /* Walk through each inode, accounting for it in the inode map and in newcg->cg_cs. */ @@ -374,7 +378,16 @@ pass5 () if (writesb) writeblock (SBLOCK, &sblock, SBSIZE); if (writecsum) - writeblock (fsbtodb (sblock, sblock->fs_csaddr), csumbuf, - fragroundup (sblock, sblock->fs_cssize)); + { + struct csum *test; + + writeblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, + fragroundup (sblock, sblock->fs_cssize)); + test = alloca (fragroundup (sblock, sblock->fs_cssize)); + readblock (fsbtodb (sblock, sblock->fs_csaddr), test, + fragroundup (sblock, sblock->fs_cssize)); + if (bcmp (test, sbcsums, fragroundup (sblock, sblock->fs_cssize))) + printf ("CSUM write inconsistent"); + } } -- cgit v1.2.3 From 436101b13c694b042a7b751278c7325790160db4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 20 Oct 1994 16:57:52 +0000 Subject: Formerly setup.c.~6~ --- ufs-fsck/setup.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index 10521ce1..a4c65bc0 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -47,24 +47,27 @@ setup (char *dev) if (!reply ("CONTINUE")) return 0; } - readfd = open (dev, O_RDONLY); - if (readfd == -1) - { - perror (dev); - return 0; - } if (preen == 0) printf ("** %s", dev); - if (nowrite) - writefd = -1; - else - writefd = open (dev, O_WRONLY); - if (nowrite || writefd == -1) + if (!nflag) + readfd = open (dev, O_RDWR); + if (nflag || readfd == -1) { + readfd = open (dev, O_RDONLY); + if (readfd == -1) + { + perror (dev); + return 0; + } + writefd = -1; + nflag = 1; if (preen) pfatal ("NO WRITE ACCESS"); printf (" (NO WRITE)"); } + else + writefd = readfd; + if (preen == 0) printf ("\n"); -- cgit v1.2.3 From 7f9033632b20aa8b0fd17dca3cbf74a52b6b287e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 03:37:12 +0000 Subject: entered into RCS --- ufs-fsck/inode.c | 3 +++ ufs-fsck/setup.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index c10906ff..afb8b1a4 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -50,6 +50,9 @@ inode_iterate (struct dinode *dp, readblock (fsbtodb (sblock, iblock), ptrs, sblock->fs_bsize); for (i = 0; i < NINDIR (sblock); i++) { + if (!ptrs[i]) + continue; + if (level == 0) { cont = (*fn)(ptrs[i], sblock->fs_frag, totaloffset); diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index a4c65bc0..f3faf07d 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -49,9 +49,9 @@ setup (char *dev) } if (preen == 0) printf ("** %s", dev); - if (!nflag) + if (!nowrite) readfd = open (dev, O_RDWR); - if (nflag || readfd == -1) + if (nowrite || readfd == -1) { readfd = open (dev, O_RDONLY); if (readfd == -1) @@ -60,7 +60,7 @@ setup (char *dev) return 0; } writefd = -1; - nflag = 1; + nowrite = 1; if (preen) pfatal ("NO WRITE ACCESS"); printf (" (NO WRITE)"); -- cgit v1.2.3 From 7843a2ecd03eb2fad0d4e2ed6bad695bae4fd7b2 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 15:50:51 +0000 Subject: Formerly pass2.c.~10~ --- ufs-fsck/pass2.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index a04b475e..e300501a 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -163,14 +163,36 @@ pass2 () /* Account for the inode in the linkfound map */ if (inodestate[dp->d_ino] != UNALLOC) linkfound[dp->d_ino]++; - - /* If this is `.' or `..' then note the value for - later examination. */ - if (dp->d_namlen == 1 && dp->d_name[0] == '.') - dnp->i_dot = dp->d_ino; - if (dp->d_namlen == 2 - && dp->d_name[0] == '.' && dp->d_name[1] == '.') - dnp->i_dotdot = dp->d_ino; + + if (inodestate[dp->d_ino] == DIRECTORY + || inodestate[dp->d_ino] == BADDIR) + { + if (dp->d_namlen == 1 && dp->d_name[0] == '.') + dnp->i_dot = dp->d_ino; + else if (dp->d_namlen == 2 + && dp->d_name[0] == '.' && dp->d_name[1] == '.') + dnp->i_dotdot = dp->d_ino; + else + { + struct dirinfo *targetdir; + targetdir = lookup_directory (dp->d_ino); + if (targetdir->i_parent) + { + printf ("EXTRANEOUS LINK %s TO DIR I=%ld", dp->d_name, + dp->d_ino); + pwarn ("FOUND IN DIR I=%d", dnp->i_number); + if (preen || reply ("REMOVE")) + { + if (preen) + printf (" (REMOVED)"); + dp->d_ino = 0; + mod = 1; + } + } + else + targetdir->i_parent = dnp->i_number; + } + } } return mod; } -- cgit v1.2.3 From f284e2db9fd5ffa61a4e3f008ee43a099d3bcf6c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 16:12:58 +0000 Subject: entered into RCS --- ufs-fsck/pass5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 323ae48e..dccd2140 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -376,7 +376,8 @@ pass5 () } if (writesb) - writeblock (SBLOCK, &sblock, SBSIZE); + writeblock (SBLOCK, sblock, SBSIZE); + if (writecsum) { struct csum *test; -- cgit v1.2.3 From 59fe81bbe11821d0c0f70e3caecb6164437d7ae5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 16:54:36 +0000 Subject: entered into RCS --- ufs/alloc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ufs/alloc.c b/ufs/alloc.c index 4464dfa0..b82d6065 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -817,6 +817,9 @@ ffs_fragextend(struct node *np, fs->fs_cstotal.cs_nffree--; csum[cg].cs_nffree--; } + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; fs->fs_fmod = 1; /* bdwrite(bp); */ return (bprev); @@ -892,6 +895,10 @@ ffs_alloccg(struct node *np, csum[cg].cs_nffree += i; fs->fs_fmod = 1; cgp->cg_frsum[i]++; + + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; /* bdwrite(bp); */ return (bno); } @@ -909,6 +916,9 @@ ffs_alloccg(struct node *np, cgp->cg_frsum[allocsiz]--; if (frags != allocsiz) cgp->cg_frsum[allocsiz - frags]++; + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; /* bdwrite(bp); */ return (cg * fs->fs_fpg + bno); } @@ -1020,6 +1030,9 @@ gotit: cg_blks(fs, cgp, cylno)[cbtorpos(fs, bno)]--; cg_blktot(cgp)[cylno]--; fs->fs_fmod = 1; + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; return (cgp->cg_cgx * fs->fs_fpg + bno); } @@ -1188,6 +1201,9 @@ gotit: fs->fs_cstotal.cs_ndir++; csum[cg].cs_ndir++; } + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; /* bdwrite(bp); */ return (cg * fs->fs_ipg + ipref); } @@ -1285,6 +1301,9 @@ ffs_blkfree(register struct node *np, cg_blktot(cgp)[i]++; } } + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; fs->fs_fmod = 1; /* bdwrite(bp); */ } @@ -1340,6 +1359,9 @@ diskfs_free_node (struct node *np, mode_t mode) fs->fs_cstotal.cs_ndir--; csum[cg].cs_ndir--; } + record_poke (cgp, sblock->fs_cgsize); + csum_dirty = 1; + sblock_dirty = 1; fs->fs_fmod = 1; /* bdwrite(bp); */ } -- cgit v1.2.3 From ca358f9be145942c38d645f0bca24e5637794962 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 19:06:32 +0000 Subject: Formerly hyper.c.~15~ --- ufs/hyper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index e73f78b8..5e9eb12f 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -123,7 +123,9 @@ copy_sblock () if (csum_dirty) { bcopy (csum, disk_image + fsaddr (sblock, sblock->fs_csaddr), - fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); + fragroundup (sblock, sblock->fs_cssize)); + record_poke (disk_image + fsaddr (sblock, sblock->fs_csaddr), + fragroundup (sblock, sblock->fs_cssize)); csum_dirty = 0; } @@ -153,6 +155,7 @@ copy_sblock () } else bcopy (sblock, disk_image + SBOFF, SBSIZE); + record_poke (disk_image + SBOFF, SBSIZE); sblock_dirty = 0; } -- cgit v1.2.3 From d30575770a161a35dab5a58fa7102a11ed4c5064 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 19:35:24 +0000 Subject: Formerly dir.c.~8~ --- ufs-fsck/dir.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index c8ad46ed..f99a290d 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -63,6 +63,19 @@ record_directory (struct dinode *dp, ino_t number) dirarrayused++; } +/* Return the cached dirinfo structure for directory INO. */ +struct dirinfo * +lookup_directory (ino_t ino) +{ + int i; + + for (i = 0; i < dirarrayused; i++) + if (dirarray[i]->i_number == ino) + return dirarray[i]; + + errexit ("Cannot find chached directory I=%d\n", ino); +} + /* Check to see if DIR is really a readable directory; if it isn't, then bail with an appropriate message and return 0; else return 1. MSG identifies the action contemplated */ @@ -386,6 +399,8 @@ ino_t allocdir (ino_t parent, ino_t request, mode_t mode) { ino_t ino; + + mode |= IFDIR; ino = allocino (request, mode); if (!ino) -- cgit v1.2.3 From 6968b16f1bb86a90b525636987501c7094d070d3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 25 Oct 1994 19:48:58 +0000 Subject: Formerly pager.c.~41~ --- ufs/pager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index fd148d8d..73f1b5d7 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -546,6 +546,7 @@ diskfs_shutdown_pager () pager_shutdown (p->p); } + copy_sblock (); write_all_disknodes (); pager_traverse (shutdown_one); } @@ -562,6 +563,7 @@ diskfs_sync_everything (int wait) sync_disk (wait); } + copy_sblock (); write_all_disknodes (); pager_traverse (sync_one); } -- cgit v1.2.3 From 28cd2c87c77fe466592f265bcb22601f747e28c0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 28 Oct 1994 00:58:57 +0000 Subject: entered into RCS --- ufs/sizes.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 7225a851..bf9e2c38 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -103,8 +103,6 @@ diskfs_truncate (struct node *np, pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np); - mach_port_insert_right (mach_task_self (), obj, obj, - MACH_MSG_TYPE_MAKE_SEND); poke_pages (obj, round_page (length), round_page (np->allocsize)); mach_port_deallocate (mach_task_self (), obj); pager_flush_some (upi->p, round_page (length), @@ -587,8 +585,6 @@ diskfs_grow (struct node *np, mach_port_t obj; obj = diskfs_get_filemap (np); - mach_port_insert_right (mach_task_self (), obj, obj, - MACH_MSG_TYPE_MAKE_SEND); poke_pages (obj, trunc_page (poke_off), round_page (poke_off + poke_len)); mach_port_deallocate (mach_task_self (), obj); -- cgit v1.2.3 From 1e025ef8df752af1c26ababf60ff96ed38d599d1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 28 Oct 1994 01:15:47 +0000 Subject: entered into RCS --- ufs/dir.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 2f215974..83eae80d 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -129,8 +129,6 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, /* Map in the directory contents. */ memobj = diskfs_get_filemap (dp); - mach_port_insert_right (mach_task_self (), memobj, memobj, - MACH_MSG_TYPE_MAKE_SEND); buf = 0; /* We allow extra space in case we have to do an EXTEND. */ buflen = round_page (dp->dn_stat.st_size + DIRBLKSIZ); @@ -655,8 +653,6 @@ diskfs_dirempty(struct node *dp, error_t err; memobj = diskfs_get_filemap (dp); - mach_port_insert_right (mach_task_self (), memobj, memobj, - MACH_MSG_TYPE_MAKE_SEND); buf = 0; err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, -- cgit v1.2.3 From 50e3959d6d8fa7ade5f82ea85c6f65777eee0f5f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 28 Oct 1994 22:23:22 +0000 Subject: entered into RCS --- ufs/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 7fcfa43b..4c617193 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -163,14 +163,14 @@ main (int argc, char **argv) get_hypermetadata (); if (diskpagersize < sblock->fs_size * sblock->fs_fsize) - { - fprintf (stderr, - "Disk size (%d) less than necessary " - "(superblock says we need %ld)\n", - sizes[DEV_GET_SIZE_DEVICE_SIZE], - sblock->fs_size * sblock->fs_fsize); - exit (1); - } + { + fprintf (stderr, + "Disk size (%d) less than necessary " + "(superblock says we need %ld)\n", + sizes[DEV_GET_SIZE_DEVICE_SIZE], + sblock->fs_size * sblock->fs_fsize); + exit (1); + } vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); -- cgit v1.2.3 From 95ad36aca16849157dc8281f096e4c539b511a96 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 2 Nov 1994 19:40:42 +0000 Subject: entered into RCS --- ufs-fsck/dir.c | 7 ++++--- ufs-fsck/pass2.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index f99a290d..dc1f1dda 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -128,7 +128,7 @@ searchdir (ino_t dir, char *name, ino_t *ino) return; if (dp->d_ino == 0 || dp->d_ino > maxino) continue; - if (dp->d_namlen != len) + if (DIRECT_NAMLEN (dp) != len) continue; if (!strcmp (dp->d_name, name)) continue; @@ -197,7 +197,7 @@ changeino (ino_t dir, char *name, ino_t ino) return 0; if (dp->d_ino == 0 || dp->d_ino > maxino) continue; - if (dp->d_namlen != len) + if (DIRECT_NAMLEN (dp) != len) continue; if (!strcmp (dp->d_name, name)) continue; @@ -308,7 +308,8 @@ makeentry (ino_t dir, ino_t ino, char *name) if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) return 0; - if (dp->d_ino && dp->d_reclen - DIRSIZ (dp->d_namlen) >= needed) + if (dp->d_ino + && dp->d_reclen - DIRSIZ (DIRECT_NAMLEN (dp)) >= needed) { struct directory_entry *newdp; newdp = (struct directory_entry *) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index e300501a..6f508074 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -117,7 +117,7 @@ pass2 () else { /* Check for illegal characters */ - for (i = 0; i < dp->d_namlen; i++) + for (i = 0; i < DIRECT_NAMLEN (dp); i++) if (dp->d_name[i] == '\0' || dp->d_name[i] == '/') { pfatal ("ILLEGAL CHARACTER IN FILE NAME"); @@ -129,7 +129,7 @@ pass2 () break; } } - if (dp->d_name[dp->d_namlen]) + if (dp->d_name[DIRECT_NAMLEN (dp)]) { pfatal ("DIRECTORY NAME NOT TERMINATED"); if (reply ("SALVAGE")) @@ -167,9 +167,9 @@ pass2 () if (inodestate[dp->d_ino] == DIRECTORY || inodestate[dp->d_ino] == BADDIR) { - if (dp->d_namlen == 1 && dp->d_name[0] == '.') + if (DIRECT_NAMLEN (dp) == 1 && dp->d_name[0] == '.') dnp->i_dot = dp->d_ino; - else if (dp->d_namlen == 2 + else if (DIRECT_NAMLEN (dp) == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.') dnp->i_dotdot = dp->d_ino; else -- cgit v1.2.3 From b20e126405a6679ed645df02f6d12d0e932a7b93 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 2 Nov 1994 21:08:19 +0000 Subject: entered into RCS --- ufs/hyper.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 5e9eb12f..1317e8b6 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -105,13 +105,24 @@ get_hypermetadata (void) diskfs_end_catch_exception (); } -/* We don't need this callback; all our data is backed by pagers. */ +/* Write the csum data. This isn't backed by a pager because it is + taken from ordinary data blocks and might not be an even number + of pages; in that case writing it through the pager would nuke whatever + pages came after it on the disk and were backed by file pagers. */ void diskfs_set_hypermetadata (int wait, int clean) { + spin_lock (&alloclock); + if (csum_dirty) + (wait ? dev_write_sync : dev_write) (fsbtodb (sblock, sblock->fs_csaddr), + (vm_address_t) csum, + fragroundup (sblock, + sblock->fs_cssize)); + csum_dirty = 0; + spin_unlock (&alloclock); } -/* Copy the sblock and csum into the disk */ +/* Copy the sblock into the disk */ void copy_sblock () { @@ -120,14 +131,6 @@ copy_sblock () assert (!diskfs_catch_exception ()); spin_lock (&alloclock); - if (csum_dirty) - { - bcopy (csum, disk_image + fsaddr (sblock, sblock->fs_csaddr), - fragroundup (sblock, sblock->fs_cssize)); - record_poke (disk_image + fsaddr (sblock, sblock->fs_csaddr), - fragroundup (sblock, sblock->fs_cssize)); - csum_dirty = 0; - } if (clean && !diskfs_readonly) { -- cgit v1.2.3 From ab70d0204f45f42f76ec3505517055108b61af58 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 3 Nov 1994 22:19:05 +0000 Subject: entered into RCS --- bsdfsck/Makefile | 4 ++-- ufs-fsck/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index bc718b66..28adbbd1 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -dir := fsck +dir := bsdfsck makemode := utility SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ @@ -23,7 +23,7 @@ SRCS = dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ pass5.o setup.o utilities.o tables.o # preen.o LCLHDRS = fsck.h -target = fsck +target = bsdfsck include ../Makeconf diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 75b2207a..ef8919a9 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -18,14 +18,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -dir := newfsck +dir := fsck makemode := utility SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c inode.c OBJS = $(subst .c,.o,$(SRCS)) tables.o LCLHDRS = fsck.h -target = newfsck +target = fsck include ../Makeconf -- cgit v1.2.3 From 7f849d2f7fb1b61d18dcfe7e3167b54b27a511af Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 4 Nov 1994 21:54:56 +0000 Subject: entered into RCS --- bsdfsck/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c index 28697827..e63473ae 100644 --- a/bsdfsck/dir.c +++ b/bsdfsck/dir.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: dir.c,v 1.4 1994/10/07 23:37:52 mib Exp $"; +static char *rcsid = "$Id: dir.c,v 1.5 1994/11/04 21:54:56 mib Exp $"; #endif /* not lint */ #include @@ -586,7 +586,7 @@ allocdir(parent, request, mode) { ino_t ino; char *cp; - + struct dinode *dp; register struct bufarea *bp; struct dirtemplate *dirp; -- cgit v1.2.3 From 88129f99b2e25f38cb7be3f8f50494842b853309 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 8 Nov 1994 05:04:32 +0000 Subject: entered into RCS --- ufs/pager.c | 2 +- ufs/ufs.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index 73f1b5d7..d41b792d 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -152,7 +152,7 @@ pager_write_page (struct user_pager_info *pager, else { printf ("Attempt to write unallocated disk\n."); - printf ("Object %#x\tOffset %#x\n", pager, page); + printf ("Object %p\tOffset %#x\n", pager, page); fflush (stdout); err = 0; /* unallocated disk; error would be pointless */ diff --git a/ufs/ufs.h b/ufs/ufs.h index 3301e703..a7c9a891 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -270,6 +270,7 @@ error_t dev_read_sync (daddr_t addr, vm_address_t *data, long len); /* From hyper.c: */ void get_hypermetadata (void); +void copy_sblock (void); /* From inode.c: */ error_t iget (ino_t ino, struct node **NP); -- cgit v1.2.3 From 55c48df54aee12d4520fe1a024b7da1a233d93c3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 8 Nov 1994 19:27:56 +0000 Subject: (CCVERSION): Upgrade default to version 2.6.2. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 4679b119..9ce48964 100644 --- a/=Maketools +++ b/=Maketools @@ -14,7 +14,7 @@ mighost := ernst.gnu.ai.mit.edu # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). CCTARGET=i386-gnu -CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.0) +CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.2) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 -- cgit v1.2.3 From 9aaa8d2a028e054848cfe1e244f6a32b4e225d09 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 9 Nov 1994 10:43:07 +0000 Subject: (main): Behave more reasonably if we can't open DEVNAME. --- ufs/main.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 4c617193..0e6bd19d 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -129,10 +129,32 @@ main (int argc, char **argv) any other diskfs call. */ diskfs_init_diskfs (); - err = device_open (diskfs_master_device, - (diskfs_readonly ? 0 : D_WRITE) | D_READ, - devname, &ufs_device); - assert (!err); + do + { + char *line = 0; + size_t linesz = 0; + ssize_t len; + + err = device_open (diskfs_master_device, + (diskfs_readonly ? 0 : D_WRITE) | D_READ, + devname, &ufs_device); + if (err == D_NO_SUCH_DEVICE && getpid () <= 0) + { + /* Prompt the user to give us another name rather + than just crashing */ + printf ("Cannot open device %s\n", devname); + len = getline (&line, &linesz, stdin); + if (len > 2) + devname = line; + } + } + while (err && err == D_NO_SUCH_DEVICE && getpid () <= 0); + + if (err) + { + perror (devname); + exit (1); + } /* Check to make sure device sector size is reasonable. */ err = device_get_status (ufs_device, DEV_GET_SIZE, sizes, &sizescnt); -- cgit v1.2.3 From a7cb22de8543981acf8101cc70cc4b14c4742242 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Nov 1994 18:27:05 +0000 Subject: (diskfs_set_hypermetadata): Copy CSUM into a page-aligned page-sized buffer for disk write to avoid inane kernel bug. --- ufs/hyper.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 1317e8b6..9f8bd8d5 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -112,13 +112,31 @@ get_hypermetadata (void) void diskfs_set_hypermetadata (int wait, int clean) { + vm_address_t buf; + vm_size_t bufsize; + error_t err; + spin_lock (&alloclock); - if (csum_dirty) - (wait ? dev_write_sync : dev_write) (fsbtodb (sblock, sblock->fs_csaddr), - (vm_address_t) csum, - fragroundup (sblock, - sblock->fs_cssize)); - csum_dirty = 0; + + if (!csum_dirty) + { + spin_unlock (&alloclock); + return; + } + + /* Copy into a page-aligned buffer to avoid bugs in kernel device code. */ + + bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); + + err = dev_read_sync (fsbtodb (sblock, sblock->fs_csaddr), &buf, bufsize); + if (!err) + { + bcopy (csum, (void *) buf, sblock->fs_cssize); + (wait ? dev_write_sync : dev_write) (fsbtodb (sblock, sblock->fs_csaddr), + buf, bufsize); + csum_dirty = 0; + } + spin_unlock (&alloclock); } -- cgit v1.2.3 From 44eca97cf3027b2078c6954131753e315a6ed577 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 10 Nov 1994 18:33:47 +0000 Subject: (main): Issue decent prompt. --- ufs/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index 0e6bd19d..5905cbb0 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -143,6 +143,8 @@ main (int argc, char **argv) /* Prompt the user to give us another name rather than just crashing */ printf ("Cannot open device %s\n", devname); + printf ("Open instead: "); + fflush (stdout); len = getline (&line, &linesz, stdin); if (len > 2) devname = line; -- cgit v1.2.3 From 33f49d636fa6189f04e7d1ed5b690e34a4c3205e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 11 Nov 1994 16:45:33 +0000 Subject: (diskfs_set_hypermetadata): Always use dev_write_sync to avoid device_write bug that says you can't modify the buffer until device_write returns. Also remember to deallocate BUF. --- ufs/hyper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 9f8bd8d5..94fd209c 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -132,10 +132,10 @@ diskfs_set_hypermetadata (int wait, int clean) if (!err) { bcopy (csum, (void *) buf, sblock->fs_cssize); - (wait ? dev_write_sync : dev_write) (fsbtodb (sblock, sblock->fs_csaddr), - buf, bufsize); + dev_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize); csum_dirty = 0; } + vm_deallocate (mach_task_self (), buf, bufsize); spin_unlock (&alloclock); } -- cgit v1.2.3 From 625da34c7cbb8896caa4b17fca8d16284ee48132 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 11 Nov 1994 16:46:04 +0000 Subject: (diskfs_set_hypermetadata): Deallocate BUF in the right place. --- ufs/hyper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 94fd209c..8a556cef 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -134,8 +134,8 @@ diskfs_set_hypermetadata (int wait, int clean) bcopy (csum, (void *) buf, sblock->fs_cssize); dev_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize); csum_dirty = 0; + vm_deallocate (mach_task_self (), buf, bufsize); } - vm_deallocate (mach_task_self (), buf, bufsize); spin_unlock (&alloclock); } -- cgit v1.2.3 From 70b75045c4003d0d7f764d5093a63385d7c3ae1a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 16 Nov 1994 19:52:13 +0000 Subject: (MIG, MIGCOM): Never define using rsh; use /usr/local/i386-gnu/.... --- =Maketools | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/=Maketools b/=Maketools index 9ce48964..70892be7 100644 --- a/=Maketools +++ b/=Maketools @@ -26,15 +26,14 @@ export BUILD_CC := $(CC) endif CC=gcc $(CCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=rsh $(mighost) cd `pwd` \; umask `umask` \; /usr/local/lib/migcom +MIGCOM=/usr/local/i386-gnu/lib/migcom +MIG=$(tooldir)/mig else MIGCOM=/usr/local/lib/migcom +MIG=mig endif CPP=$(CC) -E -x c export CPP -# I put a /usr/local/bin/mig on the hp300s that will run $CPP locally and -# rsh to ernst to run migcom. --roland -MIG=mig # rsh $(mighost) cd `pwd` \; mig AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) -- cgit v1.2.3 From 444021f5d48a04f56cdc735a21b42886ea5a052d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 24 Nov 1994 23:39:21 +0000 Subject: Protect all mfs code with #ifdef MFS. --- ufs-utils/mkfs.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 7246505b..dd293fde 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.6 1994/10/18 18:26:04 mib Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; #endif /* not lint */ #include @@ -103,7 +103,9 @@ static char *rcsid = "$Id: mkfs.c,v 1.6 1994/10/18 18:26:04 mib Exp $"; * variables set up by front end. */ #define extern +#ifdef MFS extern int mfs; /* run as the memory based filesystem */ +#endif extern int Nflag; /* run mkfs without writing file system */ extern int Oflag; /* format as an 4.3BSD file system */ extern int fssize; /* file system size */ @@ -204,7 +206,9 @@ main (int argc, char **argv) exit (1); } +#ifdef MFS mfs = 0; +#endif Oflag = 0; fssize = st.st_size / DEV_BSIZE; @@ -285,6 +289,7 @@ mkfs(pp, fsys, fi, fo) #ifndef STANDALONE time(&utime); #endif +#ifdef MFS if (mfs) { ppid = getpid(); (void) signal(SIGUSR1, started); @@ -304,6 +309,7 @@ mkfs(pp, fsys, fi, fo) if ((membase = malloc(fssize * sectorsize)) == 0) exit(12); } +#endif fsi = fi; fso = fo; if (Oflag) { @@ -538,7 +544,7 @@ mkfs(pp, fsys, fi, fo) } sblock.fs_fpg = (sblock.fs_cpg * sblock.fs_spc) / NSPF(&sblock); if ((sblock.fs_cpg * sblock.fs_spc) % NSPB(&sblock) != 0) { - printf("panic (fs_cpg * fs_spc) % NSPF != 0"); + printf("panic (fs_cpg * fs_spc) %% NSPF != 0"); exit(24); } if (sblock.fs_cpg < mincpg) { @@ -677,7 +683,11 @@ next: NSPF(&sblock); warn = 0; } - if (warn && !mfs) { + if (warn +#ifdef MFS + && !mfs +#endif + ) { printf("Warning: %d sector(s) in last cylinder unallocated\n", sblock.fs_spc - (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) @@ -713,7 +723,10 @@ next: /* * Dump out summary information about file system. */ - if (!mfs) { +#ifdef MFS + if (!mfs) +#endif + { printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, "cylinders", sblock.fs_ntrak, sblock.fs_nsect); @@ -729,19 +742,29 @@ next: * Now build the cylinders group blocks and * then print out indices of cylinder groups. */ +#ifdef MFS if (!mfs) +#endif printf("super-block backups (for fsck -b #) at:"); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); +#ifdef MFS if (mfs) continue; +#endif if (cylno % 8 == 0) printf("\n"); printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); } +#ifdef MFS if (!mfs) +#endif printf("\n"); - if (Nflag && !mfs) + if (Nflag +#ifdef MFS + && !mfs +#endif + ) exit(0); /* * Now construct the initial file system, @@ -775,6 +798,7 @@ next: * Notify parent process of success. * Dissociate from session and tty. */ +#ifdef MFS if (mfs) { kill(ppid, SIGUSR1); (void) setsid(); @@ -783,6 +807,7 @@ next: (void) close(2); (void) chdir("/"); } +#endif } /* @@ -1017,9 +1042,11 @@ fsinit(utime) /* * create the root directory */ +#ifdef MFS if (mfs) node.di_model = IFDIR | 01777; else +#endif node.di_model = IFDIR | UMASK; node.di_modeh = 0; node.di_nlink = PREDEFDIR; @@ -1239,10 +1266,12 @@ rdfs(bno, size, bf) { int n; +#ifdef MFS if (mfs) { bcopy(membase + bno * sectorsize, bf, size); return; } +#endif if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) { printf("seek error: %ld\n", bno); perror("rdfs"); @@ -1266,10 +1295,12 @@ wtfs(bno, size, bf) { int n; +#ifdef MFS if (mfs) { bcopy(bf, membase + bno * sectorsize, size); return; } +#endif if (Nflag) return; if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) { -- cgit v1.2.3 From cc4f4d5aa696bc5c3d66b6460596dbcc1848e094 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 28 Jan 1995 19:59:24 +0000 Subject: (OBJS): Remove reference to libc's devstream.o. --- ufs/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 59965946..7ad7cb65 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,5 +1,5 @@ -# Copyright (C) 1994 Free Software Foundation +# Copyright (C) 1994, 1995 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 @@ -18,9 +18,9 @@ dir := ufs makemode := server -SRCS=alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ - sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS=$(subst .c,.o,$(SRCS)) exec_server_image.o /gd3/gnu/libc/i386/devstream.o +SRCS = alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ + sizes.c subr.c tables.c bmap.c pokeloc.c +OBJS = $(SRCS:.c=.o) exec_server_image.o LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h -- cgit v1.2.3 From 1a4d3f60b20f1e7007e8669c3e9e516936214b50 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 11 Feb 1995 08:59:12 +0000 Subject: (INSTALL_BIN): Use objcopy. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 70892be7..1c387228 100644 --- a/=Maketools +++ b/=Maketools @@ -38,7 +38,7 @@ AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) -INSTALL_BIN=i386-gnu-objcopy -S +INSTALL_BIN=objcopy -S #INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From 42241669ffb457214e1aac9d6a814c911d662075 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 16 Feb 1995 03:40:17 +0000 Subject: (CCVERSION-duality.gnu.ai.mit.edu): New variable. --- =Maketools | 1 + 1 file changed, 1 insertion(+) diff --git a/=Maketools b/=Maketools index 1c387228..b4183cff 100644 --- a/=Maketools +++ b/=Maketools @@ -18,6 +18,7 @@ CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.2) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 +CCVERSION-duality.gnu.ai.mit.edu = 2.6.4 ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) -- cgit v1.2.3 From ae31f51e1ba8afc3c5b797c01508e6c5d2d6f59d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 16 Feb 1995 05:43:28 +0000 Subject: (hostname): New variable, so CCVERSION actually works. --- =Maketools | 1 + 1 file changed, 1 insertion(+) diff --git a/=Maketools b/=Maketools index b4183cff..4ae5ebb6 100644 --- a/=Maketools +++ b/=Maketools @@ -14,6 +14,7 @@ mighost := ernst.gnu.ai.mit.edu # Set these options to the GCC compiler spec (the correct value # can be found in /usr/local/lib/lib-gcc). CCTARGET=i386-gnu +hostname := $(shell hostname) CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.2) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 -- cgit v1.2.3 From 28d8598ef9e75e22031141cae694ece08af6730e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 17 Mar 1995 19:31:00 +0000 Subject: (ffs_clusteracct): Make static. (alloc_sync): New function. (ffs_alloc): Call alloc_sync. (ffs_realloccg): Likewise. (diskfs_alloc_node): Likewise. (ffs_blkfree): Likewise. (diskfs_free_node): Likewise. --- ufs/alloc.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index b82d6065..9fa517ed 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,5 +1,5 @@ /* Disk allocation routines - Copyright (C) 1993, 1994 Free Software Foundation + Copyright (C) 1993, 1994, 1995 Free Software Foundation This file is part of the GNU Hurd. @@ -73,7 +73,21 @@ static ino_t ffs_dirpref (struct fs *); static u_long ffs_nodealloccg (struct node *, int, daddr_t, int); static daddr_t ffs_alloccgblk (struct fs *, struct cg *, daddr_t); static daddr_t ffs_mapsearch (struct fs *, struct cg *, daddr_t, int); -void ffs_clusteracct (struct fs *, struct cg *, daddr_t, int); +static void ffs_clusteracct (struct fs *, struct cg *, daddr_t, int); + +/* Sync all allocation information and nod eNP if diskfs_synchronous. */ +inline +alloc_sync (struct diskfs_node *np) +{ + if (diskfs_syncronous) + { + if (np) + diskfs_node_update (np, 1); + copy_sblock (); + diskfs_set_dypermetadata (1, 0); + sync_disk (1); + } +} /* * Allocate a block in the file system. @@ -140,6 +154,7 @@ ffs_alloc(register struct node *np, np->dn_set_ctime = 1; np->dn_set_mtime = 1; *bnp = bno; + alloc_sync (np); return (0); } #ifdef QUOTA @@ -235,6 +250,7 @@ ffs_realloccg(register struct node *np, bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; #endif + alloc_sync (np); return (0); } /* @@ -305,6 +321,7 @@ ffs_realloccg(register struct node *np, bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; #endif /* 0 */ + alloc_sync (np); return (0); } #ifdef QUOTA @@ -565,6 +582,7 @@ diskfs_alloc_node (struct node *dir, spin_unlock (&gennumberlock); *npp = np; + alloc_sync (np); return (0); noinodes: printf ("out of inodes"); @@ -1305,6 +1323,7 @@ ffs_blkfree(register struct node *np, csum_dirty = 1; sblock_dirty = 1; fs->fs_fmod = 1; + alloc_sync (np); /* bdwrite(bp); */ } @@ -1363,6 +1382,7 @@ diskfs_free_node (struct node *np, mode_t mode) csum_dirty = 1; sblock_dirty = 1; fs->fs_fmod = 1; + alloc_sync (np, 1); /* bdwrite(bp); */ } @@ -1430,7 +1450,7 @@ ffs_mapsearch(register struct fs *fs, * * Cnt == 1 means free; cnt == -1 means allocating. */ -void +static void ffs_clusteracct(struct fs *fs, struct cg *cgp, daddr_t blkno, -- cgit v1.2.3 From 08eb992b1fdc4285ca49b31fb51a0a844ba03c42 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 17 Mar 1995 19:36:46 +0000 Subject: (alloc_sync): Typo. --- ufs/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 9fa517ed..39344501 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -77,7 +77,7 @@ static void ffs_clusteracct (struct fs *, struct cg *, daddr_t, int); /* Sync all allocation information and nod eNP if diskfs_synchronous. */ inline -alloc_sync (struct diskfs_node *np) +alloc_sync (struct node *np) { if (diskfs_syncronous) { -- cgit v1.2.3 From bb2bd7c4d2c7e834529383b0036373faf4cd035d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 17 Mar 1995 19:37:52 +0000 Subject: More typos. --- ufs/alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 39344501..87b0b45a 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -76,15 +76,15 @@ static daddr_t ffs_mapsearch (struct fs *, struct cg *, daddr_t, int); static void ffs_clusteracct (struct fs *, struct cg *, daddr_t, int); /* Sync all allocation information and nod eNP if diskfs_synchronous. */ -inline +inline void alloc_sync (struct node *np) { - if (diskfs_syncronous) + if (diskfs_synchronous) { if (np) diskfs_node_update (np, 1); copy_sblock (); - diskfs_set_dypermetadata (1, 0); + diskfs_set_hypermetadata (1, 0); sync_disk (1); } } @@ -1382,7 +1382,7 @@ diskfs_free_node (struct node *np, mode_t mode) csum_dirty = 1; sblock_dirty = 1; fs->fs_fmod = 1; - alloc_sync (np, 1); + alloc_sync (np); /* bdwrite(bp); */ } -- cgit v1.2.3 From bf193e411495df70c055c9b22e02f4ac18353df5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 20 Mar 1995 18:58:39 +0000 Subject: (diskfs_synchronous): New variable. --- ufs/consts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/consts.c b/ufs/consts.c index 2062a07f..6698c5f4 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -1,5 +1,5 @@ /* Various constants wanted by the diskfs library - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -28,3 +28,4 @@ char *diskfs_server_name = "ufs"; int diskfs_major_version = 0; int diskfs_minor_version = 0; int diskfs_edit_version = 0; +int diskfs_synchronous = 0; -- cgit v1.2.3 From 520105244a77aabb592432400f0746dfc757bee5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 20 Mar 1995 19:02:06 +0000 Subject: (CC): Specify `$(CCTARGET)-gcc' instead of just `gcc'. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 4ae5ebb6..92de2353 100644 --- a/=Maketools +++ b/=Maketools @@ -26,7 +26,7 @@ ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) ifndef BUILD_CC export BUILD_CC := $(CC) endif -CC=gcc $(CCTYPE) -O2 -pipe +CC=$(CCTARGET)-gcc $(CCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=/usr/local/i386-gnu/lib/migcom MIG=$(tooldir)/mig -- cgit v1.2.3 From bee30b19142cc6a0f9ca98c8936d3c439f0b9d16 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 31 Mar 1995 18:43:23 +0000 Subject: (diskfs_truncate): Don't acquire writer lock on NP->dn->allocptrlock until after forcing delayed copies through; otherwise the pageins will deadlock attempting to get a reader lock to service them. This is safe, because we only need NP->allocsize here, and that can't change as long as we hold NP->lock. --- ufs/sizes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index bf9e2c38..ef7666b1 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -1,5 +1,5 @@ /* File growth and truncation - Copyright (C) 1993, 1994 Free Software Foundation + Copyright (C) 1993, 1994, 1995 Free Software Foundation This file is part of the GNU Hurd. @@ -83,13 +83,11 @@ diskfs_truncate (struct node *np, diskfs_file_update (np, 1); } - rwlock_writer_lock (&np->dn->allocptrlock); - /* Now flush all the data past the new size from the kernel. Also force any delayed copies of this data to take place - immediately. (We are changing the data implicitly to zeros - and doing it without the kernels immediate knowledge; - this forces us to help out the kernel thusly.) */ + immediately. (We are implicitly changing the data to zeros + and doing it without the kernel's immediate knowledge; + accordingl we must help out the kernel thusly.) */ spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) @@ -110,6 +108,8 @@ diskfs_truncate (struct node *np, pager_unreference (upi->p); } + rwlock_writer_lock (&np->dn->allocptrlock); + /* Update the size on disk; fsck will finish freeing blocks if necessary should we crash. */ np->dn_stat.st_size = length; -- cgit v1.2.3 From 046941da64a1367c1ce88827c42ef285f9a5aabd Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 Apr 1995 04:45:06 +0000 Subject: (INSTALL, INSTALL_DATA, INSTALL_BIN): Define normally using `install'. --- =Maketools | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 92de2353..7ba35ae2 100644 --- a/=Maketools +++ b/=Maketools @@ -40,7 +40,9 @@ AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) -INSTALL_BIN=objcopy -S +INSTALL = install -c +INSTALL_DATA = $(INSTALL) -m 644 +INSTALL_BIN = $(INSTALL) -m 755 #INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From 5fb8321441b128744285e783e8468a8a0ee10698 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Apr 1995 00:08:14 +0000 Subject: (diskfs_set_translator): When freeing passive translator, account for blocks freed in NP->dn_stat.st_blocks. --- ufs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index e5ba31c9..80a5fcff 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -492,6 +492,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, ffs_blkfree (np, blkno, sblock->fs_bsize); di->di_trans = 0; record_poke (di, sizeof (struct dinode)); + np->dn_stat.st_blocks -= btodb (sblock->fs_bsize); np->istranslated = 0; np->dn_set_ctime = 1; } -- cgit v1.2.3 From e2c8eab4507a52ed9812eb7ae8b9282ce24a0da1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 5 Apr 1995 00:54:58 +0000 Subject: Initial revision --- devio/dev.c | 454 ++++++++++++++++++++++++++++++++++++++++++++++++++++ devio/dev.h | 138 ++++++++++++++++ devio/devio.c | 451 ++++++++++++++++++++++++++++++++++++++++++++++++++++ devio/devpager.c | 138 ++++++++++++++++ devio/io.c | 358 +++++++++++++++++++++++++++++++++++++++++ devio/iostate.c | 76 +++++++++ devio/iostate.h | 67 ++++++++ devio/mem.c | 57 +++++++ devio/mem.h | 33 ++++ devio/open.c | 90 +++++++++++ devio/open.h | 67 ++++++++ devio/ptypes.h | 23 +++ devio/rdwr.c | 473 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ devio/window.c | 200 +++++++++++++++++++++++ devio/window.h | 82 ++++++++++ 15 files changed, 2707 insertions(+) create mode 100644 devio/dev.c create mode 100644 devio/dev.h create mode 100644 devio/devio.c create mode 100644 devio/devpager.c create mode 100644 devio/io.c create mode 100644 devio/iostate.c create mode 100644 devio/iostate.h create mode 100644 devio/mem.c create mode 100644 devio/mem.h create mode 100644 devio/open.c create mode 100644 devio/open.h create mode 100644 devio/ptypes.h create mode 100644 devio/rdwr.c create mode 100644 devio/window.c create mode 100644 devio/window.h diff --git a/devio/dev.c b/devio/dev.c new file mode 100644 index 00000000..a2eed5c0 --- /dev/null +++ b/devio/dev.c @@ -0,0 +1,454 @@ +/* Mach devices. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include + +#include "dev.h" +#include "iostate.h" + +#ifdef MSG +#include +#endif +#ifdef FAKE +#include +#include +#include +#include +#endif + +/* ---------------------------------------------------------------- */ + +/* Returns a pointer to a new device structure in DEV for the kernel device + NAME, with the given FLAGS. If BLOCK_SIZE is non-zero, it should be the + desired block size, and must be a multiple of the device block size. + If an error occurs, the error code is returned, otherwise 0. */ +error_t +dev_open(char *name, int flags, int block_size, struct dev **dev) +{ + error_t err = 0; + static mach_port_t device_master = MACH_PORT_NULL; + + *dev = malloc(sizeof (struct dev)); + + if (!(flags & DEV_SERIAL)) + flags |= DEV_SEEKABLE; + + if (*dev == NULL) + return ENOMEM; + + (*dev)->port = MACH_PORT_NULL; + + if (device_master == MACH_PORT_NULL) + err = get_privileged_ports(NULL, &device_master); + +#ifdef FAKE + (*dev)->port = (mach_port_t) + open(name, ((flags & DEV_READONLY) ? O_RDONLY : O_RDWR)); + err = ((int)(*dev)->port == -1 ? errno : 0); + if (!err) + { + struct stat stat; + if (fstat((int)(*dev)->port, &stat) == 0) + { + (*dev)->size = stat.st_size; + (*dev)->dev_block_size = stat.st_blksize; + } + else + err = errno; + } +#else + if (!err) + err = device_open(device_master, + D_READ | (flags & DEV_READONLY ? D_WRITE : 0), + name, &(*dev)->port); + + if (!err) + { + int count = DEV_GET_SIZE_COUNT; + int sizes[DEV_GET_SIZE_COUNT]; + + /* Get info about the device: total size (in bytes) and block size (in + bytes). Block size is unit in which device addressing is done. */ + err = device_get_status((*dev)->port, DEV_GET_SIZE, sizes, &count); + if (!err) + { + (*dev)->size = sizes[DEV_GET_SIZE_DEVICE_SIZE]; + (*dev)->dev_block_size = sizes[DEV_GET_SIZE_RECORD_SIZE]; + } + } +#endif +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "dev_open(`%s', 0x%x, %d) => %s\n", + name, flags, block_size, err ? strerror(err) : "OK"); + if (!err) + fprintf(debug, " size = %d, dev_block_size = %d\n", + (*dev)->size, (*dev)->dev_block_size); + mutex_unlock(&debug_lock); + } +#endif + + if (!err) + { + if (block_size > 0) + if (block_size > (*dev)->dev_block_size + && block_size % (*dev)->dev_block_size == 0) + (*dev)->block_size = block_size; + else + err = EINVAL; + else + (*dev)->block_size = (*dev)->dev_block_size; + + if ((*dev)->dev_block_size == 1) + flags |= DEV_SERIAL; + + (*dev)->flags = flags; + (*dev)->owner = 0; + } + + if (!err) + err = io_state_init(&(*dev)->io_state, *dev); + + if (err) + { + if ((*dev)->port != MACH_PORT_NULL) + mach_port_deallocate(mach_task_self(), (*dev)->port); + free(*dev); + } + + return err; +} + +/* Free DEV and any resources it consumes. */ +void +dev_close(struct dev *dev) +{ + if (!dev_is(dev, DEV_READONLY)) + { + if (dev->pager != NULL) + pager_shutdown(dev->pager); + io_state_sync(&dev->io_state, dev); + } + + device_close(dev->port); + io_state_finalize(&dev->io_state); + + free(dev); +} + +/* ---------------------------------------------------------------- */ + +/* Try and write out any pending writes to DEV. If WAIT is true, will wait + for any paging activity to cease. */ +error_t +dev_sync(struct dev *dev, int wait) +{ + error_t err = 0; + + if (!dev_is(dev, DEV_READONLY)) + { + struct io_state *ios = &dev->io_state; + + io_state_lock(ios); + + /* Sync any paged backing store. */ + if (dev->pager != NULL) + pager_sync(dev->pager, wait); + + /* Write out any stuff buffered in our io_state. */ + err = io_state_sync(ios, dev); + + io_state_unlock(ios); + } + + return err; +} + +/* ---------------------------------------------------------------- */ + +#ifdef MSG +char * +brep(vm_address_t buf, vm_size_t len) +{ + static char rep[200]; + char *prep(char *buf, char *str, int len) + { + *buf++ = '`'; + while (len-- > 0) + { + int ch = *str++; + if (isprint(ch) && ch != '\'' && ch != '\\') + *buf++ = ch; + else + { + *buf++ = '\\'; + switch (ch) + { + case '\n': *buf++ = 'n'; break; + case '\t': *buf++ = 't'; break; + case '\b': *buf++ = 'b'; break; + case '\f': *buf++ = 'f'; break; + default: sprintf(buf, "%03o", ch); buf += 3; break; + } + } + } + *buf++ = '\''; + *buf = '\0'; + return buf; + } + + if (len < 40) + prep(rep, (char *)buf, (int)len); + else + { + char *end = prep(rep, (char *)buf, 20); + *end++ = '.'; *end++ = '.'; *end++ = '.'; + prep(end, (char *)buf + len - 20, 20); + } + + return rep; +} +#endif + +/* Writes AMOUNT bytes from the buffer pointed to by BUF to the device DEV. + *OFFS is incremented to reflect the amount read/written. Both AMOUNT and + *OFFS must be multiples of DEV's block size, and either BUF must be + page-aligned, or dev_write_valid() must return true for these arguments. + If an error occurs, the error code is returned, otherwise 0. */ +error_t +dev_write(struct dev *dev, + vm_address_t buf, vm_size_t amount, vm_offset_t *offs) +{ + int bsize = dev->dev_block_size; + vm_offset_t written = 0; + vm_offset_t block = (bsize == 1 ? *offs : *offs / bsize); + error_t err; + + assert(dev_write_valid(dev, buf, amount, *offs)); + assert(*offs % bsize == 0); + assert(amount % bsize == 0); + + if (amount < IO_INBAND_MAX) + { +#ifdef FAKE + if (*offs != dev->io_state.location) + { + err = lseek((int)dev->port, SEEK_SET, *offs); + if (err == -1) + err = errno; + else + dev->io_state.location = *offs; + } + written = write((int)dev->port, (char *)buf, amount); + err = (written < 1 ? errno : 0); + if (!err) + dev->io_state.location += written; +#else + err = + device_write_inband(dev->port, 0, block, + (io_buf_ptr_t)buf, amount, &written); +#endif +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_write_inband(%d, %s, %d) => %s, %d\n", + block, brep(buf, amount), amount, err ? strerror(err) : "OK", written); + fprintf(debug, " offset = %d => %d\n", *offs, *offs + written); +#endif + mutex_unlock(&debug_lock); + } + } + else + { +#ifdef FAKE + if (*offs != dev->io_state.location) + { + err = lseek((int)dev->port, SEEK_SET, *offs); + if (err == -1) + err = errno; + else + dev->io_state.location = *offs; + } + written = write((int)dev->port, (char *)buf, amount); + err = (written < 1 ? errno : 0); + if (!err) + dev->io_state.location += written; +#else + err = + device_write(dev->port, 0, block, (io_buf_ptr_t)buf, amount, &written); +#endif +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_write(%d, %s, %d) => %s, %d\n", + block, brep(buf, amount), amount, + err ? strerror(err) : "OK", written); + fprintf(debug, " offset = %d => %d\n", *offs, *offs + written); + mutex_unlock(&debug_lock); + } +#endif + } + + if (!err) + *offs += written; + + return err; +} + +/* Reads AMOUNT bytes from DEV and returns it in BUF and BUF_LEN (using the + standard mach out-array convention). *OFFS is incremented to reflect the + amount read/written. Both LEN and *OFFS must be multiples of DEV's block + size. If an error occurs, the error code is returned, otherwise 0. */ +error_t +dev_read(struct dev *dev, + vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, + vm_offset_t *offs) +{ + error_t err = 0; + int bsize = dev->dev_block_size; + vm_offset_t read = 0; + vm_offset_t block = (bsize == 1 ? *offs : *offs / bsize); + + assert(*offs % bsize == 0); + assert(amount % bsize == 0); + + if (amount < IO_INBAND_MAX) + { + if (*buf_len < amount) + err = vm_allocate(mach_task_self(), buf, amount, 1); +#ifdef FAKE + if (*offs != dev->io_state.location) + { + err = lseek((int)dev->port, SEEK_SET, *offs); + if (err == -1) + err = errno; + else + dev->io_state.location = *offs; + } + err = vm_allocate(mach_task_self(), buf, amount, 1); + if (!err) + { + read = __read((int)dev->port, (char *)*buf, amount); + err = (read == -1 ? errno : 0); + if (!err) + dev->io_state.location += read; + } +#else + if (!err) + err = + device_read_inband(dev->port, 0, block, + amount, (io_buf_ptr_t)*buf, &read); +#endif +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_read_inband(%d, %d) => %s, %s, %d\n", + block, amount, + err ? strerror(err) : "OK", err ? "-" : brep(*buf, read), + read); + if (!err) + fprintf(debug, " offset = %d => %d\n", *offs, *offs + read); + mutex_unlock(&debug_lock); + } +#endif + } + else + { +#ifdef FAKE + if (*offs != dev->io_state.location) + { + err = lseek((int)dev->port, SEEK_SET, *offs); + if (err == -1) + err = errno; + else + dev->io_state.location = *offs; + } + err = vm_allocate(mach_task_self(), buf, amount, 1); + if (!err) + { + read = __read((int)dev->port, (char *)*buf, amount); + err = (read == -1 ? errno : 0); + if (!err) + dev->io_state.location += read; + } +#else + err = + device_read(dev->port, 0, block, amount, (io_buf_ptr_t *)buf, &read); +#endif +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_read(%d, %d) => %s, %s, %d\n", + block, amount, + err ? strerror(err) : "OK", err ? "-" : brep(*buf, read), + read); + if (!err) + fprintf(debug, " offset = %d => %d\n", *offs, *offs + read); + mutex_unlock(&debug_lock); + } +#endif + } + + if (!err) + { + *offs += read; + *buf_len = read; + } + + return err; +} + +/* ---------------------------------------------------------------- */ + +/* Returns in MEMOBJ the port for a memory object backed by the storage on + DEV. Returns 0 or the error code if an error occurred. */ +error_t +dev_get_memory_object(struct dev *dev, memory_object_t *memobj) +{ + if (dev_is(dev, DEV_SERIAL)) + return ENODEV; + + io_state_lock(&dev->io_state); + if (dev->pager == NULL) + dev->pager = + pager_create((struct user_pager_info *)dev, 1, MEMORY_OBJECT_COPY_DELAY); + io_state_unlock(&dev->io_state); + + if (dev->pager == NULL) + return ENODEV; /* XXX ??? */ + + *memobj = pager_get_port(dev->pager); + if (*memobj != MACH_PORT_NULL) + return + mach_port_insert_right(mach_task_self(), + *memobj, *memobj, + MACH_MSG_TYPE_MAKE_SEND); + + return 0; +} diff --git a/devio/dev.h b/devio/dev.h new file mode 100644 index 00000000..7244c91e --- /dev/null +++ b/devio/dev.h @@ -0,0 +1,138 @@ +/* A handle on a mach device. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 __DEV_H__ +#define __DEV_H__ + +#include +#include + +#include "iostate.h" + +/* #define FAKE */ +#define MSG + +#ifdef MSG +#include +#include +#include +extern FILE *debug; +extern struct mutex debug_lock; +#endif + +/* ---------------------------------------------------------------- */ + +/* Information about a kernel device. */ +struct dev +{ + /* The device port for the kernel device we're doing paging on. */ + device_t port; + + /* The total size of DEV. */ + vm_size_t size; + + /* The block size of DEV. I/O to DEV must occur in multiples of + block_size. */ + int dev_block_size; + /* The block size in which we will do I/O; this must be a multiple of + DEV_BLOCK_SIZE. */ + int block_size; + + /* Various attributes of this device (see below for the DEV_ flag bits). + This field is constant. */ + int flags; + + /* Current state of our output stream -- location and the buffer used to do + buffered i/o. */ + struct io_state io_state; + + /* The pager we're using to do disk i/o for us. If NULL, a pager hasn't + been allocated yet. Lock the lock in IO_STATE if you want to update + this field. */ + struct pager *pager; + + /* The current owner of the open device. For terminals, this affects + controlling terminal behavior (see term_become_ctty). For all objects + this affects old-style async IO. Negative values represent pgrps. This + has nothing to do with the owner of a file (as returned by io_stat, and + as used for various permission checks by filesystems). An owner of 0 + indicates that there is no owner. */ + pid_t owner; +}; + +/* Various bits to be set in the flags field. */ + +/* True if this device should be used in `block' mode, with buffering of + sub-block-size i/o. */ +#define DEV_BUFFERED 0x1 +/* True if this device only supports serial i/o (that is, there's only one + read/write location, which must explicitly be moved to do i/o elsewhere.*/ +#define DEV_SERIAL 0x2 +/* True if we can change the current i/o location of a serial device. */ +#define DEV_SEEKABLE 0x4 +/* True if a device cannot be written on. */ +#define DEV_READONLY 0x8 + +/* Returns TRUE if any of the flags in BITS are set for DEV. */ +#define dev_is(dev, bits) ((dev)->flags & (bits)) + +/* Returns true if it's ok to call dev_write on these arguments, without + first copying BUF to a page-aligned buffer. */ +#define dev_write_valid(dev, buf, len, offs) \ + ((len) <= IO_INBAND_MAX || (buf) % vm_page_size == 0) + +/* Returns a pointer to a new device structure in DEV for the kernel device + NAME, with the given FLAGS. If BLOCK_SIZE is non-zero, it should be the + desired block size, and must be a multiple of the device block size. + If an error occurs, the error code is returned, otherwise 0. */ +error_t dev_open(char *name, int flags, int block_size, struct dev **dev); + +/* Free DEV and any resources it consumes. */ +void dev_close(struct dev *dev); + +/* Reads AMOUNT bytes from DEV and returns it in BUF and BUF_LEN (using the + standard mach out-array convention). *OFFS is incremented to reflect the + amount read/written. Both LEN and *OFFS must be multiples of DEV's block + size. If an error occurs, the error code is returned, otherwise 0. */ +error_t dev_read(struct dev *dev, + vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, + vm_offset_t *offs); + +/* Writes AMOUNT bytes from the buffer pointed to by BUF to the device DEV. + *OFFS is incremented to reflect the amount read/written. Both AMOUNT and + *OFFS must be multiples of DEV's block size, and either BUF must be + page-aligned, or dev_write_valid() must return true for these arguments. + If an error occurs, the error code is returned, otherwise 0. */ +error_t dev_write(struct dev *dev, + vm_address_t buf, vm_size_t amount, vm_offset_t *offs); + +/* Returns in MEMOBJ the port for a memory object backed by the storage on + DEV. Returns 0 or the error code if an error occurred. */ +error_t dev_get_memory_object(struct dev *dev, memory_object_t *memobj); + +/* Try and write out any pending writes to DEV. If WAIT is true, will wait + for any paging activity to cease. */ +error_t dev_sync(struct dev *dev, int wait); + +#ifdef MSG +char *brep(vm_address_t buf, vm_size_t len); +#endif + +#endif /* !__DEV_H__ */ diff --git a/devio/devio.c b/devio/devio.c new file mode 100644 index 00000000..05343b7e --- /dev/null +++ b/devio/devio.c @@ -0,0 +1,451 @@ +/* A translator for doing I/O to mach kernel devices. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "open.h" +#include "dev.h" +#include "ptypes.h" + +/* ---------------------------------------------------------------- */ + +#define USAGE "Usage: %s [OPTION...] DEVICE\n" + +static void +usage(int status) +{ + if (status != 0) + fprintf(stderr, "Try `%s --help' for more information.\n", + program_invocation_name); + else + { + printf(USAGE, program_invocation_name); + printf("\ +\n\ + -d, --devnum=NUM Give DEVICE a device number NUM\n\ + -r, --readonly Disable writing to DEVICE\n\ + -p, --seekable Enable seeking if DEVICE is serial\n\ + -s, --serial Indicate that DEVICE has a single R/W point\n\ + -b, --buffered, --block Open DEVICE in `block' mode, which allows reads\n\ + or writes less than a single block and buffers\n\ + I/O to the actual device. By default, all reads\n\ + and writes are made directly to the device,\n\ + with no buffering, and any sub-block-size I/O\n\ + is padded to the nearest full block.\n\ + -B NUM, --block-size=NUM Use a block size of NUM, which must be an integer\n\ + multiple of DEVICE's real block size\n\ +"); + } + + exit(status); +} + +#define SHORT_OPTIONS "bB:d:D:?rpsu" + +static struct option options[] = +{ + {"block-size", required_argument, 0, 'B'}, + {"debug", required_argument, 0, 'D'}, + {"help", no_argument, 0, '?'}, + {"devnum", required_argument, 0, 'm'}, + {"block", no_argument, 0, 'b'}, + {"buffered", no_argument, 0, 'b'}, + {"readonly", no_argument, 0, 'r'}, + {"seekable", no_argument, 0, 'p'}, + {"serial", no_argument, 0, 's'}, + {0, 0, 0, 0} +}; + + +/* ---------------------------------------------------------------- */ + +/* A struct dev for the open kernel device. */ +static struct dev *device = NULL; + +/* Desired device parameters specified by the user. */ +static char *device_name = NULL; +static int device_flags = 0; +static int device_block_size = 0; + +/* A unixy device number to return when the device is stat'd. */ +static int device_number = 0; + +/* A stream on which we can print debugging message. */ +FILE *debug = NULL; +/* A lock to use while doing so. */ +struct mutex debug_lock; + +void main(int argc, char *argv[]) +{ + error_t err; + mach_port_t bootstrap; + int opt; + struct trivfs_control *trivfs_control; + mach_port_t realnode, control; + + while ((opt = getopt_long(argc, argv, SHORT_OPTIONS, options, 0)) != EOF) + switch (opt) + { + case 'r': device_flags |= DEV_READONLY; break; + case 's': device_flags |= DEV_SERIAL; break; + case 'b': device_flags |= DEV_BUFFERED; break; + case 'p': device_flags |= DEV_SEEKABLE; break; + case 'B': device_block_size = atoi(optarg); break; + case 'd': device_number = atoi(optarg); break; + case 'D': debug = fopen(optarg, "w+"); setlinebuf(debug); break; + case '?': usage(0); + default: usage(1); + } + + mutex_init(&debug_lock); + + if (device_flags & DEV_READONLY) + /* Catch illegal writes at the point of open. */ + trivfs_allow_open &= ~O_WRITE; + + if (argv[optind] == NULL || argv[optind + 1] != NULL) + { + fprintf(stderr, USAGE, program_invocation_name); + usage(1); + } + + device_name = argv[optind]; + + _libports_initialize(); + + task_get_bootstrap_port (mach_task_self (), &bootstrap); + if (bootstrap == MACH_PORT_NULL) + error(2, 0, "Must be started as a translator"); + + /* Reply to our parent */ + control = trivfs_handle_port (MACH_PORT_NULL, PT_FSYS, PT_NODE); + err = fsys_startup (bootstrap, control, MACH_MSG_TYPE_MAKE_SEND, &realnode); + + /* Install the returned realnode for trivfs's use */ + trivfs_control = ports_check_port_type (control, PT_FSYS); + assert (trivfs_control); + ports_change_hardsoft (trivfs_control, 1); + trivfs_control->underlying = realnode; + ports_done_with_port (trivfs_control); + + /* Open the device only when necessary. */ + device = NULL; + + /* Launch. */ + ports_manage_port_operations_multithread (); + + exit(0); +} + +/* Called whenever someone tries to open our node (even for a stat). We + delay opening the kernel device until this point, as we can usefully + return errors from here. */ +static error_t +check_open_hook (struct trivfs_control *trivfs_control, + uid_t *uids, u_int nuids, + gid_t *gids, u_int ngids, + int flags) +{ + error_t err = 0; + + if (device == NULL) + /* Try and open the device. */ + { + err = dev_open(device_name, device_flags, device_block_size, &device); + if (err) + device = NULL; + if (err && (flags & (O_READ|O_WRITE)) == 0) + /* If we're not opening for read or write, then just ignore the + error, as this allows stat to word correctly. XXX */ + err = 0; + } + + return err; +} + +static void +open_hook(struct trivfs_peropen *peropen) +{ + if (device) + open_create(device, (struct open **)&peropen->hook); +} + +static void +close_hook(struct trivfs_peropen *peropen) +{ + if (peropen->hook) + open_free(peropen->hook); +} + +static void +clean_exit(int status) +{ +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "cleaning up and exiting (status = %d)...\n", status); + mutex_unlock(&debug_lock); + } +#endif + if (device) + { + dev_close(device); + device = NULL; + } +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "Bye!\n"); + fclose(debug); + debug = NULL; + mutex_unlock(&debug_lock); + } +#endif +} + +/* ---------------------------------------------------------------- */ +/* Trivfs hooks */ + +int trivfs_fstype = FSTYPE_DEV; +int trivfs_fsid = 0; /* ??? */ + +int trivfs_support_read = 1; +int trivfs_support_write = 1; +int trivfs_support_exec = 0; + +int trivfs_allow_open = O_READ | O_WRITE; + +int trivfs_protid_porttypes[] = {PT_NODE}; +int trivfs_cntl_porttypes[] = {PT_FSYS}; +int trivfs_protid_nporttypes = 1; +int trivfs_cntl_nporttypes = 1; + +void +trivfs_modify_stat (struct stat *st) +{ + if (device) + { + vm_size_t size = device->size; + + if (device->block_size > 1) + st->st_blksize = device->block_size; + + st->st_size = size; + st->st_blocks = size / 512; + + if (dev_is(device, DEV_READONLY)) + st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); + + st->st_mode &= ~S_IFMT; + st->st_mode |= dev_is(device, DEV_BUFFERED) ? S_IFBLK : S_IFCHR; + } + else + /* Try and do things without an open device... */ + { + st->st_blksize = device_block_size; + st->st_size = 0; + st->st_blocks = 0; + st->st_mode &= ~S_IFMT; + st->st_mode |= (device_flags & DEV_BUFFERED) ? S_IFBLK : S_IFCHR; + if (device_flags & DEV_READONLY) + st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); + } + + st->st_fstype = FSTYPE_DEV; + st->st_rdev = device_number; +} + +error_t +trivfs_goaway (int flags, mach_port_t realnode, int ctltype, int pitype) +{ + if (device != NULL && !(flags & FSYS_GOAWAY_FORCE)) + /* By default, don't go away if there are still opens on this device. */ + return EBUSY; + +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "trivfs_goaway(0x%x, %d, %d, %d)\n", + flags, realnode, ctltype, pitype); + mutex_unlock(&debug_lock); + } +#endif + + if (flags & FSYS_GOAWAY_NOSYNC) + exit(0); + else + clean_exit(0); +} + +/* If this variable is set, it is called every time an open happens. + UIDS, GIDS, and FLAGS are from the open; CNTL identifies the + node being opened. This call need not check permissions on the underlying + node. If the open call should block, then return EWOULDBLOCK. Other + errors are immediately reflected to the user. If O_NONBLOCK + is not set in FLAGS and EWOULDBLOCK is returned, then call + trivfs_complete_open when all pending open requests for this + file can complete. */ +error_t (*trivfs_check_open_hook)(struct trivfs_control *trivfs_control, + uid_t *uids, u_int nuids, + gid_t *gids, u_int ngids, + int flags) + = check_open_hook; + +/* If this variable is set, it is called every time a new peropen + structure is created and initialized. */ +void (*trivfs_peropen_create_hook)(struct trivfs_peropen *) = open_hook; + +/* If this variable is set, it is called every time a peropen structure + is about to be destroyed. */ +void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *) = close_hook; + +/* Sync this filesystem. */ +kern_return_t +trivfs_S_fsys_syncfs (struct trivfs_control *cntl, + mach_port_t reply, mach_msg_type_name_t replytype, + int wait, int dochildren) +{ +#ifdef MSG + if (debug && device) + { + mutex_lock(&debug_lock); + fprintf(debug, "syncing filesystem...\n"); + mutex_unlock(&debug_lock); + } +#endif + if (device) + return dev_sync(device, wait); + else + return 0; +} + +/* ---------------------------------------------------------------- */ +/* Ports hooks */ + +void (*ports_cleanroutines[])(void *) = +{ + [PT_FSYS] = trivfs_clean_cntl, + [PT_NODE] = trivfs_clean_protid, +}; + +int +ports_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) +{ + error_t err; +#ifdef MSG + static int next_msg_num = 0; + int msg_num; + + if (debug) + { + mutex_lock(&debug_lock); + msg_num = next_msg_num++; + fprintf(debug, "port_demuxer(%d) [%d]\n", inp->msgh_id, msg_num); + mutex_unlock(&debug_lock); + } +#endif + + err = pager_demuxer(inp, outp) || trivfs_demuxer(inp, outp); + +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "port_demuxer(%d) [%d] done!\n", inp->msgh_id, msg_num); + mutex_unlock(&debug_lock); + } +#endif + + return err; +} + +/* This will be called whenever there have been no requests to the server for + a significant period of time. NHARD is the number of live hard ports; + NSOFT is the number of live soft ports. This function is called while an + internal lock is held, so it cannot reliably call any other functions of + the ports library. */ +void +ports_notice_idle (int nhard, int nsoft) +{ +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "ports_notice_idle(%d, %d)\n", nhard, nsoft); + mutex_unlock(&debug_lock); + } + else +#endif + if (nhard == 0) + clean_exit(0); +} + +/* This will be called whenever there are no hard ports or soft ports + allocated. This function is called while an internal lock is held, so it + cannot reliably call any other functions of the ports library. */ +void +ports_no_live_ports () +{ +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "ports_no_live_ports()\n"); + mutex_unlock(&debug_lock); + } + else +#endif + clean_exit(0); +} + +/* This will be called whenever there are no hard ports allocated but there + are still some soft ports. This function is called while an internal lock + is held, so it cannot reliably call any other functions of the ports + library. */ +void +ports_no_hard_ports () +{ +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "ports_no_hard_ports()\n"); + mutex_unlock(&debug_lock); + } +#endif + if (device != NULL) + { + dev_close(device); + device = NULL; + } +} diff --git a/devio/devpager.c b/devio/devpager.c new file mode 100644 index 00000000..9ed5bd3e --- /dev/null +++ b/devio/devpager.c @@ -0,0 +1,138 @@ +/* A pager interface for raw mach devices. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include + +#include "dev.h" +#include "ptypes.h" + +/* ---------------------------------------------------------------- */ +/* Pager library callbacks; see for more info. */ + +/* This will be the type used in calls to allocate_port by the pager system. + */ +int pager_port_type = PT_MEMOBJ; + +/* 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. */ +error_t +pager_read_page(struct user_pager_info *upi, + vm_offset_t page, vm_address_t *buf, int *writelock) +{ + int read; /* bytes actually read */ + struct dev *dev = (struct dev *)upi; + error_t err = + device_read(dev->port, + 0, page / dev->dev_block_size, vm_page_size, + (io_buf_ptr_t *)buf, &read); +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_read(%d, %d) [pager] => %s, %s, %d\n", + page / dev->dev_block_size, vm_page_size, + strerror(err), err ? "-" : brep(*buf, read), read); + mutex_unlock(&debug_lock); + } +#endif + + *writelock = (dev->flags & DEV_READONLY); + + if (err || read < vm_page_size) + return EIO; + else + return 0; +} + +/* For pager PAGER, synchronously write one page from BUF to offset PAGE. In + addition, vm_deallocate (or equivalent) BUF. The only permissable error + returns are EIO, EDQUOT, and ENOSPC. */ +error_t +pager_write_page(struct user_pager_info *upi, + vm_offset_t page, vm_address_t buf) +{ + struct dev *dev = (struct dev *)upi; + + if (dev->flags & DEV_READONLY) + return EROFS; + else + { + int written; + error_t err = + device_write(dev->port, + 0, page / dev->dev_block_size, + (io_buf_ptr_t)buf, vm_page_size, + &written); +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "device_write(%d, %s, %d) [pager] => %s, %d\n", + page / dev->dev_block_size, + brep(buf, vm_page_size), vm_page_size, + strerror(err), written); + mutex_unlock(&debug_lock); + } +#endif + + vm_deallocate(mach_task_self(), buf, vm_page_size); + + if (err || written < vm_page_size) + return EIO; + else + return 0; + } +} + +/* A page should be made writable. */ +error_t +pager_unlock_page(struct user_pager_info *upi, vm_offset_t address) +{ + struct dev *dev = (struct dev *)upi; + + if (dev->flags & DEV_READONLY) + return EROFS; + else + return 0; +} + +/* The user must define this function. It should report back (in + *OFFSET and *SIZE the minimum valid address the pager will accept + and the size of the object. */ +error_t +pager_report_extent(struct user_pager_info *upi, + vm_address_t *offset, vm_size_t *size) +{ + *offset = 0; + *size = ((struct dev *)upi)->size; + return 0; +} + +/* This is called when a pager is being deallocated after all extant send + rights have been destroyed. */ +void +pager_clear_user_data(struct user_pager_info *upi) +{ +} diff --git a/devio/io.c b/devio/io.c new file mode 100644 index 00000000..855cf158 --- /dev/null +++ b/devio/io.c @@ -0,0 +1,358 @@ +/* Implements the hurd io interface to devio. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include +#include + +#include "open.h" +#include "dev.h" +#include "iostate.h" + +/* ---------------------------------------------------------------- */ + +/* Return objects mapping the data underlying this memory object. If + the object can be read then memobjrd will be provided; if the + object can be written then memobjwr will be provided. For objects + where read data and write data are the same, these objects will be + equal, otherwise they will be disjoint. Servers are permitted to + implement io_map but not io_map_cntl. Some objects do not provide + mapping; they will set none of the ports and return an error. Such + objects can still be accessed by io_read and io_write. */ +kern_return_t +trivfs_S_io_map(struct trivfs_protid *cred, + memory_object_t *rdobj, + mach_msg_type_name_t *rdtype, + memory_object_t *wrobj, + mach_msg_type_name_t *wrtype) +{ + if (!cred) + return EOPNOTSUPP; + else + { + mach_port_t memobj; + struct open *open = (struct open *)cred->po->hook; + error_t err = dev_get_memory_object(open->dev, &memobj); + + if (!err) + { + if (cred->po->openmodes & O_READ) + { + *rdobj = memobj; + *rdtype = MACH_MSG_TYPE_MOVE_SEND; + } + else + *rdobj = MACH_PORT_NULL; + + if (cred->po->openmodes & O_WRITE) + { + *wrobj = memobj; + *wrtype = MACH_MSG_TYPE_MOVE_SEND; + } + else + *wrobj = MACH_PORT_NULL; + } + + return err; + } +} + +/* ---------------------------------------------------------------- */ + +/* Read data from an IO object. If offset if -1, read from the object + maintained file pointer. If the object is not seekable, offset is + ignored. The amount desired to be read is in AMT. */ +kern_return_t +trivfs_S_io_read(struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + vm_address_t *data, + mach_msg_type_number_t *datalen, + off_t offs, + mach_msg_type_number_t amt) +{ + if (!cred) + return EOPNOTSUPP; + else if (!(cred->po->openmodes & O_READ)) + return EBADF; + else + return open_read((struct open *)cred->po->hook, data, datalen, amt, offs); +} + +/* ---------------------------------------------------------------- */ + +/* Tell how much data can be read from the object without blocking for + a "long time" (this should be the same meaning of "long time" used + by the nonblocking flag. */ +kern_return_t +trivfs_S_io_readable (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + mach_msg_type_number_t *amount) +{ + if (!cred) + return EOPNOTSUPP; + else if (!(cred->po->openmodes & O_READ)) + return EINVAL; + else + { + struct open *open = (struct open *)cred->po->hook; + struct dev *dev = open->dev; + vm_offset_t location = open_get_io_state(open)->location; + *amount = dev->size - location; + return 0; + } +} + +/* ---------------------------------------------------------------- */ + +/* Change current read/write offset */ +kern_return_t +trivfs_S_io_seek (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + off_t offset, int whence, off_t *new_offset) +{ + if (!cred) + return EOPNOTSUPP; + else + { + error_t err = 0; + struct open *open = (struct open *)cred->po->hook; + struct io_state *io_state = open_get_io_state(open); + + if (!dev_is(open->dev, DEV_SEEKABLE)) + return ESPIPE; + + io_state_lock(io_state); + switch(whence) + { + case SEEK_SET: + io_state->location = offset; break; + case SEEK_CUR: + io_state->location += offset; break; + case SEEK_END: + io_state->location = open->dev->size - offset; break; + default: + err = EINVAL; + } + *new_offset = io_state->location; + io_state_unlock(io_state); + + return err; + } +} + +/* ---------------------------------------------------------------- */ + +/* SELECT_TYPE is the bitwise OR of SELECT_READ, SELECT_WRITE, and SELECT_URG. + Block until one of the indicated types of i/o can be done "quickly", and + return the types that are then available. ID_TAG is returned as passed; it + is just for the convenience of the user in matching up reply messages with + specific requests sent. */ +kern_return_t +trivfs_S_io_select (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + int *type, int *tag) +{ + if (!cred) + return EOPNOTSUPP; + else if (((*type & SELECT_READ) && !(cred->po->openmodes & O_READ)) + || ((*type & SELECT_WRITE) && !(cred->po->openmodes & O_WRITE))) + return EBADF; + else + *type &= ~SELECT_URG; + return 0; +} + +/* ---------------------------------------------------------------- */ + +/* Write data to an IO object. If offset is -1, write at the object + maintained file pointer. If the object is not seekable, offset is + ignored. The amount successfully written is returned in amount. A + given user should not have more than one outstanding io_write on an + object at a time; servers implement congestion control by delaying + responses to io_write. Servers may drop data (returning ENOBUFS) + if they recevie more than one write when not prepared for it. */ +kern_return_t +trivfs_S_io_write (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + vm_address_t data, mach_msg_type_number_t datalen, + off_t offs, mach_msg_type_number_t *amt) +{ + if (!cred) + return EOPNOTSUPP; + else if (!(cred->po->openmodes & O_WRITE)) + return EBADF; + else + return open_write((struct open *)cred->po->hook, data, datalen, amt, offs); +} + +/* ---------------------------------------------------------------- */ + +/* Truncate file. */ +kern_return_t +trivfs_S_file_truncate (struct trivfs_protid *cred, off_t size) +{ + if (!cred) + return EOPNOTSUPP; + else if (dev_is(((struct open *)cred->po->hook)->dev, DEV_SERIAL)) + return 0; + else + return EINVAL; +} + +/* ---------------------------------------------------------------- */ +/* These four routines modify the O_APPEND, O_ASYNC, O_FSYNC, and + O_NONBLOCK bits for the IO object. In addition, io_get_openmodes + will tell you which of O_READ, O_WRITE, and O_EXEC the object can + be used for. The O_ASYNC bit affects icky async I/O; good async + I/O is done through io_async which is orthogonal to these calls. */ + +kern_return_t +trivfs_S_io_get_openmodes (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + int *bits) +{ + if (!cred) + return EOPNOTSUPP; + else + { + *bits = cred->po->openmodes; + return 0; + } +} + +error_t +trivfs_S_io_set_all_openmodes(struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int mode) +{ + if (!cred) + return EOPNOTSUPP; + else + return 0; +} + +kern_return_t +trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int bits) +{ + if (!cred) + return EOPNOTSUPP; + else + return 0; +} + +kern_return_t +trivfs_S_io_clear_some_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int bits) +{ + if (!cred) + return EOPNOTSUPP; + else + return 0; +} + +/* ---------------------------------------------------------------- */ +/* Get/set the owner of the IO object. For terminals, this affects + controlling terminal behavior (see term_become_ctty). For all + objects this affects old-style async IO. Negative values represent + pgrps. This has nothing to do with the owner of a file (as + returned by io_stat, and as used for various permission checks by + filesystems). An owner of 0 indicates that there is no owner. */ + +kern_return_t +trivfs_S_io_get_owner (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + pid_t *owner) +{ + if (!cred) + return EOPNOTSUPP; + else + { + struct open *open = (struct open *)cred->po->hook; + *owner = open->dev->owner; + return 0; + } +} + +kern_return_t +trivfs_S_io_mod_owner (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + pid_t owner) +{ + if (!cred) + return EOPNOTSUPP; + else + { + struct open *open = (struct open *)cred->po->hook; + open->dev->owner = owner; + return 0; + } +} + + +/* ---------------------------------------------------------------- */ +/* File syncing operations; these all do the same thing, sync the underlying + device. */ + +kern_return_t +trivfs_S_file_sync (struct trivfs_protid *cred, int wait) +{ + if (!cred) + return EOPNOTSUPP; + else + { +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "syncing file...\n"); + mutex_unlock(&debug_lock); + } +#endif + return dev_sync(((struct open *)cred->po->hook)->dev, wait); + } +} + +kern_return_t +trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) +{ + if (!cred) + return EOPNOTSUPP; + else + { +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "syncing filesystem (through file)...\n"); + mutex_unlock(&debug_lock); + } +#endif + return dev_sync(((struct open *)cred->po->hook)->dev, wait); + } +} diff --git a/devio/iostate.c b/devio/iostate.c new file mode 100644 index 00000000..2f6863bc --- /dev/null +++ b/devio/iostate.c @@ -0,0 +1,76 @@ +/* State for an I/O stream. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 + +#include "iostate.h" +#include "dev.h" + +/* ---------------------------------------------------------------- */ + +/* Initialize the io_state structure IOS to be used with the device DEV. If + a memory allocation error occurs, ENOMEM is returned, otherwise 0. */ +error_t +io_state_init(struct io_state *ios, struct dev *dev) +{ + error_t err = + vm_allocate(mach_task_self(), + (vm_address_t *)&ios->buffer, dev->block_size, 1); + + ios->location = 0; + ios->buffer_size = dev->block_size; + ios->buffer_use = 0; + mutex_init(&ios->lock); + + return err; +} + +/* Frees all resources used by IOS. */ +void +io_state_finalize(struct io_state *ios) +{ + vm_deallocate(mach_task_self(), (vm_address_t)ios->buffer, ios->buffer_size); +} + +/* If IOS's location isn't block aligned because writes have been buffered + there, then sync the whole buffer out to the device. Any error that + occurs while writing is returned, otherwise 0. */ +error_t +io_state_sync(struct io_state *ios, struct dev *dev) +{ + error_t err = 0; + + if (ios->buffer_use == IO_STATE_BUFFERED_WRITE) + { + vm_offset_t pos = ios->location; + int block_offs = pos % dev->block_size; + + if (block_offs > 0) + { + bzero((char *)ios->buffer + block_offs, + dev->block_size - block_offs); + ios->location -= block_offs; + err = + dev_write(dev, ios->buffer, dev->block_size, &ios->location); + } + } + + return err; +} diff --git a/devio/iostate.h b/devio/iostate.h new file mode 100644 index 00000000..1795e153 --- /dev/null +++ b/devio/iostate.h @@ -0,0 +1,67 @@ +/* State for an I/O stream. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 __IOSTATE_H__ +#define __IOSTATE_H__ + +/* ---------------------------------------------------------------- */ + +enum io_state_buffer_use +{ + /* 0 means nothing */ + IO_STATE_BUFFERED_WRITE = 1, IO_STATE_BUFFERED_READ = 2 +}; + +struct io_state { + /* What we think the current position is. */ + vm_offset_t location; + + /* The buffer in which we accumulate buffered i/o. */ + vm_address_t buffer; + /* The size of BUFFER. */ + vm_size_t buffer_size; + + /* If LOCATION is not a multiple of the block size (and so points somewhere + in the middle of BUFFER), this indicates why. */ + enum io_state_buffer_use buffer_use; + + /* Lock this if you want to read/modify LOCATION or BUFFER. */ + struct mutex lock; +}; + +#define io_state_lock(ios) mutex_lock(&(ios)->lock) +#define io_state_unlock(ios) mutex_unlock(&(ios)->lock) + +/* Declare this to keep the parameter scope below sane. */ +struct dev; + +/* Initialize the io_state structure IOS to be used with the device DEV. If + a memory allocation error occurs, ENOMEM is returned, otherwise 0. */ +error_t io_state_init(struct io_state *ios, struct dev *dev); + +/* Frees all resources used by IOS. */ +void io_state_finalize(struct io_state *ios); + +/* If IOS's location isn't block aligned because writes have been buffered + there, then sync the whole buffer out to the device. Any error that + occurs while writing is returned, otherwise 0. */ +error_t io_state_sync(struct io_state *ios, struct dev *dev); + +#endif /* !__IOSTATE_H__ */ diff --git a/devio/mem.c b/devio/mem.c new file mode 100644 index 00000000..65caa19f --- /dev/null +++ b/devio/mem.c @@ -0,0 +1,57 @@ +/* Some random handy ops for dealing with rpcs that return memory. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include + +/* ---------------------------------------------------------------- */ + +/* Makes sure that BUF, points to a buffer with AMOUNT bytes available. + *BUF_LEN should be the current length of *BUF, and if this isn't enough to + hold AMOUNT bytes, then more is allocated and the new buffer is returned + in *BUF and *BUF_LEN. If a memory allocation error occurs, the error code + is returned, otherwise 0. */ +error_t +allocate(vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount) +{ + if (*buf_len < amount) + { + error_t err = vm_allocate(mach_task_self(), buf, amount, 1); + if (err) + return err; + } + + *buf_len = amount; + return 0; +} + +/* Deallocates any pages entirely within the last EXCESS bytes of the BUF_LEN + long buffer, BUF. */ +error_t +deallocate_excess(vm_address_t buf, vm_size_t buf_len, vm_size_t excess) +{ + vm_size_t excess_pages = buf_len - round_page(buf_len - excess); + if (excess_pages > 0) + return + vm_deallocate(mach_task_self(), + round_page(buf + buf_len - excess), excess_pages); + else + return 0; +} diff --git a/devio/mem.h b/devio/mem.h new file mode 100644 index 00000000..e19b590c --- /dev/null +++ b/devio/mem.h @@ -0,0 +1,33 @@ +/* Some random handy memory ops that know about VM. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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. */ + +/* For bcopy &c. */ +#include + +/* Makes sure that BUF, points to a buffer with AMOUNT bytes available. + *BUF_LEN should be the current length of *BUF, and if this isn't enough to + hold AMOUNT bytes, then more is allocated and the new buffer is returned + in *BUF and *BUF_LEN. If a memory allocation error occurs, the error code + is returned, otherwise 0. */ +error_t allocate(vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount); + +/* Deallocates any pages entirely within the last EXCESS bytes of the BUF_LEN + long buffer, BUF. */ +error_t deallocate_excess(vm_address_t buf, vm_size_t buf_len, vm_size_t excess); diff --git a/devio/open.c b/devio/open.c new file mode 100644 index 00000000..64d62bfe --- /dev/null +++ b/devio/open.c @@ -0,0 +1,90 @@ +/* Per-open information for devio. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 + +#include "open.h" +#include "window.h" +#include "dev.h" + +/* ---------------------------------------------------------------- */ + +/* Returns a new per-open structure for the device DEV in OPEN. If an error + occurs, the error-code is returned, otherwise 0. */ +error_t +open_create(struct dev *dev, struct open **open) +{ + error_t err; + + *open = malloc(sizeof(struct open)); + + if (*open == NULL) + return ENOMEM; + + (*open)->dev = dev; + + err = io_state_init(&(*open)->io_state, dev); + + if (!err && dev_is(dev, DEV_BUFFERED) && !dev_is(dev, DEV_SERIAL)) + /* A random-access buffered device -- use a pager to do i/o to it. */ + { + mach_port_t memobj; + err = dev_get_memory_object(dev, &memobj); + if (!err) + err = + window_create(memobj, 0, 0, dev_is(dev, DEV_READONLY), + &(*open)->window); /* XXX sizes */ + if (err) + { + mach_port_destroy(mach_task_self(), memobj); + io_state_finalize(&(*open)->io_state); + } + } + else + (*open)->window = NULL; + + if (err) + free(*open); + + return err; +} + +/* ---------------------------------------------------------------- */ + +/* Free OPEN and any resources it holds. */ +void +open_free(struct open *open) +{ + io_state_finalize(&open->io_state); + window_free(open->window); + free(open); +} + + +/* ---------------------------------------------------------------- */ + +/* Returns the appropiate io_state object for OPEN (which may be either + per-open or a per-device depending on the device). */ +struct io_state * +open_get_io_state(struct open *open) +{ + return + dev_is(open->dev, DEV_SERIAL) ? &open->dev->io_state : &open->io_state; +} diff --git a/devio/open.h b/devio/open.h new file mode 100644 index 00000000..c202d9ed --- /dev/null +++ b/devio/open.h @@ -0,0 +1,67 @@ +/* Per-open information for devio. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 __OPEN_H__ +#define __OPEN_H__ + +#include "iostate.h" + +/* ---------------------------------------------------------------- */ + +/* A structure describing a particular i/o stream on this device. */ +struct open +{ + /* Current state of our output stream -- location and the buffer used to do + buffered i/o. */ + struct io_state io_state; + + /* The memory window we're using to do i/o. This may be NULL, indicating + we're not doing buffered random access i/o. */ + struct window *window; + + /* The device that this an open on. */ + struct dev *dev; +}; + +/* Returns a new per-open structure for the device DEV in OPEN. If an error + occurs, the error-code is returned, otherwise 0. */ +error_t open_create(struct dev *dev, struct open **open); + +/* Free OPEN and any resources it holds. */ +void open_free(struct open *open); + +/* Returns the appropiate io_state object for OPEN (which may be either + per-open or a per-device depending on the device). */ +struct io_state *open_get_io_state(struct open *open); + +/* Writes up to LEN bytes from BUF to OPEN's device at device offset OFFS + (which may be ignored if the device doesn't support random access), + and returns the number of bytes written in AMOUNT. If no error occurs, + zero is returned, otherwise the error code is returned. */ +error_t open_write(struct open *open, vm_address_t buf, vm_size_t len, + vm_size_t *amount, off_t offs); + +/* Reads up to AMOUNT bytes from the device into BUF and BUF_LEN using the + standard mach out-array convention. If no error occurs, zero is returned, + otherwise the error code is returned. */ +error_t open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, + vm_size_t amount, off_t offs); + +#endif /* !__OPEN_H__ */ diff --git a/devio/ptypes.h b/devio/ptypes.h new file mode 100644 index 00000000..64aa3b0d --- /dev/null +++ b/devio/ptypes.h @@ -0,0 +1,23 @@ +/* Libports port types for devio. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 PT_FSYS 0 +#define PT_NODE 1 +#define PT_MEMOBJ 2 diff --git a/devio/rdwr.c b/devio/rdwr.c new file mode 100644 index 00000000..99ba9414 --- /dev/null +++ b/devio/rdwr.c @@ -0,0 +1,473 @@ +/* Implements various types of I/O on top of raw devices. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include + +#include "open.h" +#include "dev.h" +#include "mem.h" +#include "window.h" + +/* ---------------------------------------------------------------- */ + +/* Writes BUF to DEV, copying through an intermediate buffer to page-align + it. If STAGING_BUF isn't 0, it is used as the copy buffer for + small-enough transfers (staging_buf is assumed to be one block in length). + AMOUNT is the actual amount written, and LEN is the amount of source + material actually in BUF; if LEN is smaller than AMOUNT, the remainder is + zero. */ +static error_t +copying_block_write(struct dev *dev, vm_address_t staging_buf, + vm_address_t buf, vm_size_t len, vm_size_t amount, + vm_offset_t *offs) +{ + error_t err = 0; + vm_address_t copy_buf = staging_buf; + vm_size_t copy_buf_len = dev->block_size; + + if (amount > dev->block_size || staging_buf == 0) + { + copy_buf_len = amount; + err = vm_allocate(mach_task_self(), ©_buf, copy_buf_len, 1); + if (err) + return err; + } + + bcopy((char *)buf, (char *)copy_buf, len); + if (len < amount && copy_buf == staging_buf) + /* We need to zero the rest of the bloc, but only if we didn't + vm_allocate it (in which case it will be zero-filled). */ + bzero((char *)buf + len, amount - len); + + err = dev_write(dev, copy_buf, amount, offs); + + if (copy_buf != staging_buf) + vm_deallocate(mach_task_self(), copy_buf, copy_buf_len); + + return err; +} + +/* ---------------------------------------------------------------- */ + +/* Copies LEN bytes from BUF to DEV, using STAGING_BUF to do buffering of + partial blocks, and returning the amount actually written in AMOUNT. + *OFFS is incremented to reflect the amount read/written. If an error + occurs, the error code is returned, otherwise 0. */ +error_t +buffered_write(struct dev *dev, vm_address_t staging_buf, + vm_address_t buf, vm_size_t len, vm_size_t *amount, + vm_offset_t *offs) +{ + error_t err = 0; + int bsize = dev->block_size; + int staging_buf_loc = *offs % bsize; + int left_in_staging_buf = bsize - staging_buf_loc; + vm_offset_t start_offs = *offs; + + if (left_in_staging_buf > 0) + /* Write what's buffered from the last I/O. */ + { + /* Amount of the current i/o we can put in the staging buffer. */ + int stage = (left_in_staging_buf > len ? len : left_in_staging_buf); + + bcopy((char *)buf, (char *)staging_buf + staging_buf_loc, stage); + + buf += stage; + len -= stage; + *offs += stage; + + if (stage == left_in_staging_buf) + /* We've filled up STAGING_BUF so we can write it out now. */ + { + /* Backup OFFS to reflect the beginning-of-block position. */ + *offs -= bsize; + err = dev_write(dev, staging_buf, bsize, offs); + } + } + + if (!err && len > bsize) + /* Enough i/o pending to do whole block transfers. */ + { + /* The number of bytes at the end of the transfer that aren't a + multiple of the block-size. We have to deal with these separately + because device i/o must be in block multiples. */ + int excess = len % bsize; + vm_size_t block_len = len - excess; + + if (dev_write_valid(dev, buf, block_len, offs)) + /* BUF is page-aligned, so we can do i/o directly to the device, or + it is small enough that it doesn't matter. */ + err = dev_write(dev, buf, block_len, offs); + else + /* Argh! BUF isn't page aligned! We must filter the i/o though an + intermediate buffer... */ + err = copying_block_write(dev, staging_buf, + buf, block_len, block_len, offs); + + if (*offs - start_offs < left_in_staging_buf + block_len) + /* Didn't write out all the blocks, so suppress buffering the rest. */ + len = 0; + else + len = excess; + } + + /* At this point, LEN should be < BLOCK_SIZE, so we use buffering again. */ + if (!err && len > 0) + { + bcopy((char *)staging_buf, (char *)buf, len); + *offs += len; + } + + *amount = *offs - start_offs; + if (*amount > 0) + /* If an error occurred, but we successfully wrote *something*, then + pretend nothing bad happened; the error will probably get caught next + time. */ + err = 0; + + return err; +} + +/* ---------------------------------------------------------------- */ + +/* Reads AMOUNT bytes from DEV and returns them in BUF and BUF_LEN (using the + standard mach out-array conventions), using STAGING_BUF to do buffering of + partial blocks. *OFFS is incremented to reflect the amount read/written. + If an error occurs, the error code is returned, otherwise 0. */ +error_t +buffered_read (struct dev *dev, vm_address_t staging_buf, + vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, + vm_offset_t *offs) +{ + error_t err = 0; + int bsize = dev->block_size; + vm_offset_t start_offs = *offs; + int staging_buf_loc = *offs % bsize; + int from_staging_buf = bsize - staging_buf_loc; + vm_address_t block_buf = *buf; + vm_size_t block_buf_size = *buf_len; + vm_size_t block_amount = amount; + + if (staging_buf_loc > 0) + { + /* Read into a temporary buffer. */ + block_buf = 0; + block_buf_size = 0; + + if (from_staging_buf > amount) + from_staging_buf = amount; + + block_amount -= from_staging_buf; + } + else + from_staging_buf = 0; + + /* Read any new block required. */ + if (block_amount > 0) + { + /* We read enough to get every full block of BLOCK_AMOUNT, plus an + additional whole block if there's any more; we just copy any excess + from that last block into STAGING_BUF for next time. */ + block_amount = ((block_amount + bsize - 1) / bsize) * bsize; + + err = dev_read(dev, &block_buf, &block_buf_size, block_amount, offs); + if (err && staging_buf_loc > 0) + /* We got an error, but don't abort, since we did get the bit from + the buffer. */ + { + err = 0; + amount = from_staging_buf; + block_amount = 0; + } + + if (amount > *offs - start_offs) + /* If we read less than we hoped, reflect this down below. */ + amount = *offs - start_offs; + } + + if (staging_buf_loc > 0) + /* Coalesce what we have in STAGING_BUF with what we read. */ + { + err = allocate(buf, buf_len, amount); + assert_perror(err); + bcopy((char *)staging_buf + staging_buf_loc, (char *)*buf, + from_staging_buf); + + if (block_amount > 0) + bcopy((char *)block_buf, (char *)*buf + from_staging_buf, + amount - from_staging_buf); + } + else + /* Otherwise, BLOCK_BUF should already contain the correct data. */ + { + *buf = block_buf; + *buf_len = block_buf_size; + } + + if (*offs - start_offs > amount) + /* We've read too far, so put some amount from the end back into + STAGING_BUF. */ + { + int excess = (*offs - start_offs) - amount; + + bcopy((char *)block_buf + amount, + (char *)staging_buf + bsize - excess, + excess); + *offs -= excess; + + if (excess >= vm_page_size) + deallocate_excess(*buf, *buf_len, excess); + *buf_len -= excess; + } + + /* Deallocate any extra copy buffer if necessary. */ + if (*buf != block_buf) + vm_deallocate(mach_task_self(), block_buf, block_buf_size); + + return err; +} + +/* ---------------------------------------------------------------- */ + +/* Write BUF_LEN bytes from BUF to DEV, padding with zeros as necessary to + write whole blocks, and returning the amount actually written in AMOUNT. + If successful, 0 is returned, otherwise an error code is returned. *OFFS + is incremented by the change in device location. */ +error_t +raw_write(struct dev *dev, + vm_address_t buf, vm_size_t buf_len, + vm_size_t *amount, vm_offset_t *offs) +{ + error_t err; + int bsize = dev->block_size; + int block_amount = ((buf_len + bsize - 1) / bsize) * bsize; + vm_offset_t start_offs = *offs; + + if (block_amount == buf_len && dev_write_valid(dev, buf, block_amount, offs)) + /* BUF is page-aligned, so we can do i/o directly to the device, or + it is small enough that it doesn't matter. */ + err = dev_write(dev, buf, block_amount, offs); + else + /* Argh! BUF isn't page aligned! We must filter the i/o though an + intermediate buffer... [We use DEV's io_state buffer, as we know + that the io_state is locked in open_rdwr, and it isn't otherwise + used...] */ + err = copying_block_write(dev, dev->io_state.buffer, + buf, buf_len, block_amount, offs); + + if (!err && *offs - start_offs < buf_len) + *amount = *offs - start_offs; + else + *amount = buf_len; + + return err; +} + +/* Read AMOUNT bytes from DEV into BUF and BUF_LEN; only whole blocks are + read, but anything greater than *AMOUNT bytes is discarded. The standard + mach out-array convention is used to return the data in BUF and BUF_LEN. + If successful, 0 is returned, otherwise an error code is returned. *OFFS + is incremented by the change in device location. */ +error_t +raw_read(struct dev *dev, + vm_address_t *buf, vm_size_t *buf_len, + vm_size_t amount, vm_offset_t *offs) +{ + error_t err; + int bsize = dev->block_size; + int block_amount = ((amount + bsize - 1) / bsize) * bsize; + err = dev_read(dev, buf, buf_len, block_amount, offs); + + if (!err) + { + int excess = *buf_len - amount; + if (excess > vm_page_size) + deallocate_excess(*buf, *buf_len, excess); + if (excess > 0) + *buf_len = amount; + } + + return err; +} + +/* ---------------------------------------------------------------- */ + +struct rdwr_state +{ + struct dev *dev; + off_t user_offs; + vm_offset_t *offs_p; + struct io_state *io_state; +}; + +/* Setup state needed for I/O to/from OPEN, putting it into STATE. OFFS + should be the original user-supplied offset. */ +static void +rdwr_state_init(struct rdwr_state *state, struct open *open, off_t offs) +{ + state->dev = open->dev; + state->io_state = open_get_io_state(open); + state->user_offs = offs; + + if (dev_is(state->dev, DEV_SERIAL)) + /* For serial i/o, we always ignore the proffered offs, and use the + actual device offset. */ + state->user_offs = -1; + + if (state->user_offs == -1 || !dev_is(state->dev, DEV_BUFFERED)) + /* If we're going to use some bit of IO_STATE, lock it first. This + should only not happen if we're going to used windowed i/o with an + explicit offset. */ + io_state_lock(state->io_state); + + if (state->user_offs == -1) + state->offs_p = &state->io_state->location; + else + state->offs_p = (vm_offset_t *)&state->user_offs; +} + +/* Destroy any state created by rdwr_state_init. */ +static void +rdwr_state_finalize(struct rdwr_state *state) +{ + if (state->user_offs == -1 || !dev_is(state->dev, DEV_BUFFERED)) + io_state_unlock(state->io_state); +} + +/* ---------------------------------------------------------------- */ + +/* Writes up to LEN bytes from BUF to OPEN's device at device offset OFFS + (which may be ignored if the device doesn't support random access), + and returns the number of bytes written in AMOUNT. If no error occurs, + zero is returned, otherwise the error code is returned. */ +error_t +open_write(struct open *open, vm_address_t buf, vm_size_t len, + vm_size_t *amount, off_t offs) +{ + error_t err; + struct rdwr_state state; + struct dev *dev = open->dev; +#ifdef MSG + off_t start_offs; +#endif + + rdwr_state_init(&state, open, offs); + +#ifdef MSG + start_offs = *state.offs_p; +#endif + + if (!dev_is(dev, DEV_BUFFERED)) + err = raw_write(dev, buf, len, amount, state.offs_p); + else if (dev_is(dev, DEV_SERIAL)) + { + state.io_state->buffer_use = IO_STATE_BUFFERED_WRITE; + err = buffered_write(dev, state.io_state->buffer, buf, len, + amount, state.offs_p); + } + else + err = window_write(open->window, buf, len, amount, state.offs_p); + +#ifdef MSG + if (debug) + { + char *mode = + (dev_is(dev, DEV_BUFFERED) + ? dev_is(dev, DEV_SERIAL) ? "buffered" : "windowed" : "raw"); + char *estr = err ? strerror(err) : "OK"; + char *bstr = err ? "-" : brep(buf, len); + + mutex_lock(&debug_lock); + fprintf(debug, "open_rdwr:\n using %s offset\n", + (offs == -1 || !dev_is(dev, DEV_BUFFERED)) + ? (state.offs_p == &dev->io_state.location + ? "device" : "open") + : "msg"); + fprintf(debug, " %s write(%s, %d, %d) => %s, %d\n", + mode, bstr, len, (int)start_offs, estr, *amount); + fprintf(debug, " offset = %d\n", (int)*state.offs_p); + mutex_unlock(&debug_lock); + } +#endif + + rdwr_state_finalize(&state); + + return err; +} + +/* Reads up to AMOUNT bytes from the device into BUF and BUF_LEN using the + standard mach out-array convention. If no error occurs, zero is returned, + otherwise the error code is returned. */ +error_t +open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, + vm_size_t amount, off_t offs) +{ + error_t err; + struct rdwr_state state; + struct dev *dev = open->dev; +#ifdef MSG + off_t start_offs; +#endif + + rdwr_state_init(&state, open, offs); + +#ifdef MSG + start_offs = *state.offs_p; +#endif + + if (!dev_is(dev, DEV_BUFFERED)) + err = raw_read(dev, buf, buf_len, amount, state.offs_p); + else if (dev_is(dev, DEV_SERIAL)) + { + state.io_state->buffer_use = IO_STATE_BUFFERED_READ; + err = buffered_read(dev, state.io_state->buffer, buf, buf_len, + amount, state.offs_p); + } + else + err = window_read(open->window, buf, buf_len, amount, state.offs_p); + +#ifdef MSG + if (debug) + { + char *mode = + (dev_is(dev, DEV_BUFFERED) + ? dev_is(dev, DEV_SERIAL) ? "buffered" : "windowed" : "raw"); + char *estr = err ? strerror(err) : "OK"; + char *bstr = err ? "-" : brep(*buf, *buf_len); + + mutex_lock(&debug_lock); + fprintf(debug, "open_rdwr:\n using %s offset\n", + (offs == -1 || !dev_is(dev, DEV_BUFFERED)) + ? (state.offs_p == &dev->io_state.location + ? "device" : "open") + : "msg"); + fprintf(debug, " %s read(%d, %d) => %s, %s, %d\n", + mode, amount, (int)start_offs, estr, bstr, *buf_len); + fprintf(debug, " offset = %d\n", (int)*state.offs_p); + mutex_unlock(&debug_lock); + } +#endif + + rdwr_state_finalize(&state); + + return err; +} diff --git a/devio/window.c b/devio/window.c new file mode 100644 index 00000000..26c6fd33 --- /dev/null +++ b/devio/window.c @@ -0,0 +1,200 @@ +/* Window management routines for buffered I/O using VM. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 + +#include "window.h" +#include "mem.h" + +#include "dev.h" /* for MSG & debug */ + +/* ---------------------------------------------------------------- */ + +/* Create a VM window onto the memory object MEMOBJ, and return it in WIN. + MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window + will shrink/grow to (a value of 0 will use some default). */ +error_t +window_create(mach_port_t memobj, + vm_size_t min_size, vm_size_t max_size, int read_only, + struct window **win) +{ + *win = malloc(sizeof(struct window)); + if (*win == NULL) + return ENOMEM; + + if (min_size < max_size) + min_size = max_size; + + (*win)->location = 0; + (*win)->size = 0; + (*win)->memobj = memobj; + (*win)->min_size = (min_size < vm_page_size ? vm_page_size : min_size); + (*win)->max_size = (max_size < vm_page_size ? vm_page_size : max_size); + (*win)->read_only = read_only; + + return 0; +} + +/* Free WIN and any resources it holds. */ +void +window_free(struct window *win) +{ + if (win->size > 0) + vm_deallocate(mach_task_self(), win->buffer, win->size); + mach_port_destroy(mach_task_self(), win->memobj); + free(win); +} + +/* ---------------------------------------------------------------- */ + +/* Makes sure that WIN's memory window contains at least positions POS + through POS + LEN on the device WIN's mapping. If an error occurs in the + process, the error code is returned (and WIN may not map the desired + locations), otherwise 0. WIN is assumed to already be locked when this is + called. */ +static error_t +position(struct window *win, vm_offset_t pos, vm_size_t len) +{ + vm_offset_t end = pos + len; + vm_offset_t win_beg = win->location; + vm_offset_t win_end = win_beg + win->size; + +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "position: need window on 0x%x[%d]\n", pos, len); + mutex_unlock(&debug_lock); + } +#endif + + if (pos >= win_beg && end <= win_end) + /* The request is totally satisfied by our current position. */ + return 0; + else +#if 0 /* XXXXXXX */ + if (end < win_beg || pos >= win_end) + /* The desired locations are entirely outside our current window, so just + trash it, and map a new buffer anywhere. */ +#endif + { + int prot = VM_PROT_READ | (win->read_only ? 0 : VM_PROT_WRITE); + + if (win->size > 0) + { +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "position: deallocating window 0x%x[%d]\n", + win_beg, win->size); + mutex_unlock(&debug_lock); + } +#endif + vm_deallocate(mach_task_self(), win->buffer, win->size); + } + + win->location = trunc_page(pos); + win->size = round_page(len + (pos - win->location)); + win->buffer = 0; + + if (win->size < win->min_size) + win->size = win->min_size; + +#ifdef MSG + if (debug) + { + mutex_lock(&debug_lock); + fprintf(debug, "position: mapping window 0x%x[%d]\n", + win->location, win->size); + mutex_unlock(&debug_lock); + } +#endif + + return + vm_map(mach_task_self(), &win->buffer, win->size, 0, 1, + win->memobj, win->location, 0, prot, prot, VM_INHERIT_NONE); + } + + return 0; +} + + +/* ---------------------------------------------------------------- */ + +/* Write up to BUF_LEN bytes from BUF to the device that WIN is a window on, + at offset *OFFS, using memory-mapped buffered I/O. If successful, 0 is + returned, otherwise an error code is returned. *OFFS is incremented by + the amount sucessfully written. */ +error_t +window_write(struct window *win, + vm_address_t buf, vm_size_t buf_len, vm_size_t *amount, + vm_offset_t *offs) +{ + error_t err; + + mutex_lock(&win->lock); + + err = position(win, *offs, buf_len); + if (!err) + { + bcopy((char *)buf, + (char *)win->buffer + (*offs - win->location), + buf_len); + *amount = buf_len; + *offs += buf_len; + } + + mutex_unlock(&win->lock); + + return err; +} + +/* Read up to AMOUNT bytes from the device that WIN is a window on, at offset + *OFFS, into BUF and BUF_LEN (using the standard mach out-array + conventions), using memory-mapped buffered I/O. If successful, 0 is + returned, otherwise an error code is returned. *OFFS is incremented by + the amount sucessfully written. */ +error_t +window_read(struct window *win, + vm_address_t *buf, vm_size_t *buf_len, + vm_size_t amount, vm_offset_t *offs) +{ + error_t err; + + mutex_lock(&win->lock); + + err = position(win, *offs, amount); + if (!err) + { + err = allocate(buf, buf_len, amount); + if (!err) + { + bcopy((char *)win->buffer + (*offs - win->location), + (char *)*buf, + amount); + *offs += amount; + } + } + + mutex_unlock(&win->lock); + + return err; +} diff --git a/devio/window.h b/devio/window.h new file mode 100644 index 00000000..4bd6301c --- /dev/null +++ b/devio/window.h @@ -0,0 +1,82 @@ +/* Window management routines for buffered I/O using VM. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 __WINDOW_H__ +#define __WINDOW_H__ + +#include + +/* ---------------------------------------------------------------- */ + +/* A structure describing a memory window used to do buffered random access + device i/o through the device pager. */ +struct window +{ + /* The currently allocated vm window backed by the device pager. */ + vm_address_t buffer; + + /* The device offset of the window. */ + vm_offset_t location; + + /* The length of the window (should be a multiple of __vm_page_size). If + this is 0, this window isn't allocated. */ + vm_size_t size; + /* If SIZE < MIN_SIZE we won't shrink the window. */ + vm_size_t min_size; + /* If SIZE > MAX_SIZE, we'll try and shrink the window to fit. */ + vm_size_t max_size; + + /* The device pager providing backing store for this window. */ + mach_port_t memobj; + /* True if the mapping should be read_only. */ + int read_only; + + /* Lock this if you want to read/write some field(s) here. */ + struct mutex lock; +}; + +/* Create a VM window onto the memory object MEMOBJ, and return it in WIN. + MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window + will shrink/grow to. */ +error_t window_create(mach_port_t memobj, + vm_size_t min_size, vm_size_t max_size, int read_only, + struct window **win); + +/* Free WIN and any resources it holds. */ +void window_free(struct window *win); + +/* Write up to BUF_LEN bytes from BUF to the device that WIN is a window on, + at offset *OFFS, using memory-mapped buffered I/O. If successful, 0 is + returned, otherwise an error code is returned. *OFFS is incremented by + the amount sucessfully written. */ +error_t window_write(struct window *win, + vm_address_t buf, vm_size_t buf_len, vm_size_t *amount, + vm_offset_t *offs); + +/* Read up to AMOUNT bytes from the device that WIN is a window on, at offset + *OFFS, into BUF and BUF_LEN (using the standard mach out-array + conventions), using memory-mapped buffered I/O. If successful, 0 is + returned, otherwise an error code is returned. *OFFS is incremented by + the amount sucessfully written. */ +error_t window_read(struct window *win, + vm_address_t *buf, vm_size_t *buf_len, + vm_size_t amount, vm_offset_t *offs); + +#endif /* !__WINDOW_H__ */ -- cgit v1.2.3 From b55fd07ab7a4d5099649576afe1f6a201e18fc60 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 5 Apr 1995 00:58:28 +0000 Subject: Initial revision --- devio/Makefile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 devio/Makefile diff --git a/devio/Makefile b/devio/Makefile new file mode 100644 index 00000000..2fcf94cd --- /dev/null +++ b/devio/Makefile @@ -0,0 +1,35 @@ +# +# Copyright (C) 1995 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 +# published by the Free Software Foundation; either version 2, 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. + +dir := devio +makemode := server + +target = devio +SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c +LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h +HURDLIBS = libtrivfs libpager libports libfshelp libthreads + +OBJS = $(SRCS:.c=.o) error.o + +CPPFLAGS += -I../lib +CPPFLAGS += $(CPPFLAGS-$(notdir $<)) + +CPPFLAGS-error.c = -Dprogram_name=program_invocation_name -DHAVE_VPRINTF -DSTDC_HEADERS -DHAVE_STRERROR + +vpath %.c ../lib + +include ../Makeconf -- cgit v1.2.3 From 38e662960bee7538161c4d3f2ff8726f4cfa5adc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 5 Apr 1995 16:59:53 +0000 Subject: (crossdir, startup, libc, crossheaders): New vars. (MIGCOM): Use $(crossdir) instead of literal string. --- =Maketools | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 7ba35ae2..6a81ad0e 100644 --- a/=Maketools +++ b/=Maketools @@ -22,13 +22,14 @@ CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 CCVERSION-duality.gnu.ai.mit.edu = 2.6.4 ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) +crossdir := /usr/local/$(CCTARGET) ifndef BUILD_CC export BUILD_CC := $(CC) endif CC=$(CCTARGET)-gcc $(CCTYPE) -O2 -pipe ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=/usr/local/i386-gnu/lib/migcom +MIGCOM=$(crossdir)/lib/migcom MIG=$(tooldir)/mig else MIGCOM=/usr/local/lib/migcom @@ -40,6 +41,10 @@ AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) +startup := $(crossdir)/lib/crt0.o +libc := $(crossdir)/lib/libc.a +crossheaders := $(crossdir)/include + INSTALL = install -c INSTALL_DATA = $(INSTALL) -m 644 INSTALL_BIN = $(INSTALL) -m 755 -- cgit v1.2.3 From 18a0d02fdb1d7ec906660142a4cd9a99ea22a955 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 9 Apr 1995 19:02:29 +0000 Subject: Add a new window field, max_pos. Rename the location field `pos'. --- devio/window.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devio/window.h b/devio/window.h index 4bd6301c..c15ebd9e 100644 --- a/devio/window.h +++ b/devio/window.h @@ -33,7 +33,9 @@ struct window vm_address_t buffer; /* The device offset of the window. */ - vm_offset_t location; + vm_offset_t pos; + /* The end of the device. */ + vm_offset_t max_pos; /* The length of the window (should be a multiple of __vm_page_size). If this is 0, this window isn't allocated. */ @@ -55,7 +57,7 @@ struct window /* Create a VM window onto the memory object MEMOBJ, and return it in WIN. MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window will shrink/grow to. */ -error_t window_create(mach_port_t memobj, +error_t window_create(mach_port_t memobj, vm_offset_t max_pos, vm_size_t min_size, vm_size_t max_size, int read_only, struct window **win); -- cgit v1.2.3 From ab9026fc6aae43119b58528592d5e75e0800dab8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 9 Apr 1995 19:03:51 +0000 Subject: (position): Use a shorter than normal window if necessary to avoid going past the end of the device. (window_create): Initialize the new MAX_POS field. Rename the location field `pos'. --- devio/window.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/devio/window.c b/devio/window.c index 26c6fd33..06f9b0fd 100644 --- a/devio/window.c +++ b/devio/window.c @@ -31,7 +31,7 @@ MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window will shrink/grow to (a value of 0 will use some default). */ error_t -window_create(mach_port_t memobj, +window_create(mach_port_t memobj, vm_offset_t max_pos, vm_size_t min_size, vm_size_t max_size, int read_only, struct window **win) { @@ -42,7 +42,8 @@ window_create(mach_port_t memobj, if (min_size < max_size) min_size = max_size; - (*win)->location = 0; + (*win)->pos = 0; + (*win)->max_pos = max_pos; (*win)->size = 0; (*win)->memobj = memobj; (*win)->min_size = (min_size < vm_page_size ? vm_page_size : min_size); @@ -73,7 +74,7 @@ static error_t position(struct window *win, vm_offset_t pos, vm_size_t len) { vm_offset_t end = pos + len; - vm_offset_t win_beg = win->location; + vm_offset_t win_beg = win->pos; vm_offset_t win_end = win_beg + win->size; #ifdef MSG @@ -111,31 +112,33 @@ position(struct window *win, vm_offset_t pos, vm_size_t len) vm_deallocate(mach_task_self(), win->buffer, win->size); } - win->location = trunc_page(pos); - win->size = round_page(len + (pos - win->location)); + win->pos = trunc_page(pos); + win->size = round_page(len + (pos - win->pos)); win->buffer = 0; if (win->size < win->min_size) win->size = win->min_size; + if (win->pos + win->size > win->max_pos) + win->size = win->max_pos - win->pos; + #ifdef MSG if (debug) { mutex_lock(&debug_lock); fprintf(debug, "position: mapping window 0x%x[%d]\n", - win->location, win->size); + win->pos, win->size); mutex_unlock(&debug_lock); } #endif return vm_map(mach_task_self(), &win->buffer, win->size, 0, 1, - win->memobj, win->location, 0, prot, prot, VM_INHERIT_NONE); + win->memobj, win->pos, 0, prot, prot, VM_INHERIT_NONE); } return 0; } - /* ---------------------------------------------------------------- */ @@ -156,7 +159,7 @@ window_write(struct window *win, if (!err) { bcopy((char *)buf, - (char *)win->buffer + (*offs - win->location), + (char *)win->buffer + (*offs - win->pos), buf_len); *amount = buf_len; *offs += buf_len; @@ -187,7 +190,7 @@ window_read(struct window *win, err = allocate(buf, buf_len, amount); if (!err) { - bcopy((char *)win->buffer + (*offs - win->location), + bcopy((char *)win->buffer + (*offs - win->pos), (char *)*buf, amount); *offs += amount; -- cgit v1.2.3 From f2ea86328f690fef084d422d0281a20e6ebdc4bc Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 9 Apr 1995 19:04:36 +0000 Subject: Read or write partial pages at the end of the device. --- devio/devpager.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/devio/devpager.c b/devio/devpager.c index 9ed5bd3e..ab3da34a 100644 --- a/devio/devpager.c +++ b/devio/devpager.c @@ -41,26 +41,36 @@ error_t pager_read_page(struct user_pager_info *upi, vm_offset_t page, vm_address_t *buf, int *writelock) { + error_t err; int read; /* bytes actually read */ + int want = vm_page_size; /* bytes we want to read */ struct dev *dev = (struct dev *)upi; - error_t err = - device_read(dev->port, - 0, page / dev->dev_block_size, vm_page_size, - (io_buf_ptr_t *)buf, &read); + + if (page + want > dev->size) + /* Read a partial page if necessary to avoid reading off the end. */ + want = dev->size - page; + + err = device_read(dev->port, 0, page / dev->dev_block_size, want, + (io_buf_ptr_t *)buf, &read); #ifdef MSG if (debug) { mutex_lock(&debug_lock); fprintf(debug, "device_read(%d, %d) [pager] => %s, %s, %d\n", - page / dev->dev_block_size, vm_page_size, + page / dev->dev_block_size, want, strerror(err), err ? "-" : brep(*buf, read), read); mutex_unlock(&debug_lock); } #endif + if (!err && want < vm_page_size) + /* Zero anything we didn't read. Allocation only happens in page-size + multiples, so we know we can write there. */ + bzero((char *)*buf + want, vm_page_size - want); + *writelock = (dev->flags & DEV_READONLY); - if (err || read < vm_page_size) + if (err || read < want) return EIO; else return 0; @@ -79,12 +89,16 @@ pager_write_page(struct user_pager_info *upi, return EROFS; else { + error_t err; int written; - error_t err = - device_write(dev->port, - 0, page / dev->dev_block_size, - (io_buf_ptr_t)buf, vm_page_size, - &written); + int want = vm_page_size; + + if (page + want > dev->size) + /* Write a partial page if necessary to avoid reading off the end. */ + want = dev->size - page; + + err = device_write(dev->port, 0, page / dev->dev_block_size, + (io_buf_ptr_t)buf, want, &written); #ifdef MSG if (debug) { @@ -99,7 +113,7 @@ pager_write_page(struct user_pager_info *upi, vm_deallocate(mach_task_self(), buf, vm_page_size); - if (err || written < vm_page_size) + if (err || written < want) return EIO; else return 0; -- cgit v1.2.3 From b2d7c55eb720c1c0005f553937c8eb03a0a72dc4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 14:26:36 +0000 Subject: (open_create): Supply our device's size when creating a window. --- devio/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devio/open.c b/devio/open.c index 64d62bfe..bab4fe99 100644 --- a/devio/open.c +++ b/devio/open.c @@ -49,7 +49,7 @@ open_create(struct dev *dev, struct open **open) err = dev_get_memory_object(dev, &memobj); if (!err) err = - window_create(memobj, 0, 0, dev_is(dev, DEV_READONLY), + window_create(memobj, dev->size, 0, 0, dev_is(dev, DEV_READONLY), &(*open)->window); /* XXX sizes */ if (err) { -- cgit v1.2.3 From fbe1a999161968d717a4c62f9bbf593324190188 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 15:38:06 +0000 Subject: (main, check_open_hook, close_device, trivfs_goaway): Add a new lock, device_lock, and use it to control access to the DEVICE variable. (open_hook, trivfs_modify_stat, trivfs_S_fys_syncfs): Copy DEVICE before using it, so it doesn't change underneath us. (clean_exit): Add a new argument that says whether to aquire a lock before doing our work. (ports_notice_idle, ports_no_live_ports): Use it. (close_device): New function, closes DEVICE cleanly. (clean_exit, ports_no_hard_ports): Use close_device. (main): Use trivfs_startup instead of doing it manually. (trivfs_goaway): Try and do it better, paying attention to flags, etc.; this still isn't right though, we may want to wait for the ports library to be fixed first. (DEBUG): New macro, executes its arg with debug_lock locked. --- devio/devio.c | 205 +++++++++++++++++++++++----------------------------------- 1 file changed, 81 insertions(+), 124 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index 05343b7e..deeebf7e 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -33,6 +33,16 @@ #include "open.h" #include "dev.h" #include "ptypes.h" + +#ifdef MSG +#define DEBUG(what) \ + ((debug) \ + ? ({ mutex_lock(&debug_lock); what; mutex_unlock(&debug_lock);0;}) \ + : 0) +#else +#define DEBUG(what) 0 +#endif + /* ---------------------------------------------------------------- */ @@ -88,6 +98,8 @@ static struct option options[] = /* A struct dev for the open kernel device. */ static struct dev *device = NULL; +/* And a lock to arbitrate changes to it. */ +static struct mutex device_lock; /* Desired device parameters specified by the user. */ static char *device_name = NULL; @@ -104,11 +116,9 @@ struct mutex debug_lock; void main(int argc, char *argv[]) { + int opt; error_t err; mach_port_t bootstrap; - int opt; - struct trivfs_control *trivfs_control; - mach_port_t realnode, control; while ((opt = getopt_long(argc, argv, SHORT_OPTIONS, options, 0)) != EOF) switch (opt) @@ -138,25 +148,18 @@ void main(int argc, char *argv[]) device_name = argv[optind]; - _libports_initialize(); - task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap == MACH_PORT_NULL) error(2, 0, "Must be started as a translator"); /* Reply to our parent */ - control = trivfs_handle_port (MACH_PORT_NULL, PT_FSYS, PT_NODE); - err = fsys_startup (bootstrap, control, MACH_MSG_TYPE_MAKE_SEND, &realnode); - - /* Install the returned realnode for trivfs's use */ - trivfs_control = ports_check_port_type (control, PT_FSYS); - assert (trivfs_control); - ports_change_hardsoft (trivfs_control, 1); - trivfs_control->underlying = realnode; - ports_done_with_port (trivfs_control); + err = trivfs_startup(bootstrap, PT_FSYS, PT_NODE, NULL); + if (err) + error(3, err, "Contacting parent"); /* Open the device only when necessary. */ device = NULL; + mutex_init(&device_lock); /* Launch. */ ports_manage_port_operations_multithread (); @@ -175,6 +178,7 @@ check_open_hook (struct trivfs_control *trivfs_control, { error_t err = 0; + mutex_lock(&device_lock); if (device == NULL) /* Try and open the device. */ { @@ -186,6 +190,7 @@ check_open_hook (struct trivfs_control *trivfs_control, error, as this allows stat to word correctly. XXX */ err = 0; } + mutex_unlock(&device_lock); return err; } @@ -193,8 +198,9 @@ check_open_hook (struct trivfs_control *trivfs_control, static void open_hook(struct trivfs_peropen *peropen) { - if (device) - open_create(device, (struct open **)&peropen->hook); + struct dev *dev = device; + if (dev) + open_create(dev, (struct open **)&peropen->hook); } static void @@ -205,38 +211,34 @@ close_hook(struct trivfs_peropen *peropen) } static void -clean_exit(int status) +close_device(int aquire_lock) { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "cleaning up and exiting (status = %d)...\n", status); - mutex_unlock(&debug_lock); - } -#endif + DEBUG(fprintf(debug, "Closing device\n")); + if (aquire_lock) + mutex_lock(&device_lock); if (device) { dev_close(device); device = NULL; } -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "Bye!\n"); - fclose(debug); - debug = NULL; - mutex_unlock(&debug_lock); - } -#endif + if (aquire_lock) + mutex_unlock(&device_lock); +} + +static void +clean_exit(int status, int aquire_lock) +{ + DEBUG(fprintf(debug, "Cleaning up and exiting (status = %d)...\n", status)); + close_device(aquire_lock); + DEBUG({fprintf(debug, "Bye!\n"); fclose(debug); debug = NULL;}); + exit(0); } /* ---------------------------------------------------------------- */ /* Trivfs hooks */ int trivfs_fstype = FSTYPE_DEV; -int trivfs_fsid = 0; /* ??? */ +int trivfs_fsid = 0; int trivfs_support_read = 1; int trivfs_support_write = 1; @@ -252,21 +254,23 @@ int trivfs_cntl_nporttypes = 1; void trivfs_modify_stat (struct stat *st) { - if (device) + struct dev *dev = device; + + if (dev) { - vm_size_t size = device->size; + vm_size_t size = dev->size; - if (device->block_size > 1) - st->st_blksize = device->block_size; + if (dev->block_size > 1) + st->st_blksize = dev->block_size; st->st_size = size; st->st_blocks = size / 512; - if (dev_is(device, DEV_READONLY)) + if (dev_is(dev, DEV_READONLY)) st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); st->st_mode &= ~S_IFMT; - st->st_mode |= dev_is(device, DEV_BUFFERED) ? S_IFBLK : S_IFCHR; + st->st_mode |= dev_is(dev, DEV_BUFFERED) ? S_IFBLK : S_IFCHR; } else /* Try and do things without an open device... */ @@ -280,31 +284,27 @@ trivfs_modify_stat (struct stat *st) st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); } - st->st_fstype = FSTYPE_DEV; st->st_rdev = device_number; } error_t trivfs_goaway (int flags, mach_port_t realnode, int ctltype, int pitype) { - if (device != NULL && !(flags & FSYS_GOAWAY_FORCE)) - /* By default, don't go away if there are still opens on this device. */ - return EBUSY; - -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "trivfs_goaway(0x%x, %d, %d, %d)\n", - flags, realnode, ctltype, pitype); - mutex_unlock(&debug_lock); - } -#endif - - if (flags & FSYS_GOAWAY_NOSYNC) - exit(0); - else - clean_exit(0); + DEBUG(fprintf(debug, "trivfs_goaway(0x%x, %d, %d, %d)\n", + flags, realnode, ctltype, pitype)); + + mutex_lock(&device_lock); + if (device == NULL || (flags & FSYS_GOAWAY_FORCE)) + /* Go away immediately. */ + if (flags & FSYS_GOAWAY_NOSYNC) + /* Don't clean up. */ + exit(0); + else + clean_exit(0, FALSE); + mutex_lock(&device_lock); + + /* Complain that there are still users. */ + return EBUSY; } /* If this variable is set, it is called every time an open happens. @@ -335,16 +335,12 @@ trivfs_S_fsys_syncfs (struct trivfs_control *cntl, mach_port_t reply, mach_msg_type_name_t replytype, int wait, int dochildren) { -#ifdef MSG - if (debug && device) - { - mutex_lock(&debug_lock); - fprintf(debug, "syncing filesystem...\n"); - mutex_unlock(&debug_lock); - } -#endif - if (device) - return dev_sync(device, wait); + struct dev *dev = device; + + DEBUG(fprintf(debug, "Syncing filesystem...\n")); + + if (dev) + return dev_sync(dev, wait); else return 0; } @@ -361,32 +357,20 @@ void (*ports_cleanroutines[])(void *) = int ports_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - error_t err; + int ok; #ifdef MSG static int next_msg_num = 0; int msg_num; - - if (debug) - { - mutex_lock(&debug_lock); - msg_num = next_msg_num++; - fprintf(debug, "port_demuxer(%d) [%d]\n", inp->msgh_id, msg_num); - mutex_unlock(&debug_lock); - } #endif - err = pager_demuxer(inp, outp) || trivfs_demuxer(inp, outp); + DEBUG(msg_num = next_msg_num++; + fprintf(debug, "port_demuxer(%d) [%d]\n", inp->msgh_id, msg_num);); -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "port_demuxer(%d) [%d] done!\n", inp->msgh_id, msg_num); - mutex_unlock(&debug_lock); - } -#endif + ok = pager_demuxer(inp, outp) || trivfs_demuxer(inp, outp); - return err; + DEBUG(fprintf(debug, "port_demuxer(%d) [%d] done!\n", inp->msgh_id,msg_num)); + + return ok; } /* This will be called whenever there have been no requests to the server for @@ -397,17 +381,9 @@ ports_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) void ports_notice_idle (int nhard, int nsoft) { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "ports_notice_idle(%d, %d)\n", nhard, nsoft); - mutex_unlock(&debug_lock); - } - else -#endif - if (nhard == 0) - clean_exit(0); + DEBUG(fprintf(debug, "ports_notice_idle(%d, %d)\n", nhard, nsoft)); + if (nhard == 0) + clean_exit(0, TRUE); } /* This will be called whenever there are no hard ports or soft ports @@ -416,16 +392,8 @@ ports_notice_idle (int nhard, int nsoft) void ports_no_live_ports () { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "ports_no_live_ports()\n"); - mutex_unlock(&debug_lock); - } - else -#endif - clean_exit(0); + DEBUG(fprintf(debug, "ports_no_live_ports()\n")); + clean_exit(0, TRUE); } /* This will be called whenever there are no hard ports allocated but there @@ -435,17 +403,6 @@ ports_no_live_ports () void ports_no_hard_ports () { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "ports_no_hard_ports()\n"); - mutex_unlock(&debug_lock); - } -#endif - if (device != NULL) - { - dev_close(device); - device = NULL; - } + DEBUG(fprintf(debug, "ports_no_hard_ports()\n")); + close_device(TRUE); } -- cgit v1.2.3 From 67b1677d475055fda642dc8b2fd8324303e428e4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 16:16:03 +0000 Subject: (open_write, open_read): Bounds check I/O. --- devio/rdwr.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/devio/rdwr.c b/devio/rdwr.c index 99ba9414..cda7635d 100644 --- a/devio/rdwr.c +++ b/devio/rdwr.c @@ -366,15 +366,14 @@ open_write(struct open *open, vm_address_t buf, vm_size_t len, error_t err; struct rdwr_state state; struct dev *dev = open->dev; -#ifdef MSG - off_t start_offs; -#endif rdwr_state_init(&state, open, offs); -#ifdef MSG - start_offs = *state.offs_p; -#endif + offs = *state.offs_p; + if (offs < 0) + return EINVAL; + if (offs + len > dev->size) + return EIO; if (!dev_is(dev, DEV_BUFFERED)) err = raw_write(dev, buf, len, amount, state.offs_p); @@ -398,12 +397,12 @@ open_write(struct open *open, vm_address_t buf, vm_size_t len, mutex_lock(&debug_lock); fprintf(debug, "open_rdwr:\n using %s offset\n", - (offs == -1 || !dev_is(dev, DEV_BUFFERED)) + (state.user_offs == -1 || !dev_is(dev, DEV_BUFFERED)) ? (state.offs_p == &dev->io_state.location ? "device" : "open") : "msg"); fprintf(debug, " %s write(%s, %d, %d) => %s, %d\n", - mode, bstr, len, (int)start_offs, estr, *amount); + mode, bstr, len, (int)offs, estr, *amount); fprintf(debug, " offset = %d\n", (int)*state.offs_p); mutex_unlock(&debug_lock); } @@ -424,15 +423,14 @@ open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, error_t err; struct rdwr_state state; struct dev *dev = open->dev; -#ifdef MSG - off_t start_offs; -#endif rdwr_state_init(&state, open, offs); -#ifdef MSG - start_offs = *state.offs_p; -#endif + offs = *state.offs_p; + if (offs < 0) + return EINVAL; + if (offs + amount > dev->size) + return EIO; if (!dev_is(dev, DEV_BUFFERED)) err = raw_read(dev, buf, buf_len, amount, state.offs_p); @@ -456,12 +454,12 @@ open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, mutex_lock(&debug_lock); fprintf(debug, "open_rdwr:\n using %s offset\n", - (offs == -1 || !dev_is(dev, DEV_BUFFERED)) + (state.user_offs == -1 || !dev_is(dev, DEV_BUFFERED)) ? (state.offs_p == &dev->io_state.location ? "device" : "open") : "msg"); fprintf(debug, " %s read(%d, %d) => %s, %s, %d\n", - mode, amount, (int)start_offs, estr, bstr, *buf_len); + mode, amount, (int)offs, estr, bstr, *buf_len); fprintf(debug, " offset = %d\n", (int)*state.offs_p); mutex_unlock(&debug_lock); } -- cgit v1.2.3 From 55d427cd34792e8f1f8ce0623261f0dbc55c06e2 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 16:16:30 +0000 Subject: (trivfs_S_file_truncate): Always return 0, so O_TRUNC works. --- devio/io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/devio/io.c b/devio/io.c index 855cf158..107a4c5e 100644 --- a/devio/io.c +++ b/devio/io.c @@ -212,10 +212,8 @@ trivfs_S_file_truncate (struct trivfs_protid *cred, off_t size) { if (!cred) return EOPNOTSUPP; - else if (dev_is(((struct open *)cred->po->hook)->dev, DEV_SERIAL)) - return 0; else - return EINVAL; + return 0; } /* ---------------------------------------------------------------- */ -- cgit v1.2.3 From 780b6adb8679a1616e6d62e7757e78db0520f657 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 16:17:08 +0000 Subject: Add some dependencies on include files. --- devio/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devio/Makefile b/devio/Makefile index 2fcf94cd..dd0cf16f 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -33,3 +33,8 @@ CPPFLAGS-error.c = -Dprogram_name=program_invocation_name -DHAVE_VPRINTF -DSTDC_ vpath %.c ../lib include ../Makeconf + +open.c rdwr.c window.c: window.h +dev.c devio.c devpager.c io.c iostate.c open.c rdwr.c window.c: dev.h +devio.c io.c open.c rdwr.c: open.h +dev.c io.c iostate.c: iostate.h -- cgit v1.2.3 From 5f6b2c7a0f24b2cc789470c1e154737c377300ba Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 10 Apr 1995 18:40:45 +0000 Subject: Make INSTALL_BIN use /gd4/hurd-cross/install-stripped to install binaries stripped. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 6a81ad0e..3648ab01 100644 --- a/=Maketools +++ b/=Maketools @@ -47,7 +47,7 @@ crossheaders := $(crossdir)/include INSTALL = install -c INSTALL_DATA = $(INSTALL) -m 644 -INSTALL_BIN = $(INSTALL) -m 755 +INSTALL_BIN = /gd4/hurd-cross/install-stripped #INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From 1c7ce1ac542fb8fa3f13d9a3ae5ec99823b63d6c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Apr 1995 19:46:25 +0000 Subject: Initial revision --- devio/MAKEDEV | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 devio/MAKEDEV diff --git a/devio/MAKEDEV b/devio/MAKEDEV new file mode 100644 index 00000000..356a5b02 --- /dev/null +++ b/devio/MAKEDEV @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Make standard devices +# + +PATH=/bin + +for I; do + case "$I" in + std) + settrans -cf console /hurd/term console + + settrans -cf tty /hurd/magic tty + + settrans -cf null /hurd/null + settrans -cf zero /hurd/null -z + + #settrans -cf stdin /hurd/magic fd/0 + #settrans -cf stdout /hurd/magic fd/1 + #settrans -cf stderr /hurd/magic fd/2 + ;; + + fd*|mt*) + settrans -cf r$I /hurd/devio $I + settrans -cf $I /hurd/devio -b $I + ;; + + rd*|sd*|hd*) + if expr $I : '[a-z]*[0-9][0-9]*\([a-z]*\)' > /dev/null; then + settrans -cf r$I /hurd/devio $I + settrans -cf $I /hurd/devio -b $I + else + echo 1>&2 $0: $I: Must supply a device number and partition + exit 1 + fi + ;; + + *) + echo $0: $I: Unknown device + esac +done -- cgit v1.2.3 From 6a334458e5ede3990d8bee7ce391dea0c1523753 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 11 Apr 1995 19:49:46 +0000 Subject: (DIST_FILES): New var, for MAKEDEV. (install): Depend on $(prefix)/dev/MAKEDEV. ($(prefix)/dev/MAKEDEV): New target. --- devio/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/devio/Makefile b/devio/Makefile index dd0cf16f..97d7029d 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -22,6 +22,7 @@ target = devio SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h HURDLIBS = libtrivfs libpager libports libfshelp libthreads +DIST_FILES = MAKEDEV OBJS = $(SRCS:.c=.o) error.o @@ -34,6 +35,12 @@ vpath %.c ../lib include ../Makeconf +install: $(prefix)/dev/MAKEDEV + +$(prefix)/dev/MAKEDEV: MAKEDEV + $(INSTALL_DATA) MAKEDEV $(prefix)/dev/MAKEDEV + chmod +x $(prefix)/dev/MAKEDEV + open.c rdwr.c window.c: window.h dev.c devio.c devpager.c io.c iostate.c open.c rdwr.c window.c: dev.h devio.c io.c open.c rdwr.c: open.h -- cgit v1.2.3 From 358d5da97c37c814af4124e099fb50e2189c6d1f Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 13 Apr 1995 22:38:52 +0000 Subject: (main): Don't abort if a std file descriptor is already open. --- ufs/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 5905cbb0..772f82ff 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -109,11 +109,10 @@ main (int argc, char **argv) { /* XXX let us see errors */ int fd = open ("/dev/console", O_RDWR); - assert (fd == 0); - fd = dup (0); - assert (fd == 1); - fd = dup (1); - assert (fd == 2); + while (fd >= 0 && fd < 2) + fd = dup(fd); + if (fd > 2) + close (fd); } } else -- cgit v1.2.3 From 0969306c4853977fe3a6c258196bb7dc21957bcc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 21 Apr 1995 15:44:01 +0000 Subject: (INSTALL_BIN): Reverse Miles's last change. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 3648ab01..6a81ad0e 100644 --- a/=Maketools +++ b/=Maketools @@ -47,7 +47,7 @@ crossheaders := $(crossdir)/include INSTALL = install -c INSTALL_DATA = $(INSTALL) -m 644 -INSTALL_BIN = /gd4/hurd-cross/install-stripped +INSTALL_BIN = $(INSTALL) -m 755 #INSTALL_BIN=cp machine := i386 -- cgit v1.2.3 From bab91ebc12456d8b52060d14092d3ccd1d85dcd9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 21 Apr 1995 18:17:11 +0000 Subject: Split out `std' into individual device-makers it calls. Rewrote /dev/fd stuff (still commented out). Use case built-in instead of expr program. --- devio/MAKEDEV | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 356a5b02..213d087d 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -8,34 +8,44 @@ PATH=/bin for I; do case "$I" in std) - settrans -cf console /hurd/term console - - settrans -cf tty /hurd/magic tty - - settrans -cf null /hurd/null - settrans -cf zero /hurd/null -z - - #settrans -cf stdin /hurd/magic fd/0 - #settrans -cf stdout /hurd/magic fd/1 - #settrans -cf stderr /hurd/magic fd/2 + $0 console tty null zero # fd + ;; + console) + settrans -cf console /hurd/term console ;; + tty) + settrans -cf tty /hurd/magic tty ;; + null) + settrans -cf null /hurd/null ;; + zero) + settrans -cf zero /hurd/null -z ;; + fd) + settrans -cf stdin /hurd/magic fd + ln -f -s fd/0 stdin + ln -f -s fd/1 stdout + ln -f -s fd/2 stderr ;; - fd*|mt*) + fd*|mt*) settrans -cf r$I /hurd/devio $I settrans -cf $I /hurd/devio -b $I ;; - rd*|sd*|hd*) - if expr $I : '[a-z]*[0-9][0-9]*\([a-z]*\)' > /dev/null; then + rd*|sd*|hd*) + case "$I" in + [a-z]*[0-9][0-9]*[a-z]*) settrans -cf r$I /hurd/devio $I settrans -cf $I /hurd/devio -b $I - else + ;; + *) echo 1>&2 $0: $I: Must supply a device number and partition exit 1 - fi + ;; + esac ;; *) - echo $0: $I: Unknown device - esac + echo >&2 $0: $I: Unknown device + exit 1 + ;; + esac done -- cgit v1.2.3 From 529ef4b137e4280fed13cb7b38d60c93cdd40886 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 28 Apr 1995 23:01:57 +0000 Subject: (write_all_disknodes): We have to really lock the nodes around the calls to diskfs_set_node_times and write_node; this in turn forces us to have real refereces. --- ufs/inode.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 80a5fcff..afe712f5 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -412,15 +412,31 @@ write_all_disknodes () { int n; struct node *np; - + struct item {struct item *next; struct node *np;} *list = 0; + struct item *i; + + /* Acquire a reference on all the nodes in the hash table + and enter them into a list on the stack. */ spin_lock (&diskfs_node_refcnt_lock); for (n = 0; n < INOHSZ; n++) for (np = nodehash[n]; np; np = np->dn->hnext) { - diskfs_set_node_times (np); - write_node (np); + np->references++; + i = alloc (sizeof (struct item)); + i->next = list; + i->np = np; + list = i; } spin_unlock (&diskfs_node_refcnt_lock); + + /* Update each node. */ + for (i = list; i; i = i->next) + { + mutex_lock (&i->np->lock); + diskfs_set_node_times (i->np); + write_node (i->np); + diskfs_nput (i->np); + } } void -- cgit v1.2.3 From c8de1463ad38c0e85eb722fa658d8b3ec1c9757f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 2 May 1995 15:59:06 +0000 Subject: (pager_clear_user_data): Acquire pagerlistlock around modifications to UPI->next/prevp list structure. --- ufs/pager.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index d41b792d..f403df64 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -1,5 +1,5 @@ /* Pager for ufs - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -363,9 +363,11 @@ pager_clear_user_data (struct user_pager_info *upi) upi->np->dn->fileinfo = 0; spin_unlock (&node2pagelock); diskfs_nrele_light (upi->np); + spin_lock (&pagerlistlock); *upi->prevp = upi->next; if (upi->next) upi->next->prevp = upi->prevp; + spin_unlock (&pagerlistlock); free (upi); } -- cgit v1.2.3 From a59ba4531f53f13c86243cf0bbb42e919459a1ff Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 8 May 1995 13:30:46 +0000 Subject: (write_all_disknodes): Fix typo `alloc' --> `alloca'. --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index afe712f5..6976ef78 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -422,7 +422,7 @@ write_all_disknodes () for (np = nodehash[n]; np; np = np->dn->hnext) { np->references++; - i = alloc (sizeof (struct item)); + i = alloca (sizeof (struct item)); i->next = list; i->np = np; list = i; -- cgit v1.2.3 From 4c51401dcc09332dae33bc0de3dd9fb7c14627f1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 8 May 1995 13:32:20 +0000 Subject: (diskfs_lookup): When looping back to try_again: because we're looking up "..", be sure and trash the mapping we made of the directory's pager -- otherwise the reference to the pager never gets dropped and we can never free the node. (diskfs_lookup): ds->type was being compared to LOOKING, which value it can never have. Compare ds->stat against LOOKING instead. --- ufs/dir.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 83eae80d..aeaa5abc 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -95,7 +95,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, struct node *np = 0; int retry_dotdot = 0; memory_object_t memobj; - vm_address_t buf; + vm_address_t buf = 0; vm_size_t buflen; int blockaddr; int idx; @@ -124,6 +124,11 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, ds->mapbuf = 0; ds->mapextent = 0; } + if (buf) + { + vm_deallocate (mach_task_self (), buf, buflen); + buf = 0; + } if (ds && (type == CREATE || type == RENAME)) ds->stat = LOOKING; @@ -245,7 +250,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, goto out; } - if ((type == CREATE || type == RENAME) && !np && ds && ds->type == LOOKING) + if ((type == CREATE || type == RENAME) && !np && ds && ds->stat == LOOKING) { /* We didn't find any room, so mark ds to extend the dir */ ds->type = CREATE; -- cgit v1.2.3 From e06111c17de78853d266ec48860e7db1dfbd701a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 8 May 1995 13:32:51 +0000 Subject: (pager_clear_user_data): Don't die when called on the disk pager. --- ufs/pager.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index f403df64..35bf1d22 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -358,16 +358,18 @@ pager_report_extent (struct user_pager_info *pager, void pager_clear_user_data (struct user_pager_info *upi) { - assert (upi->type == FILE_DATA); - spin_lock (&node2pagelock); - upi->np->dn->fileinfo = 0; - spin_unlock (&node2pagelock); - diskfs_nrele_light (upi->np); - spin_lock (&pagerlistlock); - *upi->prevp = upi->next; - if (upi->next) - upi->next->prevp = upi->prevp; - spin_unlock (&pagerlistlock); + if (upi->type == FILE_DATA) + { + spin_lock (&node2pagelock); + upi->np->dn->fileinfo = 0; + spin_unlock (&node2pagelock); + diskfs_nrele_light (upi->np); + spin_lock (&pagerlistlock); + *upi->prevp = upi->next; + if (upi->next) + upi->next->prevp = upi->prevp; + spin_unlock (&pagerlistlock); + } free (upi); } -- cgit v1.2.3 From 0b6693ea4058ee760740a656d832507b5bf1f9d3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 13 May 1995 09:04:01 +0000 Subject: (OBJS): Remove exec_server_image.o. (exec_server_image.o): Rule removed. --- ufs/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 7ad7cb65..f0022c91 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -20,7 +20,7 @@ makemode := server SRCS = alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS = $(SRCS:.c=.o) exec_server_image.o +OBJS = $(SRCS:.c=.o) LCLHDRS = ufs.h fs.h dinode.h dir.h REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h @@ -32,10 +32,6 @@ target = ufs include ../Makeconf -exec_server_image.o: ../exec/exec ../mkbootfs/mkbootfs - rsh $(mighost) -n cd `pwd` \; \ - ../mkbootfs/mkbootfs ../exec/exec exec_server_image.o - $(OBJS): ufs.h $(OBJS): $(REMHDRS) alloc.o: fs.h dinode.h @@ -48,6 +44,3 @@ pager.o: fs.h dinode.h sizes.o: fs.h dinode.h subr.o: fs.h tables.o: fs.h - -$(foreach dir,mkbootfs exec,../$(dir)/%): FORCE - $(MAKE) -C $(@D) $(@F) -- cgit v1.2.3 From 763cca7a08c3935945e8c29d2569e4cd85a35829 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 15 May 1995 17:14:45 +0000 Subject: (pager_clear_user_data): Doc fix. --- ufs/pager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/pager.c b/ufs/pager.c index 35bf1d22..3e9747b8 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -358,6 +358,7 @@ pager_report_extent (struct user_pager_info *pager, void pager_clear_user_data (struct user_pager_info *upi) { + /* XXX Do the right thing for the disk pager here too. */ if (upi->type == FILE_DATA) { spin_lock (&node2pagelock); -- cgit v1.2.3 From 0f348a6d19189b691dfd35cb13a18940dae82c97 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 20 May 1995 04:38:37 +0000 Subject: (CPPFLAGS): Add -I../lib, to get include lib include files, and $(CPPFLAGS-$(notdir $<)) to get file-specific cpp options. Add a vpath for %.c to ../lib, so we can use source files from there. --- ufs/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index f0022c91..d351caab 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -30,6 +30,10 @@ HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads LDFLAGS = -Wl,--no-keep-memory target = ufs +CPPFLAGS += -I../lib +CPPFLAGS += $(CPPFLAGS-$(notdir $<)) +vpath %.c ../lib + include ../Makeconf $(OBJS): ufs.h -- cgit v1.2.3 From 518e36e2049626337778af39c7cd64e4deba59ff Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 20 May 1995 04:39:22 +0000 Subject: (trans_parse_args): Use options_parse & diskfs_standard_startup_options to parse our translator options. (usage): New function. (parse_opt): New function. --- ufs/main.c | 78 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 772f82ff..d5699d51 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -26,40 +26,74 @@ #include char *ufs_version = "0.0 pre-alpha"; + +/* ---------------------------------------------------------------- */ +#define USAGE "Usage: %s [OPTION...] DEVICE\n" + +static void +usage(int status) +{ + if (status != 0) + fprintf(stderr, "Try `%s --help' for more information.\n", + program_invocation_name); + else + { + printf(USAGE, program_invocation_name); + printf("\ +\n\ + -r, --readonly disable writing to DEVICE\n\ + -w, --writable enable writing to DEVICE\n\ + -s, --sync[=INTERVAL] with an argument, sync every INTERVAL seconds,\n\ + otherwise operate in synchronous mode\n\ + -n, --nosync never sync the filesystem\n\ + --help display this help and exit\n\ + --version output version information and exit\n\ +"); + } + exit (status); +} + +#define SHORT_OPTS "" + +static struct option long_opts[] = +{ + {"help", no_argument, 0, '?'}, + {0, 0, 0, 0} +}; + +static error_t +parse_opt (int opt, char *arg) +{ + /* We currently only deal with one option... */ + if (opt != '?') + return EINVAL; + usage (0); /* never returns */ + return 0; +} /* Parse the arguments for ufs when started as a translator. */ char * trans_parse_args (int argc, char **argv) { - char *devname; - /* When started as a translator, we are called with - the device name and an optional argument -r, which - signifies read-only. */ - if (argc < 2 || argc > 3) - exit (1); + int argind; /* ARGV index of the first argument. */ + struct options options = + { SHORT_OPTS, long_opts, parse_opt, diskfs_standard_startup_options }; - if (argc == 2) - devname = argv[1]; + /* Parse our command line. */ + if (options_parse (&options, argc, argv, OPTIONS_PRINT_ERRS, &argind)) + usage (1); - else if (argc == 3) + if (argc - argind != 1) { - if (argv[1][0] == '-' && argv[1][1] == 'r') - { - diskfs_readonly = 1; - devname = argv[2]; - } - else if (argv[2][0] == '-' && argv[2][1] == 'r') - { - diskfs_readonly = 1; - devname = argv[1]; - } - else - exit (1); + fprintf (stderr, USAGE, program_invocation_name); + usage (1); } - return devname; + return argv[argind]; } + +/* ---------------------------------------------------------------- */ struct node *diskfs_root_node; -- cgit v1.2.3 From 45fb882198a129b3174548433ab635e7ec66417c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 14 Jun 1995 20:19:46 +0000 Subject: (diskfs_get_translator): Conform to new memory usage semantic. --- ufs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 6976ef78..7f302e47 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -548,8 +548,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) transloc = disk_image + fsaddr (sblock, blkno); datalen = *(u_int *)transloc; - if (datalen > *namelen) - vm_allocate (mach_task_self (), (vm_address_t *) namep, datalen, 1); + *namep = malloc (datalen); bcopy (transloc + sizeof (u_int), *namep, datalen); diskfs_end_catch_exception (); -- cgit v1.2.3 From 8422cad93ec0d573e0de38d8d2771980aaa1554d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 01:17:19 +0000 Subject: (diskfs_node_iterate): New function. (write_all_disknodes): Use it. --- ufs/inode.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 7f302e47..df5fec17 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -404,17 +404,15 @@ read_symlink_hook (struct node *np, } error_t (*diskfs_read_symlink_hook)(struct node *, char *) = read_symlink_hook; - -/* Write all active disknodes into the dinode pager. */ -void -write_all_disknodes () +error_t +diskfs_node_iterate (error_t (*fun)(struct node *)) { - int n; struct node *np; struct item {struct item *next; struct node *np;} *list = 0; struct item *i; - + error_t err; + /* Acquire a reference on all the nodes in the hash table and enter them into a list on the stack. */ spin_lock (&diskfs_node_refcnt_lock); @@ -428,16 +426,33 @@ write_all_disknodes () list = i; } spin_unlock (&diskfs_node_refcnt_lock); - - /* Update each node. */ + + err = 0; for (i = list; i; i = i->next) { - mutex_lock (&i->np->lock); - diskfs_set_node_times (i->np); - write_node (i->np); - diskfs_nput (i->np); + if (!err) + { + mutex_lock (&i->np->lock); + err = (*fun)(i->np); + mutex_unlock (&i->np->lock); + } + diskfs_nrele (i->np); } } + +/* Write all active disknodes into the dinode pager. */ +void +write_all_disknodes () +{ + error_t + helper (struct node *np) + { + diskfs_set_node_times (np); + write_node (np); + } + + diskfs_node_iterate (helper); +} void diskfs_write_disknode (struct node *np, int wait) -- cgit v1.2.3 From 8ad6fc41b13f33ed47eb9ae01cdd6230af2de327 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 01:21:01 +0000 Subject: (write_all_disknodes): Typos. --- ufs/inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index df5fec17..488b2785 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -412,6 +412,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) struct item {struct item *next; struct node *np;} *list = 0; struct item *i; error_t err; + int n; /* Acquire a reference on all the nodes in the hash table and enter them into a list on the stack. */ @@ -438,6 +439,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) } diskfs_nrele (i->np); } + return err; } /* Write all active disknodes into the dinode pager. */ @@ -449,6 +451,7 @@ write_all_disknodes () { diskfs_set_node_times (np); write_node (np); + return 0; } diskfs_node_iterate (helper); -- cgit v1.2.3 From 12235ec5d3b87c11782d39732209a39bb1e55381 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 15:48:44 +0000 Subject: (ffs_realloccg): Remove assignments from if tests. --- ufs/alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 87b0b45a..add588ee 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -211,7 +211,8 @@ ffs_realloccg(register struct node *np, if (!diskfs_isuid (0, cred) && freespace(fs, fs->fs_minfree) <= 0) goto nospace; - if (error = diskfs_catch_exception ()) + error = diskfs_catch_exception (); + if (error) return error; bprev = (dino (np->dn->number))->di_db[lbprev]; diskfs_end_catch_exception (); @@ -237,7 +238,8 @@ ffs_realloccg(register struct node *np, * Check for extension in the existing location. */ cg = dtog(fs, bprev); - if (bno = ffs_fragextend(np, cg, (long)bprev, osize, nsize)) { + bno = ffs_fragextend(np, cg, (long)bprev, osize, nsize); + if (bno) assert (bno == bprev); spin_unlock (&alloclock); np->dn_stat.st_blocks += btodb(nsize - osize); -- cgit v1.2.3 From c727e27413678eeadbc1a33df0c884a6e7775a9a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 15:50:14 +0000 Subject: (diskfs_truncate): Remove assignment from if test. --- ufs/sizes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index ef7666b1..8657ce13 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -58,7 +58,8 @@ diskfs_truncate (struct node *np, { error_t err; - if (err = diskfs_catch_exception ()) + err = diskfs_catch_exception (); + if (err) return err; bzero (di->di_shortlink + length, np->dn_stat.st_size - length); diskfs_end_catch_exception (); -- cgit v1.2.3 From 7605778aa6ae9594482df2001af816e568eb9745 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 15:51:08 +0000 Subject: (fetch_indir_spec): Remove assignment from if test. --- ufs/bmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index 0b3574b8..11756a66 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -1,5 +1,5 @@ /* Interpretation of indirect block structure - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -32,7 +32,8 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, error_t err; daddr_t *siblock; - if (err = diskfs_catch_exception ()) + err = diskfs_catch_exception (); + if (err) return err; indirs[0].offset = -2; -- cgit v1.2.3 From 84752530e00bd9cbd7d1864154802b0261a15df5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 16:02:30 +0000 Subject: (ffs_realloccg): Fix typo. --- ufs/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index add588ee..8f6a5baf 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -239,7 +239,7 @@ ffs_realloccg(register struct node *np, */ cg = dtog(fs, bprev); bno = ffs_fragextend(np, cg, (long)bprev, osize, nsize); - if (bno) + if (bno) { assert (bno == bprev); spin_unlock (&alloclock); np->dn_stat.st_blocks += btodb(nsize - osize); -- cgit v1.2.3 From bbb64744674f66556e4edf9082a11c7151876f7f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 16:07:20 +0000 Subject: (diskfs_grow): Provide initialization of POKE_OFF. --- ufs/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 8657ce13..62360e3c 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -355,7 +355,7 @@ diskfs_grow (struct node *np, int size, osize; error_t err; struct dinode *di = dino (np->dn->number); - off_t poke_off; + off_t poke_off = 0; size_t poke_len = 0; /* Zero an sblock->fs_bsize piece of disk starting at BNO, -- cgit v1.2.3 From 0c65f6707ccf315961f964c55f692e08dd894ac1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 16:19:57 +0000 Subject: (diskfs_lookup): Provide initialization for BUFLEN. (diskfs_direnter): Move assignment out of if test. --- ufs/dir.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index aeaa5abc..1d7004d8 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -96,7 +96,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, int retry_dotdot = 0; memory_object_t memobj; vm_address_t buf = 0; - vm_size_t buflen; + vm_size_t buflen = 0; int blockaddr; int idx; @@ -520,11 +520,14 @@ diskfs_direnter(struct node *dp, oldsize = dp->dn_stat.st_size; while (oldsize + DIRBLKSIZ > dp->allocsize) - if (err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred)) - { - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); - return err; - } + { + err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred); + if (err) + { + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + return err; + } + } new = (struct directory_entry *) (ds->mapbuf + oldsize); -- cgit v1.2.3 From 2f234620dce0c51e6f779fc3612ad3308c814a48 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 17:20:21 +0000 Subject: (diskfs_truncate): Use ports reference calls directly instead of pager wrappers. --- ufs/sizes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 62360e3c..0e6b893e 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -92,7 +92,7 @@ diskfs_truncate (struct node *np, spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) - pager_reference (upi->p); + ports_port_ref (upi->p); spin_unlock (&node2pagelock); if (upi) @@ -106,7 +106,7 @@ diskfs_truncate (struct node *np, mach_port_deallocate (mach_task_self (), obj); pager_flush_some (upi->p, round_page (length), np->allocsize - length, 1); - pager_unreference (upi->p); + ports_port_deref (upi->p); } rwlock_writer_lock (&np->dn->allocptrlock); @@ -263,13 +263,13 @@ diskfs_truncate (struct node *np, spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) - pager_reference (upi->p); + ports_port_ref (upi->p); spin_unlock (&node2pagelock); if (upi) { pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY, 0); - pager_unreference (upi->p); + ports_port_deref (upi->p); } return err; -- cgit v1.2.3 From a5e9c6b33951823a7bdd22dde0d6fe592068d9f8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 17:20:53 +0000 Subject: (pager_bucket): New variable. (create_disk_pager): Provide pager_bucket in call to pager_create. (diskfs_get_filemap): Likewise. (diskfs_file_update): Use ports reference calls directly instead of pager wrappers. --- ufs/pager.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 3e9747b8..935983f5 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -30,6 +30,8 @@ spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; #define MAY_CACHE 1 #endif +struct port_bucket *pager_bucket; + /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has @@ -383,7 +385,8 @@ create_disk_pager () diskpager = malloc (sizeof (struct user_pager_info)); diskpager->type = DISK; diskpager->np = 0; - diskpager->p = pager_create (diskpager, MAY_CACHE, MEMORY_OBJECT_COPY_NONE); + diskpager->p = pager_create (diskpager, pager_bucket, + MAY_CACHE, MEMORY_OBJECT_COPY_NONE); diskpagerport = pager_get_port (diskpager->p); mach_port_insert_right (mach_task_self (), diskpagerport, diskpagerport, MACH_MSG_TYPE_MAKE_SEND); @@ -401,13 +404,13 @@ diskfs_file_update (struct node *np, spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) - pager_reference (upi->p); + ports_port_ref (upi->p); spin_unlock (&node2pagelock); if (upi) { pager_sync (upi->p, wait); - pager_unreference (upi->p); + port_port_deref (upi->p); } for (d = np->dn->dirty; d; d = tmp) @@ -442,7 +445,8 @@ diskfs_get_filemap (struct node *np) upi->type = FILE_DATA; upi->np = np; diskfs_nref_light (np); - upi->p = pager_create (upi, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); + upi->p = pager_create (upi, pager_bucket, + MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; spin_lock (&pagerlistlock); -- cgit v1.2.3 From 08518ce71e29f27ff5d1dc4d0de1ba5438c44931 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 17:22:16 +0000 Subject: (create_disk_pager): Initialize pager_bucket. --- ufs/pager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index 935983f5..cdfecf95 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -382,6 +382,8 @@ pager_clear_user_data (struct user_pager_info *upi) void create_disk_pager () { + pager_bucket = ports_create_bucket (); + diskpager = malloc (sizeof (struct user_pager_info)); diskpager->type = DISK; diskpager->np = 0; -- cgit v1.2.3 From 0a05b968659e214011eb69e7ff262cde98d84b5d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 17:27:03 +0000 Subject: (create_disk_pager): Fork off service thread for pager ports. --- ufs/pager.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index cdfecf95..d972eb0f 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -382,8 +382,21 @@ pager_clear_user_data (struct user_pager_info *upi) void create_disk_pager () { + void + thread_function (any_t foo __attribute__ ((unused))) + { + for (;;) + ports_manage_port_operations_multithread (pager_bucket, + pager_demuxer, + 1000 * 60 * 2, + 1000 * 60 * 10, + 1, MACH_PORT_NULL); + } + pager_bucket = ports_create_bucket (); + cthread_detach (cthread_fork ((cthread_fn_t) thread_function, (any_t) 0)); + diskpager = malloc (sizeof (struct user_pager_info)); diskpager->type = DISK; diskpager->np = 0; -- cgit v1.2.3 From 06f996372c9d0e6d2d1ec5800eb4f0f9cfab1cc3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 17:33:49 +0000 Subject: (drop_pager_softrefs): Use ports reference calls directly instead of pager wrappers. (allow_pager_softrefs): Likewise. (pager_traverse): Likewise. (diskfs_file_update): Fix typo. --- ufs/pager.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index d972eb0f..a430c761 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -425,7 +425,7 @@ diskfs_file_update (struct node *np, if (upi) { pager_sync (upi->p, wait); - port_port_deref (upi->p); + ports_port_deref (upi->p); } for (d = np->dn->dirty; d; d = tmp) @@ -491,13 +491,13 @@ drop_pager_softrefs (struct node *np) spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) - pager_reference (upi->p); + ports_port_ref (upi->p); spin_unlock (&node2pagelock); if (MAY_CACHE && upi) pager_change_attributes (upi->p, 0, MEMORY_OBJECT_COPY_DELAY, 0); if (upi) - pager_unreference (upi->p); + ports_port_deref (upi->p); } /* Call this when we should turn on caching because it's no longer @@ -510,13 +510,13 @@ allow_pager_softrefs (struct node *np) spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) - pager_reference (upi->p); + ports_port_ref (upi->p); spin_unlock (&node2pagelock); if (MAY_CACHE && upi) pager_change_attributes (upi->p, 1, MEMORY_OBJECT_COPY_DELAY, 0); if (upi) - pager_unreference (upi->p); + ports_port_deref (upi->p); } /* Call this to find out the struct pager * corresponding to the @@ -547,7 +547,7 @@ pager_traverse (void (*func)(struct user_pager_info *)) i = alloca (sizeof (struct item)); i->next = list; list = i; - pager_reference (p->p); + ports_port_ref (p->p); i->p = p; } spin_unlock (&pagerlistlock); @@ -555,7 +555,7 @@ pager_traverse (void (*func)(struct user_pager_info *)) for (i = list; i; i = i->next) { (*func)(i->p); - pager_unreference (i->p->p); + ports_port_deref (i->p->p); } (*func)(diskpager); -- cgit v1.2.3 From 8863b992cab5e2aa552f043f3ccf6a9f77fc86b7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 18:49:52 +0000 Subject: (pager_clear_user_data): Don't maintain pager linked list. (diskfs_get_filemap): Don't maintain pager linked list. (pager_dropweak): New function. (pager_traverse): Delete function. (diskfs_shutdown_pager): Use ports_bucket_iterate instead of pager_traverse. (diskfs_sync_everything): Use ports_bucket_iterate instead of pager_traverse. --- ufs/pager.c | 73 ++++++++++++++++--------------------------------------------- 1 file changed, 19 insertions(+), 54 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index a430c761..ea5c1e66 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -19,9 +19,6 @@ #include #include -spin_lock_t pagerlistlock = SPIN_LOCK_INITIALIZER; -struct user_pager_info *filepagerlist; - spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; #ifdef DONT_CACHE_MEMORY_OBJECTS @@ -367,15 +364,16 @@ pager_clear_user_data (struct user_pager_info *upi) upi->np->dn->fileinfo = 0; spin_unlock (&node2pagelock); diskfs_nrele_light (upi->np); - spin_lock (&pagerlistlock); - *upi->prevp = upi->next; - if (upi->next) - upi->next->prevp = upi->prevp; - spin_unlock (&pagerlistlock); } free (upi); } +void +pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) +{ +} + + /* Create a the DISK pager, initializing DISKPAGER, and DISKPAGERPORT */ @@ -463,14 +461,6 @@ diskfs_get_filemap (struct node *np) upi->p = pager_create (upi, pager_bucket, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; - - spin_lock (&pagerlistlock); - upi->next = filepagerlist; - upi->prevp = &filepagerlist; - if (upi->next) - upi->next->prevp = &upi->next; - filepagerlist = upi; - spin_unlock (&pagerlistlock); } right = pager_get_port (np->dn->fileinfo->p); spin_unlock (&node2pagelock); @@ -531,64 +521,39 @@ diskfs_get_filemap_pager_struct (struct node *np) return np->dn->fileinfo->p; } -/* Call function FUNC (which takes one argument, a pager) on each pager, with - all file pagers being processed before the disk pager. Make the calls - while holding no locks. */ -static void -pager_traverse (void (*func)(struct user_pager_info *)) -{ - struct user_pager_info *p; - struct item {struct item *next; struct user_pager_info *p;} *list = 0; - struct item *i; - - spin_lock (&pagerlistlock); - for (p = filepagerlist; p; p = p->next) - { - i = alloca (sizeof (struct item)); - i->next = list; - list = i; - ports_port_ref (p->p); - i->p = p; - } - spin_unlock (&pagerlistlock); - - for (i = list; i; i = i->next) - { - (*func)(i->p); - ports_port_deref (i->p->p); - } - - (*func)(diskpager); -} - /* Shutdown all the pagers. */ void diskfs_shutdown_pager () { - void shutdown_one (struct user_pager_info *p) + error_t shutdown_one (struct pager *p) { - pager_shutdown (p->p); + /* Make sure the disk pager is done last. */ + if (p->upi != diskpager) + pager_shutdown (p); + return 0; } copy_sblock (); write_all_disknodes (); - pager_traverse (shutdown_one); + ports_bucket_iterate (pager_bucket, shutdown_one); + pager_shutdown (diskpager->p); } /* Sync all the pagers. */ void diskfs_sync_everything (int wait) { - void sync_one (struct user_pager_info *p) + error_t sync_one (struct pager *p) { + /* Make sure the disk pager is done last. */ if (p != diskpager) - pager_sync (p->p, wait); - else - sync_disk (wait); + pager_sync (p, wait); + return 0; } copy_sblock (); write_all_disknodes (); - pager_traverse (sync_one); + ports_bucket_iterate (pager_bucket, sync_one); + sync_disk (wait); } -- cgit v1.2.3 From 7e6d5b48ba4bc11693a2c61908fb1a8693c96bb0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 18:50:31 +0000 Subject: (struct user_pager_info): Drop members next and prevp. --- ufs/ufs.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index a7c9a891..aaaf4daa 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -157,7 +157,6 @@ struct user_pager_info FILE_DATA, } type; struct pager *p; - struct user_pager_info *next, **prevp; }; struct user_pager_info *diskpager; -- cgit v1.2.3 From d19a8d58ffb63f921c279e60a3fbb7092952527e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 18:57:36 +0000 Subject: (diskfs_shutdown_pager): Typos. --- ufs/pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index ea5c1e66..5237c671 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -528,7 +528,7 @@ diskfs_shutdown_pager () error_t shutdown_one (struct pager *p) { /* Make sure the disk pager is done last. */ - if (p->upi != diskpager) + if (p != diskpager->p) pager_shutdown (p); return 0; } @@ -546,7 +546,7 @@ diskfs_sync_everything (int wait) error_t sync_one (struct pager *p) { /* Make sure the disk pager is done last. */ - if (p != diskpager) + if (p != diskpager->p) pager_sync (p, wait); return 0; } -- cgit v1.2.3 From 8cced7ac1796db55319a593bb60586f68d567ecb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 21 Jun 1995 19:11:17 +0000 Subject: (diskfs_sync_everything, diskfs_shutdown_pager): Conform to prototype. --- ufs/pager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 5237c671..938e1127 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -525,8 +525,9 @@ diskfs_get_filemap_pager_struct (struct node *np) void diskfs_shutdown_pager () { - error_t shutdown_one (struct pager *p) + error_t shutdown_one (void *arg) { + struct pager *p = arg; /* Make sure the disk pager is done last. */ if (p != diskpager->p) pager_shutdown (p); @@ -543,8 +544,9 @@ diskfs_shutdown_pager () void diskfs_sync_everything (int wait) { - error_t sync_one (struct pager *p) + error_t sync_one (void *arg) { + struct pager *p = arg; /* Make sure the disk pager is done last. */ if (p != diskpager->p) pager_sync (p, wait); -- cgit v1.2.3 From 6add63967766c1078cd6c8962371c284057a192d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Jun 1995 15:41:01 +0000 Subject: (main): Have main thread exit when done instead of calling a diskfs function. --- ufs/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index d5699d51..7f507351 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -261,8 +261,8 @@ main (int argc, char **argv) /* We are the bootstrap filesystem; do special boot-time setup. */ diskfs_start_bootstrap (argv); - /* Now become a generic request thread. */ - diskfs_main_request_loop (); + /* And this thread is done with its work. */ + cthread_exit (0); } -- cgit v1.2.3 From b7e13bdf41a7c95aa9c2b7981c1e2f24e077d90e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Jun 1995 15:41:32 +0000 Subject: (HURDLIBS): Add libihash. --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index d351caab..04bb15fd 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -26,7 +26,7 @@ REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ ../hurd/ioserver.h ../hurd/fshelp.h #HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ # libfshelp libdiskfs libthreads libports -HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads +HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads libihash LDFLAGS = -Wl,--no-keep-memory target = ufs -- cgit v1.2.3 From 0740779ab1fda6298869b58ae3a6ad9a8440b2c8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Jun 1995 16:05:53 +0000 Subject: (thread_cancel): New function (HACK). --- ufs/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index 7f507351..b7a795f0 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -286,3 +286,7 @@ diskfs_init_completed () } +void +thread_cancel (mach_thread_t foo __attribute__ ((unused))) +{ +} -- cgit v1.2.3 From 2d9280333f1bf42d6a49f7a2c9772b76dee62700 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Jun 1995 16:07:56 +0000 Subject: (thread_cancel): Typo. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index b7a795f0..9541c956 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -287,6 +287,6 @@ diskfs_init_completed () void -thread_cancel (mach_thread_t foo __attribute__ ((unused))) +thread_cancel (thread_t foo __attribute__ ((unused))) { } -- cgit v1.2.3 From 7adec76824d5f9dfc7e46a114b03521aa877d505 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 22 Jun 1995 17:29:12 +0000 Subject: (thread_function): Move thread_function to be non-local, of course, because it needs to live even after create_disk_pager returns. --- ufs/pager.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 938e1127..355af46c 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -375,22 +375,21 @@ pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) +static void +thread_function (any_t foo __attribute__ ((unused))) +{ + for (;;) + ports_manage_port_operations_multithread (pager_bucket, + pager_demuxer, + 1000 * 60 * 2, + 1000 * 60 * 10, + 1, MACH_PORT_NULL); +} /* Create a the DISK pager, initializing DISKPAGER, and DISKPAGERPORT */ void create_disk_pager () { - void - thread_function (any_t foo __attribute__ ((unused))) - { - for (;;) - ports_manage_port_operations_multithread (pager_bucket, - pager_demuxer, - 1000 * 60 * 2, - 1000 * 60 * 10, - 1, MACH_PORT_NULL); - } - pager_bucket = ports_create_bucket (); cthread_detach (cthread_fork ((cthread_fn_t) thread_function, (any_t) 0)); -- cgit v1.2.3 From 55e97e3364d6dc1541814444f4116974c2013637 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Jun 1995 00:17:38 +0000 Subject: (diskfs_pager_users): New function. --- ufs/pager.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/ufs/pager.c b/ufs/pager.c index 355af46c..34c4d232 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -508,6 +508,73 @@ allow_pager_softrefs (struct node *np) ports_port_deref (upi->p); } +/* Tell diskfs if there are pagers exported, and if none, then + prevent any new ones from showing up. */ +int +diskfs_pager_users () +{ + int npagers; + + error_t block_cache (void *arg) + { + struct pager *p = arg; + + pager_change_attributes (p, 0, MEMORY_OBJECT_COPY_DELAY, 1); + return 0; + } + + error_t enable_cache (void *arg) + { + struct pager *p = arg; + struct user_pager_info *upi = pager_get_upi (p); + + pager_change_attributes (p, 1, MEMORY_OBJECT_COPY_DELAY, 0); + + /* It's possible that we didn't have caching on before, because + the user here is the only reference to the underlying node + (actually, that's quite likely inside this particular + routine), and if that node has no links. So dinkle the node + ref counting scheme here, which will cause caching to be + turned off, if that's really necessary. */ + if (upi->pager_type == FILE_DATA) + { + diskfs_nref (upi->np); + diskfs_nrele (upi->np); + } + + return 0; + } + + npagers = ports_count_bucket (pager_bucket); + if (npagers == 0) + return 0; + + if (MAY_CACHE == 0) + { + ports_enable_bucket (pager_bucket); + return 1 + } + + /* Loop through the pagers and turn off caching one by one, + synchronously. That should cause termination of each pager. */ + ports_bucket_iterate (pager_bucket, block_cache); + + /* Give it a second; the kernel doesn't actually shutdown + immediately. XXX */ + sleep (1); + + npagers = ports_count_bucket (pager_bucket); + + if (npagers == 0) + return 0; + + /* Darn, there are actual honest users. Turn caching back on, + and return failure. */ + ports_bucket_iterate (pager_bucket, enable_cache); + return 1; +} + + /* Call this to find out the struct pager * corresponding to the FILE_DATA pager of inode IP. This should be used *only* as a subsequent argument to register_memory_fault_area, and will be deleted when -- cgit v1.2.3 From 91bc35fb4300a4da5474c68f6c6558ca8533f7ba Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 27 Jun 1995 00:20:51 +0000 Subject: (diskfs_pager_users/enable_cache): Fix typo. Include . --- ufs/pager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 34c4d232..de5e1d18 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -18,6 +18,7 @@ #include "ufs.h" #include #include +#include spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; @@ -536,7 +537,7 @@ diskfs_pager_users () routine), and if that node has no links. So dinkle the node ref counting scheme here, which will cause caching to be turned off, if that's really necessary. */ - if (upi->pager_type == FILE_DATA) + if (upi->type == FILE_DATA) { diskfs_nref (upi->np); diskfs_nrele (upi->np); @@ -552,7 +553,7 @@ diskfs_pager_users () if (MAY_CACHE == 0) { ports_enable_bucket (pager_bucket); - return 1 + return 1; } /* Loop through the pagers and turn off caching one by one, -- cgit v1.2.3 From 2db0f3532d58e46f4c2b36966a5eb49bdfc9699c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 28 Jun 1995 19:51:47 +0000 Subject: Repair mangled include-file dependencies. --- devio/Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/devio/Makefile b/devio/Makefile index 97d7029d..52f84d86 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -41,7 +41,9 @@ $(prefix)/dev/MAKEDEV: MAKEDEV $(INSTALL_DATA) MAKEDEV $(prefix)/dev/MAKEDEV chmod +x $(prefix)/dev/MAKEDEV -open.c rdwr.c window.c: window.h -dev.c devio.c devpager.c io.c iostate.c open.c rdwr.c window.c: dev.h -devio.c io.c open.c rdwr.c: open.h -dev.c io.c iostate.c: iostate.h +open.o rdwr.o window.o: window.h +dev.o devio.o devpager.o io.o iostate.o open.o rdwr.o window.o: dev.h +devio.o io.o open.o rdwr.o: open.h +dev.o io.o iostate.o: iostate.h +dev.o devio.o devpager.o: ../hurd/pager.h +devio.o io.o: ../hurd/ports.h ../hurd/trivfs.h \ No newline at end of file -- cgit v1.2.3 From 0cbb481f3c31a306d1df4944a4668780258b8bde Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 6 Jul 1995 19:43:11 +0000 Subject: Removed dependencies that are now automatically generated. --- bsdfsck/Makefile | 4 +--- ufs-fsck/Makefile | 4 +--- ufs/Makefile | 12 ------------ 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index 28adbbd1..6bc18889 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1994 Free Software Foundation +# Copyright (C) 1994, 1995 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 @@ -27,7 +27,5 @@ target = bsdfsck include ../Makeconf -$(OBJS): fsck.h - tables.o: ../ufs/tables.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index ef8919a9..d581cda3 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1994 Free Software Foundation +# Copyright (C) 1994, 1995 Free Software Foundation # Written by Michael I. Bushnell. # # This file is part of the GNU Hurd. @@ -29,7 +29,5 @@ target = fsck include ../Makeconf -$(OBJS): fsck.h - tables.o: ../ufs/tables.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/ufs/Makefile b/ufs/Makefile index 04bb15fd..33582409 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -36,15 +36,3 @@ vpath %.c ../lib include ../Makeconf -$(OBJS): ufs.h -$(OBJS): $(REMHDRS) -alloc.o: fs.h dinode.h -consts.o: dinode.h -dir.o: dir.h -hyper.o: fs.h -inode.o: dinode.h fs.h -main.o: fs.h -pager.o: fs.h dinode.h -sizes.o: fs.h dinode.h -subr.o: fs.h -tables.o: fs.h -- cgit v1.2.3 From 016ee155fd89390b278e38ba41b150e60ed4928b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 6 Jul 1995 20:24:24 +0000 Subject: (libc): Provide definition that uses the linker search algorithm to get shared libraries if appropriate. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 6a81ad0e..db4ed7b4 100644 --- a/=Maketools +++ b/=Maketools @@ -42,7 +42,7 @@ RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) startup := $(crossdir)/lib/crt0.o -libc := $(crossdir)/lib/libc.a +libc := -L$(crossdir)/lib -lc crossheaders := $(crossdir)/include INSTALL = install -c -- cgit v1.2.3 From d55af1437b99d90f912f994c01cdf14ce14357c3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 6 Jul 1995 23:15:07 +0000 Subject: (libc): Reverst last change; ld bug. --- =Maketools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index db4ed7b4..6a81ad0e 100644 --- a/=Maketools +++ b/=Maketools @@ -42,7 +42,7 @@ RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) startup := $(crossdir)/lib/crt0.o -libc := -L$(crossdir)/lib -lc +libc := $(crossdir)/lib/libc.a crossheaders := $(crossdir)/include INSTALL = install -c -- cgit v1.2.3 From 27f34ee005b4c2423fbea6272234fe54a6b35c29 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 01:59:34 +0000 Subject: (tables.o): Delete rule. (vpath tables.c): Tell where to find tables.c. --- ufs-fsck/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index d581cda3..61c985c6 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -27,7 +27,7 @@ OBJS = $(subst .c,.o,$(SRCS)) tables.o LCLHDRS = fsck.h target = fsck +vpath tables.c ../ufs + include ../Makeconf -tables.o: ../ufs/tables.c - $(CC) $(CFLAGS) -c -o $@ $< -- cgit v1.2.3 From abd78d79f13f61044244822d80d15fa5a1fd6dbb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 02:00:43 +0000 Subject: (tables.o): Delete target. (vpath tables.c): Tell where to find tables.c. --- bsdfsck/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdfsck/Makefile b/bsdfsck/Makefile index 6bc18889..b5dcfbf2 100644 --- a/bsdfsck/Makefile +++ b/bsdfsck/Makefile @@ -25,7 +25,7 @@ OBJS = dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \ LCLHDRS = fsck.h target = bsdfsck +vpath tables.c ../ufs + include ../Makeconf -tables.o: ../ufs/tables.c - $(CC) $(CFLAGS) -c -o $@ $< -- cgit v1.2.3 From 5913f0e4946806651e8a6067347fa6eba82609d4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 02:14:07 +0000 Subject: (pass1): Remove assignment from if test. --- ufs-fsck/pass1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 621d40ec..c97ffc33 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -1,5 +1,5 @@ /* Pass one of GNU fsck -- count blocks and verify inodes - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -63,7 +63,8 @@ pass1 () int wasbad = 0; /* Check to see if this block is in range */ - if (outofrange = check_range (bno, nfrags)) + outofrange = check_range (bno, nfrags); + if (outofrange) { blkerror = 1; wasbad = 1; -- cgit v1.2.3 From ff4253e67fc207b244cab96b6e08886900525bb0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 02:15:12 +0000 Subject: (lookup_directory): New decl. --- ufs-fsck/fsck.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index ca8f2dfd..5bcc6014 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -1,6 +1,6 @@ /* - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -161,6 +161,7 @@ void datablocks_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); void allblock_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); void record_directory (struct dinode *, ino_t); +struct dirinfo *lookup_directory (ino_t); void pinode (ino_t); -- cgit v1.2.3 From a0de102fbdf454a7b1db676c2cbef1eba0ba92c3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 02:15:51 +0000 Subject: (pinode): Remove assignment from if test. --- ufs-fsck/utilities.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index e8475506..d5ff8c1b 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -1,5 +1,5 @@ /* Miscellaneous functions for fsck - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -256,7 +256,8 @@ pinode (ino_t ino) getinode (ino, &dino); printf (" OWNER="); - if (pw = getpwuid (dino.di_uid)) + pw = getpwuid (dino.di_uid); + if (pw) printf ("%s ", pw->pw_name); else printf ("%lu ", dino.di_uid); -- cgit v1.2.3 From 33bece8779ef23a807381928535957cd96c48d70 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 02:58:15 +0000 Subject: (copyright, sccsid): Declare unused. (main): Correct format for fourth arg. --- ufs-utils/clri.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs-utils/clri.c b/ufs-utils/clri.c index 203073e2..eb58ffe2 100644 --- a/ufs-utils/clri.c +++ b/ufs-utils/clri.c @@ -37,11 +37,13 @@ #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; + The Regents of the University of California. All rights reserved.\n" +__attribute__ ((unused)); #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; +static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93" +__attribute__ ((unused)); #endif /* not lint */ /* Modified by Michael I. Bushnell for GNU Hurd. */ @@ -106,7 +108,7 @@ main(argc, argv) sbp = (struct fs *)sblock; if (sbp->fs_magic != FS_MAGIC) { (void)fprintf(stderr, - "clri: %s: superblock magic number 0x%x, not 0x%x.\n", + "clri: %s: superblock magic number 0x%lux, not 0x%x.\n", fs, sbp->fs_magic, FS_MAGIC); exit(1); } -- cgit v1.2.3 From e1d558d97966072be0b0705f7911c55a9410c54c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 03:54:41 +0000 Subject: (OBJCOPY): New var. --- =Maketools | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/=Maketools b/=Maketools index 6a81ad0e..5d03cbb2 100644 --- a/=Maketools +++ b/=Maketools @@ -27,7 +27,7 @@ crossdir := /usr/local/$(CCTARGET) ifndef BUILD_CC export BUILD_CC := $(CC) endif -CC=$(CCTARGET)-gcc $(CCTYPE) -O2 -pipe +CC=$(CCTARGET)-gcc $(CCTYPE) -O2 ifeq (,$(wildcard /usr/local/lib/migcom)) MIGCOM=$(crossdir)/lib/migcom MIG=$(tooldir)/mig @@ -40,6 +40,7 @@ export CPP AR=$(tooldir)/ar RANLIB=$(tooldir)/ranlib LD=$(tooldir)/ld -L$(ccdir) +OBJCOPY=$(CCTARGET)-objcopy startup := $(crossdir)/lib/crt0.o libc := $(crossdir)/lib/libc.a -- cgit v1.2.3 From b33bb659b277544674e2e152f1d4feb641e8c05e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 7 Jul 1995 23:20:18 +0000 Subject: (copyright, sccsid): Correct syntax. --- ufs-utils/clri.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ufs-utils/clri.c b/ufs-utils/clri.c index eb58ffe2..1ad348a1 100644 --- a/ufs-utils/clri.c +++ b/ufs-utils/clri.c @@ -37,13 +37,14 @@ #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ - The Regents of the University of California. All rights reserved.\n" -__attribute__ ((unused)); + The Regents of the University of California. All rights reserved.\n"; + +static char copyright[] __attribute__ ((unused)); #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93" -__attribute__ ((unused)); +static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; +static char sccsid[] __attribute__ ((unused)); #endif /* not lint */ /* Modified by Michael I. Bushnell for GNU Hurd. */ -- cgit v1.2.3 From f56f833dabf047e9cda7ce5feafe4baa5f8e68c9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:24:14 +0000 Subject: (io_state_sync): Remember that we've synced the buffer. --- devio/iostate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devio/iostate.c b/devio/iostate.c index 2f6863bc..fe40fcd2 100644 --- a/devio/iostate.c +++ b/devio/iostate.c @@ -70,6 +70,9 @@ io_state_sync(struct io_state *ios, struct dev *dev) err = dev_write(dev, ios->buffer, dev->block_size, &ios->location); } + + /* Remember that there's nothing left in the buffer. */ + ios->buffer_use = 0; } return err; -- cgit v1.2.3 From 57e6956a7b14ece4a867b44eb7d28b721530b9ce Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:26:54 +0000 Subject: (dev_stop_paging): New function. (pager_dropweak): New function. (pager_port_type): Deleted var. (pager_port_bucket, pager_port_class): New vars. (dev_get_memory_object): Moved here from dev.c. Also, call init_dev_pager if necessary. (service_paging_requests): New function. (init_dev_pager): New function. --- devio/devpager.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 127 insertions(+), 5 deletions(-) diff --git a/devio/devpager.c b/devio/devpager.c index ab3da34a..9d6e4abb 100644 --- a/devio/devpager.c +++ b/devio/devpager.c @@ -24,15 +24,10 @@ #include #include "dev.h" -#include "ptypes.h" /* ---------------------------------------------------------------- */ /* Pager library callbacks; see for more info. */ -/* This will be the type used in calls to allocate_port by the pager system. - */ -int pager_port_type = PT_MEMOBJ; - /* 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 @@ -150,3 +145,130 @@ void pager_clear_user_data(struct user_pager_info *upi) { } + +/* ---------------------------------------------------------------- */ + +/* A top-level function for the paging thread that just services paging + requests. */ +static void +service_paging_requests (any_t arg) +{ + struct dev *dev = (struct dev *)arg; + for (;;) + ports_manage_port_operations_multithread (dev->pager_port_bucket, + pager_demuxer, + 1000 * 30, 1000 * 60 * 5, + 1, MACH_PORT_NULL); +} + +/* Initialize paging for this device. */ +static void +init_dev_paging (struct dev *dev) +{ + dev->pager_port_bucket = ports_create_bucket (); + + /* Make a thread to service paging requests. */ + cthread_detach (cthread_fork ((cthread_fn_t)service_paging_requests, + (any_t)dev)); +} + +void +pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) +{ +} + +/* ---------------------------------------------------------------- */ + +/* Try to stop all paging activity on DEV, returning true if we were + successful. If NOSYNC is true, then we won't write back any (kernel) + cached pages to the device. */ +int +dev_stop_paging (struct dev *dev, int nosync) +{ + int success = 1; /* Initially assume success. */ + + io_state_lock(&dev->io_state); + + if (dev->pager != NULL) + { + int num_pagers = ports_count_bucket (dev->pager_port_bucket); + if (num_pagers > 0 && !nosync) + { + error_t block_cache (void *arg) + { + struct pager *p = arg; + pager_change_attributes (p, 0, MEMORY_OBJECT_COPY_DELAY, 1); + return 0; + } + error_t enable_cache (void *arg) + { + struct pager *p = arg; + pager_change_attributes (p, 1, MEMORY_OBJECT_COPY_DELAY, 0); + return 0; + } + + /* Loop through the pagers and turn off caching one by one, + synchronously. That should cause termination of each pager. */ + ports_bucket_iterate (dev->pager_port_bucket, block_cache); + + /* Give it a second; the kernel doesn't actually shutdown + immediately. XXX */ + sleep (1); + + num_pagers = ports_count_bucket (dev->pager_port_bucket); + if (num_pagers > 0) + /* Darn, there are actual honest users. Turn caching back on, + and return failure. */ + { + ports_bucket_iterate (dev->pager_port_bucket, enable_cache); + success = 0; + } + } + + if (success && !nosync) + /* shutdown the pager on DEV. If NOSYNC is set, we don't bother, for + fear that this may result in I/O. In this case we've disabled + rpcs on the pager's ports, so this will result in hanging... What + do we do??? XXXX */ + pager_shutdown (dev->pager); + } + + if (success) + dev->pager = NULL; + + io_state_lock(&dev->io_state); + + return success; +} + +/* ---------------------------------------------------------------- */ + +/* Returns in MEMOBJ the port for a memory object backed by the storage on + DEV. Returns 0 or the error code if an error occurred. */ +error_t +dev_get_memory_object(struct dev *dev, memory_object_t *memobj) +{ + if (dev_is(dev, DEV_SERIAL)) + return ENODEV; + + io_state_lock(&dev->io_state); + if (dev->pager_port_bucket == NULL) + init_dev_paging (dev); + if (dev->pager == NULL) + dev->pager = + pager_create((struct user_pager_info *)dev, dev->pager_port_bucket, + 1, MEMORY_OBJECT_COPY_DELAY); + io_state_unlock(&dev->io_state); + + if (dev->pager == NULL) + return ENODEV; /* XXX ??? */ + + *memobj = pager_get_port(dev->pager); + if (*memobj != MACH_PORT_NULL) + return + mach_port_insert_right(mach_task_self(), + *memobj, *memobj, + MACH_MSG_TYPE_MAKE_SEND); + + return 0; +} -- cgit v1.2.3 From 6865a54231d3efd94bfcac39231995262c85bb25 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:28:07 +0000 Subject: (struct dev): Add the pager_port_bucket field. Declare dev_stop_paging (). --- devio/dev.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/devio/dev.h b/devio/dev.h index 7244c91e..14ffc473 100644 --- a/devio/dev.h +++ b/devio/dev.h @@ -67,6 +67,8 @@ struct dev been allocated yet. Lock the lock in IO_STATE if you want to update this field. */ struct pager *pager; + /* The port_bucket for paging ports. */ + struct port_bucket *pager_port_bucket; /* The current owner of the open device. For terminals, this affects controlling terminal behavior (see term_become_ctty). For all objects @@ -127,6 +129,11 @@ error_t dev_write(struct dev *dev, DEV. Returns 0 or the error code if an error occurred. */ error_t dev_get_memory_object(struct dev *dev, memory_object_t *memobj); +/* Try to stop all paging activity on DEV, returning true if we were + successful. If NOSYNC is true, then we won't write back any (kernel) + cached pages to the device. */ +int dev_stop_paging (struct dev *dev, int nosync); + /* Try and write out any pending writes to DEV. If WAIT is true, will wait for any paging activity to cease. */ error_t dev_sync(struct dev *dev, int wait); -- cgit v1.2.3 From 78cded2d21ccf8c6ceb4094610a272f2a1384695 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:30:07 +0000 Subject: (trivfs_goaway): Make trivfs_goaway do the right thing. (clean_exit, close_device): Deleted functions. (thread_cancel): New function. (fsys_port_class, root_port_class, port_bucket): New vars. (trivfs_protid_portclasses, trivfs_cntl_portclasses, trivfs_protid_nportclasses, trivfs_cntl_nportclasses): New vars. (main): Initialize *portclasses vars, and convert to new trivfs lib. (trivfs_protid_porttypes, trivfs_cntl_porttypes, trivfs_protid_nporttypes, trivfs_cntl_nporttypes): Deleted vars. (trivfs_goaway): Convert args for new trivfs lib. (ports_cleanroutines): Delete var. (ports_demuxer, ports_notice_idle, ports_no_live_ports, ports_no_hard_ports): Delete functions. --- devio/devio.c | 174 ++++++++++++++++++++++++---------------------------------- 1 file changed, 72 insertions(+), 102 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index deeebf7e..6273b98f 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -32,7 +32,6 @@ #include "open.h" #include "dev.h" -#include "ptypes.h" #ifdef MSG #define DEBUG(what) \ @@ -42,7 +41,22 @@ #else #define DEBUG(what) 0 #endif + +/* ---------------------------------------------------------------- */ + +/* The port class of our file system control pointer. */ +struct port_class *fsys_port_class; +/* The port class of the (only) root file port for the opened device. */ +struct port_class *root_port_class; + +/* A bucket to put all our ports in. */ +struct port_bucket *port_bucket; +/* Trivfs noise. */ +struct port_class *trivfs_protid_portclasses[1]; +struct port_class *trivfs_cntl_portclasses[1]; +int trivfs_protid_nportclasses = 1; +int trivfs_cntl_nportclasses = 1; /* ---------------------------------------------------------------- */ @@ -92,7 +106,6 @@ static struct option options[] = {"serial", no_argument, 0, 's'}, {0, 0, 0, 0} }; - /* ---------------------------------------------------------------- */ @@ -152,8 +165,18 @@ void main(int argc, char *argv[]) if (bootstrap == MACH_PORT_NULL) error(2, 0, "Must be started as a translator"); + fsys_port_class = ports_create_class (trivfs_clean_cntl, 0); + root_port_class = ports_create_class (trivfs_clean_protid, 0); + port_bucket = ports_create_bucket (); + trivfs_protid_portclasses[0] = root_port_class; + trivfs_cntl_portclasses[0] = fsys_port_class; + /* Reply to our parent */ - err = trivfs_startup(bootstrap, PT_FSYS, PT_NODE, NULL); + err = + trivfs_startup(bootstrap, + fsys_port_class, port_bucket, + root_port_class, port_bucket, + NULL); if (err) error(3, err, "Contacting parent"); @@ -162,7 +185,8 @@ void main(int argc, char *argv[]) mutex_init(&device_lock); /* Launch. */ - ports_manage_port_operations_multithread (); + ports_manage_port_operations_multithread (port_bucket, trivfs_demuxer, + 30*1000, 5*60*1000, 0, 0); exit(0); } @@ -209,30 +233,6 @@ close_hook(struct trivfs_peropen *peropen) if (peropen->hook) open_free(peropen->hook); } - -static void -close_device(int aquire_lock) -{ - DEBUG(fprintf(debug, "Closing device\n")); - if (aquire_lock) - mutex_lock(&device_lock); - if (device) - { - dev_close(device); - device = NULL; - } - if (aquire_lock) - mutex_unlock(&device_lock); -} - -static void -clean_exit(int status, int aquire_lock) -{ - DEBUG(fprintf(debug, "Cleaning up and exiting (status = %d)...\n", status)); - close_device(aquire_lock); - DEBUG({fprintf(debug, "Bye!\n"); fclose(debug); debug = NULL;}); - exit(0); -} /* ---------------------------------------------------------------- */ /* Trivfs hooks */ @@ -246,11 +246,6 @@ int trivfs_support_exec = 0; int trivfs_allow_open = O_READ | O_WRITE; -int trivfs_protid_porttypes[] = {PT_NODE}; -int trivfs_cntl_porttypes[] = {PT_FSYS}; -int trivfs_protid_nporttypes = 1; -int trivfs_cntl_nporttypes = 1; - void trivfs_modify_stat (struct stat *st) { @@ -288,21 +283,53 @@ trivfs_modify_stat (struct stat *st) } error_t -trivfs_goaway (int flags, mach_port_t realnode, int ctltype, int pitype) +trivfs_goaway (int flags, mach_port_t realnode, + struct port_class *fsys_port_class, + struct port_class *file_port_class) { - DEBUG(fprintf(debug, "trivfs_goaway(0x%x, %d, %d, %d)\n", - flags, realnode, ctltype, pitype)); + int force = (flags & FSYS_GOAWAY_FORCE); + int nosync = (flags & FSYS_GOAWAY_NOSYNC); + + DEBUG(fprintf(debug, "trivfs_goaway(0x%x, %d)\n", flags, realnode)); - mutex_lock(&device_lock); - if (device == NULL || (flags & FSYS_GOAWAY_FORCE)) - /* Go away immediately. */ - if (flags & FSYS_GOAWAY_NOSYNC) - /* Don't clean up. */ - exit(0); - else - clean_exit(0, FALSE); mutex_lock(&device_lock); + if (device == NULL) + exit (0); + + /* Wait until all pending rpcs are done. */ + ports_inhibit_class_rpcs (root_port_class); + + if (force && nosync) + /* Exit with extreme prejudice. */ + exit (0); + + if (!force && ports_count_class (root_port_class) > 0) + /* Still users, so don't exit. */ + goto busy; + + if (!nosync) + /* Sync the device here, if necessary, so that closing it won't result in + any I/O (which could get hung up trying to use one of our pagers). */ + dev_sync (device, 1); + + /* devpager_shutdown may sync the pagers as side-effect (if NOSYNC is 0), + so we put that first in this test. */ + if (dev_stop_paging (device, nosync) || force) + /* Bye-bye. */ + { + if (!nosync) + /* If NOSYNC is true, we don't close DEV, as that could cause data to + be written back. */ + dev_close (device); + exit (0); + } + + busy: + /* Allow normal operations to proceed. */ + ports_enable_class (root_port_class); + mutex_unlock(&device_lock); + /* Complain that there are still users. */ return EBUSY; } @@ -344,65 +371,8 @@ trivfs_S_fsys_syncfs (struct trivfs_control *cntl, else return 0; } - -/* ---------------------------------------------------------------- */ -/* Ports hooks */ - -void (*ports_cleanroutines[])(void *) = -{ - [PT_FSYS] = trivfs_clean_cntl, - [PT_NODE] = trivfs_clean_protid, -}; - -int -ports_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) -{ - int ok; -#ifdef MSG - static int next_msg_num = 0; - int msg_num; -#endif - - DEBUG(msg_num = next_msg_num++; - fprintf(debug, "port_demuxer(%d) [%d]\n", inp->msgh_id, msg_num);); - - ok = pager_demuxer(inp, outp) || trivfs_demuxer(inp, outp); - - DEBUG(fprintf(debug, "port_demuxer(%d) [%d] done!\n", inp->msgh_id,msg_num)); - - return ok; -} - -/* This will be called whenever there have been no requests to the server for - a significant period of time. NHARD is the number of live hard ports; - NSOFT is the number of live soft ports. This function is called while an - internal lock is held, so it cannot reliably call any other functions of - the ports library. */ -void -ports_notice_idle (int nhard, int nsoft) -{ - DEBUG(fprintf(debug, "ports_notice_idle(%d, %d)\n", nhard, nsoft)); - if (nhard == 0) - clean_exit(0, TRUE); -} - -/* This will be called whenever there are no hard ports or soft ports - allocated. This function is called while an internal lock is held, so it - cannot reliably call any other functions of the ports library. */ -void -ports_no_live_ports () -{ - DEBUG(fprintf(debug, "ports_no_live_ports()\n")); - clean_exit(0, TRUE); -} -/* This will be called whenever there are no hard ports allocated but there - are still some soft ports. This function is called while an internal lock - is held, so it cannot reliably call any other functions of the ports - library. */ void -ports_no_hard_ports () +thread_cancel (thread_t foo __attribute__ ((unused))) { - DEBUG(fprintf(debug, "ports_no_hard_ports()\n")); - close_device(TRUE); } -- cgit v1.2.3 From 3fd7df07acb0071685fa1f588ed613f278fb30c6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:31:22 +0000 Subject: (dev_get_memory_object): Moved function to devpager.c. --- devio/dev.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/devio/dev.c b/devio/dev.c index a2eed5c0..b120c07c 100644 --- a/devio/dev.c +++ b/devio/dev.c @@ -423,32 +423,3 @@ dev_read(struct dev *dev, return err; } - -/* ---------------------------------------------------------------- */ - -/* Returns in MEMOBJ the port for a memory object backed by the storage on - DEV. Returns 0 or the error code if an error occurred. */ -error_t -dev_get_memory_object(struct dev *dev, memory_object_t *memobj) -{ - if (dev_is(dev, DEV_SERIAL)) - return ENODEV; - - io_state_lock(&dev->io_state); - if (dev->pager == NULL) - dev->pager = - pager_create((struct user_pager_info *)dev, 1, MEMORY_OBJECT_COPY_DELAY); - io_state_unlock(&dev->io_state); - - if (dev->pager == NULL) - return ENODEV; /* XXX ??? */ - - *memobj = pager_get_port(dev->pager); - if (*memobj != MACH_PORT_NULL) - return - mach_port_insert_right(mach_task_self(), - *memobj, *memobj, - MACH_MSG_TYPE_MAKE_SEND); - - return 0; -} -- cgit v1.2.3 From 7dc0bbb42d01b5cedac90be38ed342c693bc591d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:32:19 +0000 Subject: (HURDLIBS): Add libihash. Remove include dependencies. --- devio/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/devio/Makefile b/devio/Makefile index 52f84d86..4534cd63 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -21,7 +21,7 @@ makemode := server target = devio SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h -HURDLIBS = libtrivfs libpager libports libfshelp libthreads +HURDLIBS = libtrivfs libpager libports libfshelp libthreads libihash DIST_FILES = MAKEDEV OBJS = $(SRCS:.c=.o) error.o @@ -40,10 +40,3 @@ install: $(prefix)/dev/MAKEDEV $(prefix)/dev/MAKEDEV: MAKEDEV $(INSTALL_DATA) MAKEDEV $(prefix)/dev/MAKEDEV chmod +x $(prefix)/dev/MAKEDEV - -open.o rdwr.o window.o: window.h -dev.o devio.o devpager.o io.o iostate.o open.o rdwr.o window.o: dev.h -devio.o io.o open.o rdwr.o: open.h -dev.o io.o iostate.o: iostate.h -dev.o devio.o devpager.o: ../hurd/pager.h -devio.o io.o: ../hurd/ports.h ../hurd/trivfs.h \ No newline at end of file -- cgit v1.2.3 From 43b9a9d76b1098b53f3b28a4bfa50eb8993d265b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 8 Jul 1995 23:32:55 +0000 Subject: (console): Give /hurd/term a ttyname argument. (fd): Put the fd server on `fd', not `stdin'. --- devio/MAKEDEV | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 213d087d..93391460 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -11,7 +11,7 @@ for I; do $0 console tty null zero # fd ;; console) - settrans -cf console /hurd/term console ;; + settrans -cf console /hurd/term console `pwd`/console ;; tty) settrans -cf tty /hurd/magic tty ;; null) @@ -19,7 +19,7 @@ for I; do zero) settrans -cf zero /hurd/null -z ;; fd) - settrans -cf stdin /hurd/magic fd + settrans -cf fd /hurd/magic fd ln -f -s fd/0 stdin ln -f -s fd/1 stdout ln -f -s fd/2 stderr -- cgit v1.2.3 From a618e283c3ccc837ed7c2aac5ee5c3d7a92160c9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 17 Jul 1995 18:35:14 +0000 Subject: (thread_function): Don't have any global timeout here; we don't use it anyhow. --- ufs/pager.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index de5e1d18..52e77f05 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -380,10 +380,8 @@ static void thread_function (any_t foo __attribute__ ((unused))) { for (;;) - ports_manage_port_operations_multithread (pager_bucket, - pager_demuxer, - 1000 * 60 * 2, - 1000 * 60 * 10, + ports_manage_port_operations_multithread (pager_bucket, pager_demuxer, + 1000 * 60 * 2, 0, 1, MACH_PORT_NULL); } -- cgit v1.2.3 From 13e34674ce5c20de9a499c7a25f26a57a0ed9a44 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 21 Jul 1995 21:51:25 +0000 Subject: (diskfs_get_filemap): Free initial reference created by pager_create. --- ufs/pager.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index 52e77f05..139e5723 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -459,8 +459,16 @@ diskfs_get_filemap (struct node *np) upi->p = pager_create (upi, pager_bucket, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); np->dn->fileinfo = upi; + right = pager_get_port (np->dn->fileinfo->p); + ports_port_deref (np->dn->fileinfo->p); } - right = pager_get_port (np->dn->fileinfo->p); + else + /* There is a race condition here. If there are no references + to NP->dn->fileinfo->p, then the clean routine might be + blocked trying to get into node2pagelock, and this call is + invalid. XXX */ + right = pager_get_port (np->dn->fileinfo->p); + spin_unlock (&node2pagelock); mach_port_insert_right (mach_task_self (), right, right, -- cgit v1.2.3 From 9003138387cca2e16d004b952c5d0f65a9364cc0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 21 Jul 1995 21:58:08 +0000 Subject: (diskfs_get_filemap): Drop initial reference created by pager_create. (pager_clear_user_data): Only clear UPI->np->dn->fileinfo if it still points to us. --- ufs/pager.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 139e5723..cac6836a 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -362,7 +362,8 @@ pager_clear_user_data (struct user_pager_info *upi) if (upi->type == FILE_DATA) { spin_lock (&node2pagelock); - upi->np->dn->fileinfo = 0; + if (upi->np->dn->fileinfo == upi) + upi->np->dn->fileinfo = 0; spin_unlock (&node2pagelock); diskfs_nrele_light (upi->np); } @@ -450,24 +451,30 @@ diskfs_get_filemap (struct node *np) || np->dn_stat.st_size >= sblock->fs_maxsymlinklen))); spin_lock (&node2pagelock); - if (!np->dn->fileinfo) - { - upi = malloc (sizeof (struct user_pager_info)); - upi->type = FILE_DATA; - upi->np = np; - diskfs_nref_light (np); - upi->p = pager_create (upi, pager_bucket, - MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); - np->dn->fileinfo = upi; - right = pager_get_port (np->dn->fileinfo->p); - ports_port_deref (np->dn->fileinfo->p); - } - else - /* There is a race condition here. If there are no references - to NP->dn->fileinfo->p, then the clean routine might be - blocked trying to get into node2pagelock, and this call is - invalid. XXX */ - right = pager_get_port (np->dn->fileinfo->p); + do + if (!np->dn->fileinfo) + { + upi = malloc (sizeof (struct user_pager_info)); + upi->type = FILE_DATA; + upi->np = np; + diskfs_nref_light (np); + upi->p = pager_create (upi, pager_bucket, + MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); + np->dn->fileinfo = upi; + right = pager_get_port (np->dn->fileinfo->p); + ports_port_deref (np->dn->fileinfo->p); + } + else + { + /* Because NP->dn->fileinfo->p is not a real reference, + this might be nearly deallocated. If that's so, then + the port right will be null. In that case, clear here + and loop. The deallocation will complete separately. */ + right = pager_get_port (np->dn->fileinfo->p); + if (right == MACH_PORT_NULL) + np->dn->fileinfo = 0; + } + while (right == MACH_PORT_NULL); spin_unlock (&node2pagelock); -- cgit v1.2.3 From 908c1e3d003d0dc7d09b9d54433738b9cae04a78 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jul 1995 22:47:42 +0000 Subject: (open_read, open_write): Clean up STATE before returning with an error. (open_seek): New function. (raw_read, raw_write): Return EINVAL if *OFFS isn't a block boundary. --- devio/rdwr.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/devio/rdwr.c b/devio/rdwr.c index cda7635d..b8431d7a 100644 --- a/devio/rdwr.c +++ b/devio/rdwr.c @@ -262,6 +262,9 @@ raw_write(struct dev *dev, int block_amount = ((buf_len + bsize - 1) / bsize) * bsize; vm_offset_t start_offs = *offs; + if (start_offs % bsize != 0) + return EINVAL; + if (block_amount == buf_len && dev_write_valid(dev, buf, block_amount, offs)) /* BUF is page-aligned, so we can do i/o directly to the device, or it is small enough that it doesn't matter. */ @@ -295,8 +298,11 @@ raw_read(struct dev *dev, error_t err; int bsize = dev->block_size; int block_amount = ((amount + bsize - 1) / bsize) * bsize; - err = dev_read(dev, buf, buf_len, block_amount, offs); + if (*offs % bsize != 0) + return EINVAL; + + err = dev_read(dev, buf, buf_len, block_amount, offs); if (!err) { int excess = *buf_len - amount; @@ -371,11 +377,10 @@ open_write(struct open *open, vm_address_t buf, vm_size_t len, offs = *state.offs_p; if (offs < 0) - return EINVAL; + err = EINVAL; if (offs + len > dev->size) - return EIO; - - if (!dev_is(dev, DEV_BUFFERED)) + err = EIO; + else if (!dev_is(dev, DEV_BUFFERED)) err = raw_write(dev, buf, len, amount, state.offs_p); else if (dev_is(dev, DEV_SERIAL)) { @@ -428,11 +433,10 @@ open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, offs = *state.offs_p; if (offs < 0) - return EINVAL; + err = EINVAL; if (offs + amount > dev->size) - return EIO; - - if (!dev_is(dev, DEV_BUFFERED)) + err = EIO; + else if (!dev_is(dev, DEV_BUFFERED)) err = raw_read(dev, buf, buf_len, amount, state.offs_p); else if (dev_is(dev, DEV_SERIAL)) { @@ -469,3 +473,43 @@ open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, return err; } + +/* Set OPEN's location to OFFS, interpreted according to WHENCE as by seek. + The new absolute location is returned in NEW_OFFS (and may not be the same + as OFFS). If no error occurs, zero is returned, otherwise the error code + is returned. */ +error_t +open_seek (struct open *open, off_t offs, int whence, off_t *new_offs) +{ + error_t err = 0; + struct io_state *io_state = open_get_io_state (open); + + if (!dev_is (open->dev, DEV_SEEKABLE)) + return ESPIPE; + + io_state_lock (io_state); + + switch (whence) + { + case SEEK_SET: + *new_offs = offs; break; + case SEEK_CUR: + *new_offs = io_state->location + offs; break; + case SEEK_END: + *new_offs = open->dev->size - offs; break; + default: + err = EINVAL; + } + + if (!err) + { + if (!dev_is (open->dev, DEV_BUFFERED)) + /* On unbuffered devices force seeks to the nearest block boundary. */ + *new_offs -= *new_offs % open->dev->block_size; + io_state->location = *new_offs; + } + + io_state_unlock (io_state); + + return err; +} -- cgit v1.2.3 From d90f7d551a27c49b0cd9c24c86c8bfe30a6b3c49 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jul 1995 22:48:10 +0000 Subject: Add declaration for open_seek. --- devio/open.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/devio/open.h b/devio/open.h index c202d9ed..80763585 100644 --- a/devio/open.h +++ b/devio/open.h @@ -64,4 +64,10 @@ error_t open_write(struct open *open, vm_address_t buf, vm_size_t len, error_t open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, off_t offs); +/* Set OPEN's location to OFFS, interpreted according to WHENCE as by seek. + The new absolute location is returned in NEW_OFFS (and may not be the same + as OFFS). If no error occurs, zero is returned, otherwise the error code + is returned. */ +error_t open_seek (struct open *open, off_t offs, int whence, off_t *new_offs); + #endif /* !__OPEN_H__ */ -- cgit v1.2.3 From 1802cf4da4bb3d0509235cec185f93fdb5a4eba0 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jul 1995 22:48:52 +0000 Subject: (trivfs_S_io_seek): Call open_seek instead of doing it ourselves. --- devio/io.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/devio/io.c b/devio/io.c index 107a4c5e..aa0caa2c 100644 --- a/devio/io.c +++ b/devio/io.c @@ -127,36 +127,12 @@ trivfs_S_io_readable (struct trivfs_protid *cred, kern_return_t trivfs_S_io_seek (struct trivfs_protid *cred, mach_port_t reply, mach_msg_type_name_t replytype, - off_t offset, int whence, off_t *new_offset) + off_t offs, int whence, off_t *new_offs) { if (!cred) return EOPNOTSUPP; else - { - error_t err = 0; - struct open *open = (struct open *)cred->po->hook; - struct io_state *io_state = open_get_io_state(open); - - if (!dev_is(open->dev, DEV_SEEKABLE)) - return ESPIPE; - - io_state_lock(io_state); - switch(whence) - { - case SEEK_SET: - io_state->location = offset; break; - case SEEK_CUR: - io_state->location += offset; break; - case SEEK_END: - io_state->location = open->dev->size - offset; break; - default: - err = EINVAL; - } - *new_offset = io_state->location; - io_state_unlock(io_state); - - return err; - } + return open_seek ((struct open *)cred->po->hook, offs, whence, new_offs); } /* ---------------------------------------------------------------- */ -- cgit v1.2.3 From 17346364171a6017001fbea93e8cac2b92346c7e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jul 1995 22:55:20 +0000 Subject: (dev_get_memory_object): A new pager now comes with 1 ref, so we allocate a ref ourselves when we're using an old one, and once we've created the send right, remove a reference. --- devio/devpager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devio/devpager.c b/devio/devpager.c index 9d6e4abb..02fd54ed 100644 --- a/devio/devpager.c +++ b/devio/devpager.c @@ -258,12 +258,16 @@ dev_get_memory_object(struct dev *dev, memory_object_t *memobj) dev->pager = pager_create((struct user_pager_info *)dev, dev->pager_port_bucket, 1, MEMORY_OBJECT_COPY_DELAY); + else + ports_port_ref (dev->pager); io_state_unlock(&dev->io_state); if (dev->pager == NULL) return ENODEV; /* XXX ??? */ *memobj = pager_get_port(dev->pager); + ports_port_deref (dev->pager); /* Drop our original ref on PAGER. */ + if (*memobj != MACH_PORT_NULL) return mach_port_insert_right(mach_task_self(), -- cgit v1.2.3 From 83ef87c257694bb8804a39ab6a5c1832b463fd4e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 13 Aug 1995 14:58:57 +0000 Subject: (trivfs_peropen_create_hook): This now returns an error_t. (open_hook): And thus this does as well. --- devio/devio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index 6273b98f..13e98b90 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -219,12 +219,14 @@ check_open_hook (struct trivfs_control *trivfs_control, return err; } -static void +static error_t open_hook(struct trivfs_peropen *peropen) { struct dev *dev = device; if (dev) - open_create(dev, (struct open **)&peropen->hook); + return open_create(dev, (struct open **)&peropen->hook); + else + return 0; } static void @@ -350,7 +352,7 @@ error_t (*trivfs_check_open_hook)(struct trivfs_control *trivfs_control, /* If this variable is set, it is called every time a new peropen structure is created and initialized. */ -void (*trivfs_peropen_create_hook)(struct trivfs_peropen *) = open_hook; +error_t (*trivfs_peropen_create_hook)(struct trivfs_peropen *) = open_hook; /* If this variable is set, it is called every time a peropen structure is about to be destroyed. */ -- cgit v1.2.3 From d7533813fce8a5fecde98726572228e1ba215e5b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 15 Aug 1995 23:47:51 +0000 Subject: ([hrs]d*): Fixed partition parsing: use glob pattern, not regexp. --- devio/MAKEDEV | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 93391460..8cb630cc 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -30,9 +30,9 @@ for I; do settrans -cf $I /hurd/devio -b $I ;; - rd*|sd*|hd*) + [hrs]d*) case "$I" in - [a-z]*[0-9][0-9]*[a-z]*) + [a-z][a-z][0-9][a-z]) settrans -cf r$I /hurd/devio $I settrans -cf $I /hurd/devio -b $I ;; -- cgit v1.2.3 From 0cf45c1e7e1c995c587fb72a91a0418fe52a5d62 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 23 Aug 1995 13:37:22 +0000 Subject: (INSTALL_BIN): Changed to INSTALL_PROGRAM. --- =Maketools | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index 5d03cbb2..d92a9ae2 100644 --- a/=Maketools +++ b/=Maketools @@ -48,7 +48,6 @@ crossheaders := $(crossdir)/include INSTALL = install -c INSTALL_DATA = $(INSTALL) -m 644 -INSTALL_BIN = $(INSTALL) -m 755 -#INSTALL_BIN=cp +INSTALL_PROGRAM = $(INSTALL) -m 755 machine := i386 -- cgit v1.2.3 From e22e0f279d0f5c7c5ad18df7f8c12ed610743c1c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 24 Aug 1995 14:23:29 +0000 Subject: (ufs): Add explicit dependencies. (HURDLIBS, LDFLAGS, REMHDRS): Removed. Rules associated with ../lib removed. --- ufs/Makefile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 33582409..a7763efc 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -18,21 +18,13 @@ dir := ufs makemode := server +target = ufs SRCS = alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ sizes.c subr.c tables.c bmap.c pokeloc.c -OBJS = $(SRCS:.c=.o) LCLHDRS = ufs.h fs.h dinode.h dir.h -REMHDRS = ../hurd/diskfs.h ../hurd/ports.h ../hurd/pager.h\ - ../hurd/ioserver.h ../hurd/fshelp.h -#HURDLIBS = libdiskfs libports libdiskfs libpager libioserver \ -# libfshelp libdiskfs libthreads libports -HURDLIBS = libdiskfs libports libpager libioserver libfshelp libthreads libihash -LDFLAGS = -Wl,--no-keep-memory -target = ufs -CPPFLAGS += -I../lib -CPPFLAGS += $(CPPFLAGS-$(notdir $<)) -vpath %.c ../lib +OBJS = $(SRCS:.c=.o) -include ../Makeconf +ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a +include ../Makeconf -- cgit v1.2.3 From c793044fd2cd6126bc92529bd36da14e80ee7f6f Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 24 Aug 1995 14:29:02 +0000 Subject: (devio): Put all dependencies here. (HURDLIBS): Removed. (OBJS): Get rid of error.o. Get rid of rules dealing with error.o. ($(prefix)/dev/MAKEDEV): Use $(INSTALL_PROGRAM) instead of $(INSTALL_DATA) + `chmod +x'. --- devio/Makefile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/devio/Makefile b/devio/Makefile index 4534cd63..08f9e4a1 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -1,3 +1,4 @@ +# Makefile for devio # # Copyright (C) 1995 Free Software Foundation, Inc. # @@ -21,22 +22,15 @@ makemode := server target = devio SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h -HURDLIBS = libtrivfs libpager libports libfshelp libthreads libihash DIST_FILES = MAKEDEV -OBJS = $(SRCS:.c=.o) error.o +OBJS = $(SRCS:.c=.o) -CPPFLAGS += -I../lib -CPPFLAGS += $(CPPFLAGS-$(notdir $<)) - -CPPFLAGS-error.c = -Dprogram_name=program_invocation_name -DHAVE_VPRINTF -DSTDC_HEADERS -DHAVE_STRERROR - -vpath %.c ../lib +devio: $(OBJS) ../libtrivfs/libtrivfs.a ../libpager/libpager.a ../libports/libports.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a include ../Makeconf install: $(prefix)/dev/MAKEDEV $(prefix)/dev/MAKEDEV: MAKEDEV - $(INSTALL_DATA) MAKEDEV $(prefix)/dev/MAKEDEV - chmod +x $(prefix)/dev/MAKEDEV + $(INSTALL_PROGRAM) MAKEDEV $(prefix)/dev/MAKEDEV -- cgit v1.2.3 From f6063d391372b19a07b85ae240384ac40e11742a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 24 Aug 1995 15:47:48 +0000 Subject: (trivfs_goaway, trivfs_modify_stat): Update arguments. (trivfs_modify_stat): Get the device from CRED now that we have it. --- devio/devio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index 13e98b90..7adae2f0 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -249,11 +249,12 @@ int trivfs_support_exec = 0; int trivfs_allow_open = O_READ | O_WRITE; void -trivfs_modify_stat (struct stat *st) +trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) { - struct dev *dev = device; + struct dev *dev = cred->po->hook; if (dev) + /* An open device. */ { vm_size_t size = dev->size; @@ -285,15 +286,11 @@ trivfs_modify_stat (struct stat *st) } error_t -trivfs_goaway (int flags, mach_port_t realnode, - struct port_class *fsys_port_class, - struct port_class *file_port_class) +trivfs_goaway (struct trivfs_control *fsys, int flags) { int force = (flags & FSYS_GOAWAY_FORCE); int nosync = (flags & FSYS_GOAWAY_NOSYNC); - DEBUG(fprintf(debug, "trivfs_goaway(0x%x, %d)\n", flags, realnode)); - mutex_lock(&device_lock); if (device == NULL) -- cgit v1.2.3 From 4d67eb6e36ed6ebf0dcd8a2b8eecfe29f1b4f4f4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 25 Aug 1995 21:15:41 +0000 Subject: (indir_release): When freeing direct blocks mentioned in a single indirect block, or single indirect blocks mentioned in a double, only call the free routine (ffs_blkfree or indir_release, respectively) if the block is actually allocated. --- ufs/sizes.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 0e6b893e..8fc0b029 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -153,11 +153,12 @@ diskfs_truncate (struct node *np, { daddr_t *sindir = indir_block (indirs[1].bno); for (i = indirs[0].offset + 1; i < NINDIR (sblock); i++) - { - ffs_blkfree (np, sindir[i], sblock->fs_bsize); - sindir[i] = 0; - blocksfreed += btodb (sblock->fs_bsize); - } + if (sindir[i]) + { + ffs_blkfree (np, sindir[i], sblock->fs_bsize); + sindir[i] = 0; + blocksfreed += btodb (sblock->fs_bsize); + } record_poke (sindir, sblock->fs_bsize); } } @@ -180,10 +181,11 @@ diskfs_truncate (struct node *np, { daddr_t *dindir = indir_block (indirs[2].bno); for (i = indirs[1].offset + 1; i < NINDIR (sblock); i++) - { - blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); - dindir[i] = 0; - } + if (dindir[i]) + { + blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); + dindir[i] = 0; + } record_poke (dindir, sblock->fs_bsize); } } -- cgit v1.2.3 From d59e4a59c84b65f3d2396816b78ae72d46f0c628 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 28 Aug 1995 21:07:31 +0000 Subject: (ufs): Depend on ../libshouldbeinlibc/libshouldbeinlibc.a. --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index a7763efc..28a30507 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -25,6 +25,6 @@ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) -ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a +ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a include ../Makeconf -- cgit v1.2.3 From b95f1f346c1db856ad260e20b9f873eae61d7f6d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 6 Sep 1995 15:03:28 +0000 Subject: (diskfs_pager_users): Ignore the disk pager when seeing if there are any active pagers. --- ufs/pager.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index cac6836a..51cfc6f3 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -560,7 +560,7 @@ diskfs_pager_users () } npagers = ports_count_bucket (pager_bucket); - if (npagers == 0) + if (npagers <= 1) return 0; if (MAY_CACHE == 0) @@ -578,8 +578,7 @@ diskfs_pager_users () sleep (1); npagers = ports_count_bucket (pager_bucket); - - if (npagers == 0) + if (npagers <= 1) return 0; /* Darn, there are actual honest users. Turn caching back on, -- cgit v1.2.3 From 42311cc0dcaba1f42d7f1c0a0fd242eaf9ddeb2d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 11 Sep 1995 16:06:36 +0000 Subject: (CCVERSION): Changed to 2.7.1. (CCVERSION-duality.gnu.ai.mit.edu): Removed. --- =Maketools | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/=Maketools b/=Maketools index d92a9ae2..1ec9b8a8 100644 --- a/=Maketools +++ b/=Maketools @@ -15,11 +15,10 @@ mighost := ernst.gnu.ai.mit.edu # can be found in /usr/local/lib/lib-gcc). CCTARGET=i386-gnu hostname := $(shell hostname) -CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.6.2) +CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.7.1) CCTYPE=-b $(CCTARGET) -V $(CCVERSION) CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 -CCVERSION-duality.gnu.ai.mit.edu = 2.6.4 ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) crossdir := /usr/local/$(CCTARGET) -- cgit v1.2.3 From b6d7707a397cec1abccdf558ba180112cd04a149 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 13 Sep 1995 16:30:20 +0000 Subject: (diskfs_lookup): Don't attempt to lock NP if NPP is not set. Don't even set NP if NPP is not set; use INUM as "lookup succeeded flag" instead. Lookups for REMOVE now *must* set NPP. --- ufs/dir.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 1d7004d8..ab98d4bb 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -100,6 +100,9 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, int blockaddr; int idx; + if (type == REMOVE) + assert (npp); + if (npp) *npp = 0; @@ -166,7 +169,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, think about that as an error yet. */ err = 0; - if (inum) + if (inum && npp) { if (namelen != 2 || name[0] != '.' || name[1] != '.') { @@ -242,15 +245,15 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, /* If we will be modifying the directory, make sure it's allowed. */ if (type == RENAME - || (type == REMOVE && np) - || (type == CREATE && !np)) + || (type == REMOVE && inum) + || (type == CREATE && !inum)) { err = diskfs_checkdirmod (dp, np, cred); if (err) goto out; } - if ((type == CREATE || type == RENAME) && !np && ds && ds->stat == LOOKING) + if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING) { /* We didn't find any room, so mark ds to extend the dir */ ds->type = CREATE; @@ -274,7 +277,8 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, if (np) { - if (err || !npp) + assert (npp); + if (err) { if (!spec_dotdot) { @@ -292,11 +296,11 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, /* We did iget */ diskfs_nput (np); } - else if (npp) + else *npp = np; } - return err ? : np ? 0 : ENOENT; + return err ? : inum ? 0 : ENOENT; } /* Scan block at address BLKADDR (of node DP; block index IDX), for -- cgit v1.2.3 From 639d32ce79bfb66727ccefd136cfb5f3486d79ec Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 13 Sep 1995 16:38:40 +0000 Subject: (diskfs_lookup): Require NPP set for RENAME too. --- ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index ab98d4bb..ff79cc1e 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -100,7 +100,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, int blockaddr; int idx; - if (type == REMOVE) + if ((type == REMOVE) || (type == RENAME)) assert (npp); if (npp) -- cgit v1.2.3 From 5900aa57822e42e3c9c550db4f937ebea63b9f2f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 16 Sep 1995 18:19:43 +0000 Subject: Initial revision --- configure.in | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 configure.in diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..1d63b3ac --- /dev/null +++ b/configure.in @@ -0,0 +1,32 @@ +dnl Process this file with autoconf to produce a configure script. +AC_REVISION([$Id: configure.in,v 1.1 1995/09/16 18:19:43 roland Exp $]) +AC_PREREQ(2.4) dnl Minimum Autoconf version required. +AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. + +AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local. + +AC_CANONICAL_HOST +case "$host_os" in +gnu*) ;; +*) AC_MSG_ERROR([sorry, this is the gnu os, not $host_os]) ;; +esac + +AC_PROG_INSTALL +AC_CHECK_TOOL(CC, gcc) +AC_CHECK_TOOL(LD, ld) +AC_CHECK_TOOL(OBJCOPY, objcopy) +AC_CHECK_TOOL(AR, ar) +AC_CHECK_TOOL(RANLIB, ranlib) +AC_CHECK_TOOL(MIG, mig) + +dnl Let these propagate from the environment. +AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) + +AC_OUTPUT(config.make) + +dnl Local Variables: +dnl comment-start: "dnl " +dnl comment-end: "" +dnl comment-start-skip: "\\bdnl\\b\\s *" +dnl compile-command: "autoconf" +dnl End: -- cgit v1.2.3 From 12bdc7f3469514950656659bb1244bfe91d7c4e1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 17 Sep 1995 15:05:13 +0000 Subject: (target): Changed to `fsck.ufs'. (installationdir): New variable, install into $(sbindir). --- ufs-fsck/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 61c985c6..e5c83b64 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -25,7 +25,8 @@ SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ pass5.c setup.c utilities.c inode.c OBJS = $(subst .c,.o,$(SRCS)) tables.o LCLHDRS = fsck.h -target = fsck +target = fsck.ufs +installationdir = $(sbindir) vpath tables.c ../ufs -- cgit v1.2.3 From 85e7c46e99d4f9b8d4bee31723bc1bb3da716f6b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 17 Sep 1995 15:05:49 +0000 Subject: (target): Changed to `mkfs.ufs'. (installationdir): New variable, install into $(sbindir). --- ufs-utils/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index d90a0a7b..d7a16396 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -23,7 +23,8 @@ makemode := utility SRCS = mkfs.c # newfs.c OBJS = mkfs.o # newfs.o -target = mkfs +target = mkfs.ufs +installationdir = $(sbindir) include ../Makeconf -- cgit v1.2.3 From d78cd02e81f5a75cc658ec1410ea31f165b32630 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 21 Sep 1995 23:07:35 +0000 Subject: If not in $srcdir, produce */Makefile from build.mk.in. --- configure.in | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 1d63b3ac..7603efca 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.1 1995/09/16 18:19:43 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.2 1995/09/21 23:07:35 roland Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -22,7 +22,18 @@ AC_CHECK_TOOL(MIG, mig) dnl Let these propagate from the environment. AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) -AC_OUTPUT(config.make) +if test $srcdir = .; then + # Configuring in source directory; don't create any Makefiles. + makefiles= +else + # We are configuring in a separate build tree. + # Create a Makefile in the top-level build directory and + # one for each subdirectory Makefile in the source. + makefiles="`cd $srcdir; for file in Makefile */Makefile; do \ + echo ${file}:build.mk.in; done`" +fi + +AC_OUTPUT(config.make ${makefiles}) dnl Local Variables: dnl comment-start: "dnl " -- cgit v1.2.3 From efe0caaa20d0075f7232fc022e5aecc141726413 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 22 Sep 1995 17:22:34 +0000 Subject: (get_hypermetadata): Use %Zd format for result of sizeof. --- ufs/hyper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 8a556cef..36d71728 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -1,5 +1,5 @@ /* Fetching and storing the hypermetadata (superblock and cg summary info). - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 1995 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 @@ -44,7 +44,7 @@ get_hypermetadata (void) } if (sblock->fs_bsize < sizeof (struct fs)) { - fprintf (stderr, "Block size %ld is too small (min is %ld bytes)\n", + fprintf (stderr, "Block size %ld is too small (min is %Zd bytes)\n", sblock->fs_bsize, sizeof (struct fs)); exit (1); } @@ -52,7 +52,7 @@ get_hypermetadata (void) if (sblock->fs_maxsymlinklen > (long)MAXSYMLINKLEN) { fprintf (stderr, "Max shortcut symlinklen %ld is too big (max is %ld)\n", - sblock->fs_maxsymlinklen, MAXSYMLINKLEN); + sblock->fs_maxsymlinklen, (long)MAXSYMLINKLEN); exit (1); } -- cgit v1.2.3 From a2fb0a994b568f719ac1121cf1e85220e4c13072 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 22 Sep 1995 17:32:18 +0000 Subject: (LDFLAGS): New variable. --- ufs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/Makefile b/ufs/Makefile index 28a30507..68c57928 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -25,6 +25,8 @@ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) +LDFLAGS += -static + ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a include ../Makeconf -- cgit v1.2.3 From c276c3936b9485063793d51edf435589c3629d0e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 26 Sep 1995 15:54:30 +0000 Subject: (ufs_device_name): New var. --- ufs/ufs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index aaaf4daa..34608c86 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -180,6 +180,7 @@ spin_lock_t gennumberlock; u_long nextgennumber; mach_port_t ufs_device; +char *ufs_device_name; /* The compat_mode specifies whether or not we write extensions onto the disk. */ -- cgit v1.2.3 From 14f50278054b7b5dfc465cef3e5c1afde1215629 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 26 Sep 1995 15:55:36 +0000 Subject: (main): Delete var `devname'. Use `ufs_device_name' throughout instead. --- ufs/main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 9541c956..59fb2822 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -126,7 +126,6 @@ int diskfs_readonly; void main (int argc, char **argv) { - char *devname; mach_port_t bootstrap; error_t err; int sizes[DEV_GET_SIZE_COUNT]; @@ -138,7 +137,7 @@ main (int argc, char **argv) { /* We are in a normal Hurd universe, started as a translator. */ - devname = trans_parse_args (argc, argv); + ufs_device_name = trans_parse_args (argc, argv); { /* XXX let us see errors */ @@ -152,7 +151,7 @@ main (int argc, char **argv) else { /* We are the bootstrap filesystem. */ - devname = diskfs_parse_bootargs (argc, argv); + ufs_device_name = diskfs_parse_bootargs (argc, argv); compat_mode = COMPAT_GNU; } @@ -170,24 +169,24 @@ main (int argc, char **argv) err = device_open (diskfs_master_device, (diskfs_readonly ? 0 : D_WRITE) | D_READ, - devname, &ufs_device); + ufs_device_name, &ufs_device); if (err == D_NO_SUCH_DEVICE && getpid () <= 0) { /* Prompt the user to give us another name rather than just crashing */ - printf ("Cannot open device %s\n", devname); + printf ("Cannot open device %s\n", ufs_device_name); printf ("Open instead: "); fflush (stdout); len = getline (&line, &linesz, stdin); if (len > 2) - devname = line; + ufs_device_name = line; } } while (err && err == D_NO_SUCH_DEVICE && getpid () <= 0); if (err) { - perror (devname); + perror (ufs_device_name); exit (1); } -- cgit v1.2.3 From c8ced2b9d72916cb0f7f670ca43307665fca87b4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 26 Sep 1995 16:01:55 +0000 Subject: (diskfs_S_file_get_storage_info): New function. --- ufs/inode.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index 488b2785..d6dbb1f8 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -583,3 +583,109 @@ diskfs_shutdown_soft_ports () (the only things that should be soft) XXX */ } +/* Return a description of the storage of the file. */ +/* In STORAGE_DATA are the following, in network byte order: + + Inode number (4 bytes) + disk address of transator spec (4 bytes) + disk address of inode structure (4 bytes) + offset into inode block holding inode (4 bytes) */ +void +diskfs_S_file_get_storage_info (struct protid *cred, + int *class, + int **addresses, + u_int *naddresses, + char *storage_name, + mach_port_t *storage_port, + mach_msg_type_name_t *storage_port_type, + char **storage_data, + u_int *storage_data_len) +{ + error_t err; + struct node *np; + int i; + struct dinode *di; + void *cp; + + np = cred->po->np; + mutex_lock (&np->lock); + + /* See if this file fits in the direct block pointers. If not, punt + for now. (Reading indir blocks is a pain, and I'm postponing + pain.) XXX */ + + if (np->allocsize > NDADDR * sblock->fs_bsize) + { + mutex_unlock (&np->lock); + return EINVAL; + } + + if (*naddresses < NDADDR * 2) + vm_allocate (mach_task_self (), addresses, sizeof (int) * NDADDR * 2, 1); + else + bzero (addresses, *naddresses * 2 * sizeof (int)); + *naddresses = NDADDR * 2; + + if (*storage_data_len < 4 * sizeof (int)) + vm_allocate (mach_task_self (), storage_data, sizeof (int) * 4, 1); + *storage_data_len = 4 * sizeof (int); + + di = dino (np->dn->number); + + err = diskfs_catch_exception (); + if (err) + { + mutex_unlock (&np->lock); + return err; + } + + /* Copy the block pointers */ + + if (!direct_symlink_extension + || np->dn_stat.st_size >= sblock->fs_maxsymlinklen + || !S_ISLNK (np->dn_stat.st_mode)) + { + for (i = 0; i < NDADDR; i++) + { + addresses[2 * i] = fsbtodb (di->di_db[i]); + if ((i + 1) * sblock->fs_bsize > np->allocsize) + addresses[2 * i + 1] = np->allocsize - i * sblock->fs_bsize; + else + addresses[2 * i + 1] = sblock->fs_bsize; + } + } + + /* Fill in the aux data */ + cp = *storage_data; + + *(int *)cp = htonl (np->dn->number); + cp += sizeof (int); + + *(int *)cp = htonl (di->di_trans); + cp += sizeof (int); + + *(int *)cp = htonl (fsbtodb (ino_to_fsba (sblock, np->dn->number))); + cp += sizeof (int); + + *(int *)cp = htonl (ino_to_fsbo (sblock, np->dn->number) + * sizeof (struct dinode)); + + + diskfs_end_catch_exception (); + + *class = STORAGE_DEVICE; + + strcpy (storage_name, ufs_device_name); + + if (diskfs_isuid (0, cred)) + *storage_port = ufs_device; + else + *storage_port = MACH_PORT_NULL; + *storage_port_type = MACH_MSG_TYPE_COPY_SEND; + + mutex_unlock (&np->lock); + + return 0; +} + + -- cgit v1.2.3 From 9ccc4c2d44b7ccb78ce432d0bd0b482dc9551edd Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 26 Sep 1995 19:08:05 +0000 Subject: Include . Fix trivial errors in previous change. --- ufs/inode.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index d6dbb1f8..ec4ee10b 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -19,6 +19,7 @@ #include #include #include +#include #define INOHSZ 512 #if ((INOHSZ&(INOHSZ-1)) == 0) @@ -590,7 +591,7 @@ diskfs_shutdown_soft_ports () disk address of transator spec (4 bytes) disk address of inode structure (4 bytes) offset into inode block holding inode (4 bytes) */ -void +error_t diskfs_S_file_get_storage_info (struct protid *cred, int *class, int **addresses, @@ -621,13 +622,15 @@ diskfs_S_file_get_storage_info (struct protid *cred, } if (*naddresses < NDADDR * 2) - vm_allocate (mach_task_self (), addresses, sizeof (int) * NDADDR * 2, 1); + vm_allocate (mach_task_self (), (vm_address_t *) addresses, + sizeof (int) * NDADDR * 2, 1); else bzero (addresses, *naddresses * 2 * sizeof (int)); *naddresses = NDADDR * 2; if (*storage_data_len < 4 * sizeof (int)) - vm_allocate (mach_task_self (), storage_data, sizeof (int) * 4, 1); + vm_allocate (mach_task_self (), (vm_address_t *) storage_data, + sizeof (int) * 4, 1); *storage_data_len = 4 * sizeof (int); di = dino (np->dn->number); @@ -647,11 +650,11 @@ diskfs_S_file_get_storage_info (struct protid *cred, { for (i = 0; i < NDADDR; i++) { - addresses[2 * i] = fsbtodb (di->di_db[i]); + (*addresses)[2 * i] = fsbtodb (sblock, di->di_db[i]); if ((i + 1) * sblock->fs_bsize > np->allocsize) - addresses[2 * i + 1] = np->allocsize - i * sblock->fs_bsize; + (*addresses)[2 * i + 1] = np->allocsize - i * sblock->fs_bsize; else - addresses[2 * i + 1] = sblock->fs_bsize; + (*addresses)[2 * i + 1] = sblock->fs_bsize; } } @@ -664,7 +667,7 @@ diskfs_S_file_get_storage_info (struct protid *cred, *(int *)cp = htonl (di->di_trans); cp += sizeof (int); - *(int *)cp = htonl (fsbtodb (ino_to_fsba (sblock, np->dn->number))); + *(int *)cp = htonl (fsbtodb (sblock, ino_to_fsba (sblock, np->dn->number))); cp += sizeof (int); *(int *)cp = htonl (ino_to_fsbo (sblock, np->dn->number) -- cgit v1.2.3 From b4bd1c52ebf6531164d86bd8cf6c830ba3210eb8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 1 Oct 1995 20:18:13 +0000 Subject: (dev_open): Record NAME in the returned dev structure. --- devio/dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devio/dev.c b/devio/dev.c index b120c07c..f2183f3b 100644 --- a/devio/dev.c +++ b/devio/dev.c @@ -56,9 +56,15 @@ dev_open(char *name, int flags, int block_size, struct dev **dev) if (*dev == NULL) return ENOMEM; + (*dev)->name = malloc (strlen (name) + 1); + if ((*dev)->name) + strcpy ((*dev)->name, name); + else + err = ENOMEM; + (*dev)->port = MACH_PORT_NULL; - if (device_master == MACH_PORT_NULL) + if (!err && device_master == MACH_PORT_NULL) err = get_privileged_ports(NULL, &device_master); #ifdef FAKE -- cgit v1.2.3 From 494c3bc0e7e9a8ae711f9718e3b01b4cb87f79bb Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 1 Oct 1995 20:37:24 +0000 Subject: (trivfs_S_file_get_storage_info): New function. --- devio/io.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/devio/io.c b/devio/io.c index aa0caa2c..ace87ea5 100644 --- a/devio/io.c +++ b/devio/io.c @@ -330,3 +330,45 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) return dev_sync(((struct open *)cred->po->hook)->dev, wait); } } + +/* ---------------------------------------------------------------- */ + +typedef int run_elem_t; + +error_t +trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, + run_elem_t **runs, unsigned *runs_len, + char *dev_name, mach_port_t *dev_port, + mach_msg_type_name_t *dev_port_type, + char **misc, unsigned *misc_len) +{ + error_t err; + if (!cred) + err = EOPNOTSUPP; + else + { + struct dev *dev = ((struct open *)cred->po->hook)->dev; + + err = vm_allocate (mach_task_self (), + (vm_address_t *)runs, 2 * sizeof (run_elem_t), 1); + if (!err) + { + *class = STORAGE_DEVICE; + + (*runs)[0] = 0; + (*runs)[1] = dev->size / dev->dev_block_size; + *runs_len = 2; + + strcpy (dev_name, dev->name); + + if (cred->isroot) + *dev_port = dev->port; + else + *dev_port = MACH_PORT_NULL; + *dev_port_type = MACH_MSG_TYPE_COPY_SEND; + + *misc_len = 0; + } + } + return err; +} -- cgit v1.2.3 From 2259b90b008f59de33003044c51c73f54df0bf1c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 21:22:49 +0000 Subject: (parse_opt): Rearrange slightly. --- ufs/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 59fb2822..26defc33 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -66,9 +66,13 @@ static error_t parse_opt (int opt, char *arg) { /* We currently only deal with one option... */ - if (opt != '?') - return EINVAL; - usage (0); /* never returns */ + switch (opt) + { + case '?': + usage (0); /* never returns */ + default: + return EINVAL; + } return 0; } -- cgit v1.2.3 From 7cf2b89b8518c511a2ada31beb5a925a54fdee7c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 21:35:33 +0000 Subject: (main, trivfs_S_fsys_syncfs): Get rid of debugging noise. --- devio/devio.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index 7adae2f0..3427cbe6 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -32,15 +32,6 @@ #include "open.h" #include "dev.h" - -#ifdef MSG -#define DEBUG(what) \ - ((debug) \ - ? ({ mutex_lock(&debug_lock); what; mutex_unlock(&debug_lock);0;}) \ - : 0) -#else -#define DEBUG(what) 0 -#endif /* ---------------------------------------------------------------- */ @@ -96,7 +87,6 @@ usage(int status) static struct option options[] = { {"block-size", required_argument, 0, 'B'}, - {"debug", required_argument, 0, 'D'}, {"help", no_argument, 0, '?'}, {"devnum", required_argument, 0, 'm'}, {"block", no_argument, 0, 'b'}, @@ -122,11 +112,6 @@ static int device_block_size = 0; /* A unixy device number to return when the device is stat'd. */ static int device_number = 0; -/* A stream on which we can print debugging message. */ -FILE *debug = NULL; -/* A lock to use while doing so. */ -struct mutex debug_lock; - void main(int argc, char *argv[]) { int opt; @@ -142,13 +127,10 @@ void main(int argc, char *argv[]) case 'p': device_flags |= DEV_SEEKABLE; break; case 'B': device_block_size = atoi(optarg); break; case 'd': device_number = atoi(optarg); break; - case 'D': debug = fopen(optarg, "w+"); setlinebuf(debug); break; case '?': usage(0); default: usage(1); } - mutex_init(&debug_lock); - if (device_flags & DEV_READONLY) /* Catch illegal writes at the point of open. */ trivfs_allow_open &= ~O_WRITE; @@ -362,16 +344,8 @@ trivfs_S_fsys_syncfs (struct trivfs_control *cntl, int wait, int dochildren) { struct dev *dev = device; - - DEBUG(fprintf(debug, "Syncing filesystem...\n")); - if (dev) return dev_sync(dev, wait); else return 0; } - -void -thread_cancel (thread_t foo __attribute__ ((unused))) -{ -} -- cgit v1.2.3 From c1d033c58229ba3f1dbbbeae3ea783f132838bc6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 21:36:19 +0000 Subject: (trivfs_S_file_syncfs, trivfs_S_file_sync): Get rid of debugging noise. --- devio/io.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/devio/io.c b/devio/io.c index ace87ea5..cedb3479 100644 --- a/devio/io.c +++ b/devio/io.c @@ -296,39 +296,19 @@ trivfs_S_io_mod_owner (struct trivfs_protid *cred, kern_return_t trivfs_S_file_sync (struct trivfs_protid *cred, int wait) { - if (!cred) - return EOPNOTSUPP; + if (cred) + return dev_sync (((struct open *)cred->po->hook)->dev, wait); else - { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "syncing file...\n"); - mutex_unlock(&debug_lock); - } -#endif - return dev_sync(((struct open *)cred->po->hook)->dev, wait); - } + return EOPNOTSUPP; } kern_return_t trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) { if (!cred) - return EOPNOTSUPP; + return dev_sync (((struct open *)cred->po->hook)->dev, wait); else - { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "syncing filesystem (through file)...\n"); - mutex_unlock(&debug_lock); - } -#endif - return dev_sync(((struct open *)cred->po->hook)->dev, wait); - } + return EOPNOTSUPP; } /* ---------------------------------------------------------------- */ -- cgit v1.2.3 From c450cc1485960bba22cee8c801b6930bbf24639e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 21:36:44 +0000 Subject: (pager_write_page, pager_read_page): Get rid of debugging noise. --- devio/devpager.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/devio/devpager.c b/devio/devpager.c index 02fd54ed..1f3b3ee1 100644 --- a/devio/devpager.c +++ b/devio/devpager.c @@ -47,16 +47,6 @@ pager_read_page(struct user_pager_info *upi, err = device_read(dev->port, 0, page / dev->dev_block_size, want, (io_buf_ptr_t *)buf, &read); -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_read(%d, %d) [pager] => %s, %s, %d\n", - page / dev->dev_block_size, want, - strerror(err), err ? "-" : brep(*buf, read), read); - mutex_unlock(&debug_lock); - } -#endif if (!err && want < vm_page_size) /* Zero anything we didn't read. Allocation only happens in page-size @@ -94,17 +84,6 @@ pager_write_page(struct user_pager_info *upi, err = device_write(dev->port, 0, page / dev->dev_block_size, (io_buf_ptr_t)buf, want, &written); -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_write(%d, %s, %d) [pager] => %s, %d\n", - page / dev->dev_block_size, - brep(buf, vm_page_size), vm_page_size, - strerror(err), written); - mutex_unlock(&debug_lock); - } -#endif vm_deallocate(mach_task_self(), buf, vm_page_size); -- cgit v1.2.3 From 316c49a41d429d29a5e073b42808470afde304a8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 21:37:11 +0000 Subject: (position): Get rid of debugging noise. --- devio/window.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/devio/window.c b/devio/window.c index 06f9b0fd..f7df045d 100644 --- a/devio/window.c +++ b/devio/window.c @@ -22,8 +22,6 @@ #include "window.h" #include "mem.h" - -#include "dev.h" /* for MSG & debug */ /* ---------------------------------------------------------------- */ @@ -77,15 +75,6 @@ position(struct window *win, vm_offset_t pos, vm_size_t len) vm_offset_t win_beg = win->pos; vm_offset_t win_end = win_beg + win->size; -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "position: need window on 0x%x[%d]\n", pos, len); - mutex_unlock(&debug_lock); - } -#endif - if (pos >= win_beg && end <= win_end) /* The request is totally satisfied by our current position. */ return 0; @@ -99,18 +88,7 @@ position(struct window *win, vm_offset_t pos, vm_size_t len) int prot = VM_PROT_READ | (win->read_only ? 0 : VM_PROT_WRITE); if (win->size > 0) - { -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "position: deallocating window 0x%x[%d]\n", - win_beg, win->size); - mutex_unlock(&debug_lock); - } -#endif - vm_deallocate(mach_task_self(), win->buffer, win->size); - } + vm_deallocate(mach_task_self(), win->buffer, win->size); win->pos = trunc_page(pos); win->size = round_page(len + (pos - win->pos)); @@ -122,16 +100,6 @@ position(struct window *win, vm_offset_t pos, vm_size_t len) if (win->pos + win->size > win->max_pos) win->size = win->max_pos - win->pos; -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "position: mapping window 0x%x[%d]\n", - win->pos, win->size); - mutex_unlock(&debug_lock); - } -#endif - return vm_map(mach_task_self(), &win->buffer, win->size, 0, 1, win->memobj, win->pos, 0, prot, prot, VM_INHERIT_NONE); -- cgit v1.2.3 From c72e0f882825e031241230c790078cd4a5dec863 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 22:12:34 +0000 Subject: (dev_open, dev_sync, dev_write, dev_read): Get rid of debugging noise. --- devio/dev.c | 216 ++---------------------------------------------------------- 1 file changed, 6 insertions(+), 210 deletions(-) diff --git a/devio/dev.c b/devio/dev.c index f2183f3b..4d3b89cb 100644 --- a/devio/dev.c +++ b/devio/dev.c @@ -25,16 +25,6 @@ #include "dev.h" #include "iostate.h" - -#ifdef MSG -#include -#endif -#ifdef FAKE -#include -#include -#include -#include -#endif /* ---------------------------------------------------------------- */ @@ -67,22 +57,6 @@ dev_open(char *name, int flags, int block_size, struct dev **dev) if (!err && device_master == MACH_PORT_NULL) err = get_privileged_ports(NULL, &device_master); -#ifdef FAKE - (*dev)->port = (mach_port_t) - open(name, ((flags & DEV_READONLY) ? O_RDONLY : O_RDWR)); - err = ((int)(*dev)->port == -1 ? errno : 0); - if (!err) - { - struct stat stat; - if (fstat((int)(*dev)->port, &stat) == 0) - { - (*dev)->size = stat.st_size; - (*dev)->dev_block_size = stat.st_blksize; - } - else - err = errno; - } -#else if (!err) err = device_open(device_master, D_READ | (flags & DEV_READONLY ? D_WRITE : 0), @@ -102,19 +76,6 @@ dev_open(char *name, int flags, int block_size, struct dev **dev) (*dev)->dev_block_size = sizes[DEV_GET_SIZE_RECORD_SIZE]; } } -#endif -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "dev_open(`%s', 0x%x, %d) => %s\n", - name, flags, block_size, err ? strerror(err) : "OK"); - if (!err) - fprintf(debug, " size = %d, dev_block_size = %d\n", - (*dev)->size, (*dev)->dev_block_size); - mutex_unlock(&debug_lock); - } -#endif if (!err) { @@ -194,50 +155,6 @@ dev_sync(struct dev *dev, int wait) /* ---------------------------------------------------------------- */ -#ifdef MSG -char * -brep(vm_address_t buf, vm_size_t len) -{ - static char rep[200]; - char *prep(char *buf, char *str, int len) - { - *buf++ = '`'; - while (len-- > 0) - { - int ch = *str++; - if (isprint(ch) && ch != '\'' && ch != '\\') - *buf++ = ch; - else - { - *buf++ = '\\'; - switch (ch) - { - case '\n': *buf++ = 'n'; break; - case '\t': *buf++ = 't'; break; - case '\b': *buf++ = 'b'; break; - case '\f': *buf++ = 'f'; break; - default: sprintf(buf, "%03o", ch); buf += 3; break; - } - } - } - *buf++ = '\''; - *buf = '\0'; - return buf; - } - - if (len < 40) - prep(rep, (char *)buf, (int)len); - else - { - char *end = prep(rep, (char *)buf, 20); - *end++ = '.'; *end++ = '.'; *end++ = '.'; - prep(end, (char *)buf + len - 20, 20); - } - - return rep; -} -#endif - /* Writes AMOUNT bytes from the buffer pointed to by BUF to the device DEV. *OFFS is incremented to reflect the amount read/written. Both AMOUNT and *OFFS must be multiples of DEV's block size, and either BUF must be @@ -257,67 +174,12 @@ dev_write(struct dev *dev, assert(amount % bsize == 0); if (amount < IO_INBAND_MAX) - { -#ifdef FAKE - if (*offs != dev->io_state.location) - { - err = lseek((int)dev->port, SEEK_SET, *offs); - if (err == -1) - err = errno; - else - dev->io_state.location = *offs; - } - written = write((int)dev->port, (char *)buf, amount); - err = (written < 1 ? errno : 0); - if (!err) - dev->io_state.location += written; -#else - err = - device_write_inband(dev->port, 0, block, - (io_buf_ptr_t)buf, amount, &written); -#endif -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_write_inband(%d, %s, %d) => %s, %d\n", - block, brep(buf, amount), amount, err ? strerror(err) : "OK", written); - fprintf(debug, " offset = %d => %d\n", *offs, *offs + written); -#endif - mutex_unlock(&debug_lock); - } - } + err = + device_write_inband (dev->port, 0, block, + (io_buf_ptr_t)buf, amount, &written); else - { -#ifdef FAKE - if (*offs != dev->io_state.location) - { - err = lseek((int)dev->port, SEEK_SET, *offs); - if (err == -1) - err = errno; - else - dev->io_state.location = *offs; - } - written = write((int)dev->port, (char *)buf, amount); - err = (written < 1 ? errno : 0); - if (!err) - dev->io_state.location += written; -#else err = - device_write(dev->port, 0, block, (io_buf_ptr_t)buf, amount, &written); -#endif -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_write(%d, %s, %d) => %s, %d\n", - block, brep(buf, amount), amount, - err ? strerror(err) : "OK", written); - fprintf(debug, " offset = %d => %d\n", *offs, *offs + written); - mutex_unlock(&debug_lock); - } -#endif - } + device_write (dev->port, 0, block, (io_buf_ptr_t)buf, amount, &written); if (!err) *offs += written; @@ -346,80 +208,14 @@ dev_read(struct dev *dev, { if (*buf_len < amount) err = vm_allocate(mach_task_self(), buf, amount, 1); -#ifdef FAKE - if (*offs != dev->io_state.location) - { - err = lseek((int)dev->port, SEEK_SET, *offs); - if (err == -1) - err = errno; - else - dev->io_state.location = *offs; - } - err = vm_allocate(mach_task_self(), buf, amount, 1); - if (!err) - { - read = __read((int)dev->port, (char *)*buf, amount); - err = (read == -1 ? errno : 0); - if (!err) - dev->io_state.location += read; - } -#else if (!err) err = device_read_inband(dev->port, 0, block, amount, (io_buf_ptr_t)*buf, &read); -#endif -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_read_inband(%d, %d) => %s, %s, %d\n", - block, amount, - err ? strerror(err) : "OK", err ? "-" : brep(*buf, read), - read); - if (!err) - fprintf(debug, " offset = %d => %d\n", *offs, *offs + read); - mutex_unlock(&debug_lock); - } -#endif } else - { -#ifdef FAKE - if (*offs != dev->io_state.location) - { - err = lseek((int)dev->port, SEEK_SET, *offs); - if (err == -1) - err = errno; - else - dev->io_state.location = *offs; - } - err = vm_allocate(mach_task_self(), buf, amount, 1); - if (!err) - { - read = __read((int)dev->port, (char *)*buf, amount); - err = (read == -1 ? errno : 0); - if (!err) - dev->io_state.location += read; - } -#else - err = - device_read(dev->port, 0, block, amount, (io_buf_ptr_t *)buf, &read); -#endif -#ifdef MSG - if (debug) - { - mutex_lock(&debug_lock); - fprintf(debug, "device_read(%d, %d) => %s, %s, %d\n", - block, amount, - err ? strerror(err) : "OK", err ? "-" : brep(*buf, read), - read); - if (!err) - fprintf(debug, " offset = %d => %d\n", *offs, *offs + read); - mutex_unlock(&debug_lock); - } -#endif - } + err = + device_read(dev->port, 0, block, amount, (io_buf_ptr_t *)buf, &read); if (!err) { -- cgit v1.2.3 From 276e5f3dffbea295050965336b3f3a613647d7ae Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 22:13:27 +0000 Subject: (open_write, open_read): Get rid of debugging noise. --- devio/rdwr.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/devio/rdwr.c b/devio/rdwr.c index b8431d7a..67f087a0 100644 --- a/devio/rdwr.c +++ b/devio/rdwr.c @@ -391,28 +391,6 @@ open_write(struct open *open, vm_address_t buf, vm_size_t len, else err = window_write(open->window, buf, len, amount, state.offs_p); -#ifdef MSG - if (debug) - { - char *mode = - (dev_is(dev, DEV_BUFFERED) - ? dev_is(dev, DEV_SERIAL) ? "buffered" : "windowed" : "raw"); - char *estr = err ? strerror(err) : "OK"; - char *bstr = err ? "-" : brep(buf, len); - - mutex_lock(&debug_lock); - fprintf(debug, "open_rdwr:\n using %s offset\n", - (state.user_offs == -1 || !dev_is(dev, DEV_BUFFERED)) - ? (state.offs_p == &dev->io_state.location - ? "device" : "open") - : "msg"); - fprintf(debug, " %s write(%s, %d, %d) => %s, %d\n", - mode, bstr, len, (int)offs, estr, *amount); - fprintf(debug, " offset = %d\n", (int)*state.offs_p); - mutex_unlock(&debug_lock); - } -#endif - rdwr_state_finalize(&state); return err; @@ -447,28 +425,6 @@ open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, else err = window_read(open->window, buf, buf_len, amount, state.offs_p); -#ifdef MSG - if (debug) - { - char *mode = - (dev_is(dev, DEV_BUFFERED) - ? dev_is(dev, DEV_SERIAL) ? "buffered" : "windowed" : "raw"); - char *estr = err ? strerror(err) : "OK"; - char *bstr = err ? "-" : brep(*buf, *buf_len); - - mutex_lock(&debug_lock); - fprintf(debug, "open_rdwr:\n using %s offset\n", - (state.user_offs == -1 || !dev_is(dev, DEV_BUFFERED)) - ? (state.offs_p == &dev->io_state.location - ? "device" : "open") - : "msg"); - fprintf(debug, " %s read(%d, %d) => %s, %s, %d\n", - mode, amount, (int)offs, estr, bstr, *buf_len); - fprintf(debug, " offset = %d\n", (int)*state.offs_p); - mutex_unlock(&debug_lock); - } -#endif - rdwr_state_finalize(&state); return err; -- cgit v1.2.3 From 8ed5c1ccdb201b931a6e52e3d54a37251f6a54bf Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 4 Oct 1995 22:14:12 +0000 Subject: (struct dev): Add the NAME field. --- devio/dev.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devio/dev.h b/devio/dev.h index 14ffc473..de51d788 100644 --- a/devio/dev.h +++ b/devio/dev.h @@ -44,6 +44,8 @@ struct dev { /* The device port for the kernel device we're doing paging on. */ device_t port; + /* The mach device name which we opened. */ + char *name; /* The total size of DEV. */ vm_size_t size; -- cgit v1.2.3 From d9b8f15366f3b97743dc51e85d9c22c6874ad2aa Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 5 Oct 1995 00:05:02 +0000 Subject: (diskfs_set_statfs): fsys_stb_bsize -> fsys_stb_iosize. fsys_stb_fsize -> fsys_stb_bsize. --- ufs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index ec4ee10b..2c1c7278 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -471,8 +471,8 @@ error_t diskfs_set_statfs (struct fsys_statfsbuf *st) { st->fsys_stb_type = FSTYPE_UFS; - st->fsys_stb_bsize = sblock->fs_bsize; - st->fsys_stb_fsize = sblock->fs_fsize; + st->fsys_stb_iosize = sblock->fs_bsize; + st->fsys_stb_bsize = sblock->fs_fsize; st->fsys_stb_blocks = sblock->fs_dsize; st->fsys_stb_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag + sblock->fs_cstotal.cs_nffree); -- cgit v1.2.3 From 3f0f59294d186bacd41056b48ce843056bcb5316 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 7 Oct 1995 00:26:55 +0000 Subject: (diskfs_S_file_get_storage_info): Change type of ADDRESSES to off_t **, and add the BLOCK_SIZE parameter. --- ufs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 2c1c7278..db1ef96d 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -594,8 +594,9 @@ diskfs_shutdown_soft_ports () error_t diskfs_S_file_get_storage_info (struct protid *cred, int *class, - int **addresses, + off_t **addresses, u_int *naddresses, + size_t *block_size, char *storage_name, mach_port_t *storage_port, mach_msg_type_name_t *storage_port_type, @@ -677,7 +678,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, diskfs_end_catch_exception (); *class = STORAGE_DEVICE; - + *block_size = DEV_BSIZE; + strcpy (storage_name, ufs_device_name); if (diskfs_isuid (0, cred)) -- cgit v1.2.3 From 6c2c5bbca4124343cc0a07c22363de408d1ac309 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 11 Oct 1995 17:52:20 +0000 Subject: (trivfs_S_file_get_storage_info): Change type of ADDRESSES to off_t **, and add BLOCK_SIZE parameter. --- devio/io.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devio/io.c b/devio/io.c index cedb3479..d244524b 100644 --- a/devio/io.c +++ b/devio/io.c @@ -313,11 +313,10 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) /* ---------------------------------------------------------------- */ -typedef int run_elem_t; - error_t trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, - run_elem_t **runs, unsigned *runs_len, + off_t **runs, unsigned *runs_len, + size_t *block_size, char *dev_name, mach_port_t *dev_port, mach_msg_type_name_t *dev_port_type, char **misc, unsigned *misc_len) @@ -330,7 +329,7 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, struct dev *dev = ((struct open *)cred->po->hook)->dev; err = vm_allocate (mach_task_self (), - (vm_address_t *)runs, 2 * sizeof (run_elem_t), 1); + (vm_address_t *)runs, 2 * sizeof (off_t), 1); if (!err) { *class = STORAGE_DEVICE; @@ -339,6 +338,8 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, (*runs)[1] = dev->size / dev->dev_block_size; *runs_len = 2; + *block_size = dev->dev_block_size; + strcpy (dev_name, dev->name); if (cred->isroot) -- cgit v1.2.3 From 975e0c9d698594d76b62be79788b4a0dacecab77 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:17:16 +0000 Subject: (diskfs_S_file_get_storage_info): Use DISKFS_DEVICE instead of UFS_DEVICE, and DISKFS_DEVICE_NAME instead of UFS_DEVICE_NAME. --- ufs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index db1ef96d..b15c9848 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -680,10 +680,11 @@ diskfs_S_file_get_storage_info (struct protid *cred, *class = STORAGE_DEVICE; *block_size = DEV_BSIZE; - strcpy (storage_name, ufs_device_name); + if (diskfs_device_name) + strcpy (storage_name, diskfs_device_name); if (diskfs_isuid (0, cred)) - *storage_port = ufs_device; + *storage_port = diskfs_device; else *storage_port = MACH_PORT_NULL; *storage_port_type = MACH_MSG_TYPE_COPY_SEND; -- cgit v1.2.3 From f61ca041068bd161d5011d58518625f860e2cc25 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:18:06 +0000 Subject: (diskfs_grow): Use diskfs_device_{read,write}_synce instead of dev_{read,write}_sync. --- ufs/sizes.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 8fc0b029..f4f81393 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -411,7 +411,7 @@ diskfs_grow (struct node *np, record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), + diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, sblock->fs_bsize - osize); if (bno != old_pbn) @@ -446,7 +446,7 @@ diskfs_grow (struct node *np, record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (sblock, bno) + btodb (osize), + diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, size - osize); if (bno != old_pbn) @@ -472,7 +472,7 @@ diskfs_grow (struct node *np, record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - dev_write_sync (fsbtodb (sblock, bno), zeroblock, size); + diskfs_device_write_sync (fsbtodb (sblock, bno), zeroblock, size); } } else @@ -562,7 +562,8 @@ diskfs_grow (struct node *np, goto out; indirs[0].bno = siblock[indirs[0].offset] = bno; record_poke (siblock, sblock->fs_bsize); - dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); + diskfs_device_write_sync (fsbtodb (sblock, bno), + zeroblock, sblock->fs_bsize); } out: -- cgit v1.2.3 From 6825e15589f025492e22d89a693df7638f2cd8d3 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:19:13 +0000 Subject: (pager_unlock_page, pager_write_page, pager_read_page): Use diskfs_device_{read,write}_synce instead of dev_{read,write}_sync. (pager_report_extent): Calculate the pager size. --- ufs/pager.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 51cfc6f3..3456d404 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -110,7 +110,7 @@ pager_read_page (struct user_pager_info *pager, if (addr) { - err = dev_read_sync (addr, (void *)buf, disksize); + err = diskfs_device_read_sync (addr, (void *)buf, disksize); if (!err && disksize != __vm_page_size) bzero ((void *)(*buf + disksize), __vm_page_size - disksize); *writelock = 0; @@ -148,7 +148,7 @@ pager_write_page (struct user_pager_info *pager, return err; if (addr) - err = dev_write_sync (addr, buf, disksize); + err = diskfs_device_write_sync (addr, buf, disksize); else { printf ("Attempt to write unallocated disk\n."); @@ -321,7 +321,8 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; - dev_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); + diskfs_device_write_sync (fsbtodb (sblock, bno), + zeroblock, sblock->fs_bsize); indirs[0].bno = siblock[indirs[0].offset] = bno; record_poke (siblock, sblock->fs_bsize); @@ -346,7 +347,7 @@ pager_report_extent (struct user_pager_info *pager, *offset = 0; if (pager->type == DISK) - *size = diskpagersize; + *size = diskfs_device_size << diskfs_log2_device_block_size; else *size = pager->np->allocsize; -- cgit v1.2.3 From c8980395c30ffeaf8709d94d931438819d1c0e09 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:20:07 +0000 Subject: (diskfs_set_hypermetadata): Use diskfs_device_{read,write}_synce instead of dev_{read,write}_sync. --- ufs/hyper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 36d71728..0aab1819 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -128,11 +128,13 @@ diskfs_set_hypermetadata (int wait, int clean) bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); - err = dev_read_sync (fsbtodb (sblock, sblock->fs_csaddr), &buf, bufsize); + err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), + &buf, bufsize); if (!err) { bcopy (csum, (void *) buf, sblock->fs_cssize); - dev_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize); + diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), + buf, bufsize); csum_dirty = 0; vm_deallocate (mach_task_self (), buf, bufsize); } -- cgit v1.2.3 From 56ea0379f4e7a01374bf1de6de96cafa2d0a2bfa Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:20:41 +0000 Subject: (dev_read_sync, dev_write_sync, dev_write, diskpagersize): Decls removed. --- ufs/ufs.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 34608c86..d0000e34 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -161,7 +161,6 @@ struct user_pager_info struct user_pager_info *diskpager; mach_port_t diskpagerport; -off_t diskpagersize; vm_address_t zeroblock; @@ -179,9 +178,6 @@ spin_lock_t alloclock; spin_lock_t gennumberlock; u_long nextgennumber; -mach_port_t ufs_device; -char *ufs_device_name; - /* The compat_mode specifies whether or not we write extensions onto the disk. */ enum compat_mode @@ -263,11 +259,6 @@ error_t ffs_realloccg(struct node *, daddr_t, daddr_t, error_t fetch_indir_spec (struct node *, daddr_t, struct iblock_spec *); void mark_indir_dirty (struct node *, daddr_t); -/* From devio.c: */ -error_t dev_write_sync (daddr_t addr, vm_address_t data, long len); -error_t dev_write (daddr_t addr, vm_address_t data, long len); -error_t dev_read_sync (daddr_t addr, vm_address_t *data, long len); - /* From hyper.c: */ void get_hypermetadata (void); void copy_sblock (void); -- cgit v1.2.3 From 99646ccb3e0420df928e863544995366a58f0af0 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:21:22 +0000 Subject: (SRCS): Remove devio.c. --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 68c57928..a4601cce 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -19,7 +19,7 @@ dir := ufs makemode := server target = ufs -SRCS = alloc.c consts.c devio.c dir.c hyper.c inode.c main.c pager.c \ +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 LCLHDRS = ufs.h fs.h dinode.h dir.h -- cgit v1.2.3 From cca7d86ff87cc09c30f882f49e2e13d58aec8c00 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 13 Oct 1995 23:25:14 +0000 Subject: (main): Use new handy diskfs routines and get rid of tons of junk. Main should be almost all ufs-specific now. (USAGE, usage, SHORT_OPTS, long_opts, parse_opt, trans_parse_arg): RIP. (printf_lock): Initialize. (diskfs_init_completed): Function deleted (now in libdiskfs). (thread_cancel): Function deleted. --- ufs/main.c | 213 +++++++++++-------------------------------------------------- 1 file changed, 38 insertions(+), 175 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 26defc33..f360220b 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -19,86 +19,14 @@ #include "ufs.h" #include #include +#include #include -#include #include #include #include char *ufs_version = "0.0 pre-alpha"; -/* ---------------------------------------------------------------- */ - -#define USAGE "Usage: %s [OPTION...] DEVICE\n" - -static void -usage(int status) -{ - if (status != 0) - fprintf(stderr, "Try `%s --help' for more information.\n", - program_invocation_name); - else - { - printf(USAGE, program_invocation_name); - printf("\ -\n\ - -r, --readonly disable writing to DEVICE\n\ - -w, --writable enable writing to DEVICE\n\ - -s, --sync[=INTERVAL] with an argument, sync every INTERVAL seconds,\n\ - otherwise operate in synchronous mode\n\ - -n, --nosync never sync the filesystem\n\ - --help display this help and exit\n\ - --version output version information and exit\n\ -"); - } - exit (status); -} - -#define SHORT_OPTS "" - -static struct option long_opts[] = -{ - {"help", no_argument, 0, '?'}, - {0, 0, 0, 0} -}; - -static error_t -parse_opt (int opt, char *arg) -{ - /* We currently only deal with one option... */ - switch (opt) - { - case '?': - usage (0); /* never returns */ - default: - return EINVAL; - } - return 0; -} - -/* Parse the arguments for ufs when started as a translator. */ -char * -trans_parse_args (int argc, char **argv) -{ - int argind; /* ARGV index of the first argument. */ - struct options options = - { SHORT_OPTS, long_opts, parse_opt, diskfs_standard_startup_options }; - - /* Parse our command line. */ - if (options_parse (&options, argc, argv, OPTIONS_PRINT_ERRS, &argind)) - usage (1); - - if (argc - argind != 1) - { - fprintf (stderr, USAGE, program_invocation_name); - usage (1); - } - - return argv[argind]; -} - -/* ---------------------------------------------------------------- */ - struct node *diskfs_root_node; /* Set diskfs_root_node to the root inode. */ @@ -112,7 +40,7 @@ warp_root (void) } /* XXX */ -struct mutex printf_lock; +struct mutex printf_lock = MUTEX_INITIALIZER; int printf (const char *fmt, ...) { va_list arg; @@ -126,86 +54,50 @@ int printf (const char *fmt, ...) } int diskfs_readonly; - -void + +int main (int argc, char **argv) { - mach_port_t bootstrap; error_t err; - int sizes[DEV_GET_SIZE_COUNT]; - u_int sizescnt = 2; - - mutex_init (&printf_lock); /* XXX */ + off_t disk_size; + mach_port_t bootstrap; - if (getpid () > 0) - { - /* We are in a normal Hurd universe, started as a translator. */ + argp_parse (diskfs_device_startup_argp, argc, argv, 0, 0); - ufs_device_name = trans_parse_args (argc, argv); + /* This must come after the args have been parsed, as this is where the + host priv ports are set for booting. */ + diskfs_console_stdio (); - { - /* XXX let us see errors */ - int fd = open ("/dev/console", O_RDWR); - while (fd >= 0 && fd < 2) - fd = dup(fd); - if (fd > 2) - close (fd); - } - } - else + if (diskfs_boot_flags) { /* We are the bootstrap filesystem. */ - ufs_device_name = diskfs_parse_bootargs (argc, argv); + bootstrap = MACH_PORT_NULL; + diskfs_use_mach_device = 1; compat_mode = COMPAT_GNU; } - - task_get_bootstrap_port (mach_task_self (), &bootstrap); - - /* Initialize the diskfs library. This must come before - any other diskfs call. */ - diskfs_init_diskfs (); - - do + else { - char *line = 0; - size_t linesz = 0; - ssize_t len; - - err = device_open (diskfs_master_device, - (diskfs_readonly ? 0 : D_WRITE) | D_READ, - ufs_device_name, &ufs_device); - if (err == D_NO_SUCH_DEVICE && getpid () <= 0) - { - /* Prompt the user to give us another name rather - than just crashing */ - printf ("Cannot open device %s\n", ufs_device_name); - printf ("Open instead: "); - fflush (stdout); - len = getline (&line, &linesz, stdin); - if (len > 2) - ufs_device_name = line; - } + task_get_bootstrap_port (mach_task_self (), &bootstrap); + if (bootstrap == MACH_PORT_NULL) + error (2, 0, "Must be started as a translator"); } - while (err && err == D_NO_SUCH_DEVICE && getpid () <= 0); - + + /* Initialize the diskfs library. Must come before any other diskfs call. */ + diskfs_init_diskfs (); + + err = diskfs_device_open (); if (err) - { - perror (ufs_device_name); - exit (1); - } + error (3, err, "%s", diskfs_device_arg); - /* Check to make sure device sector size is reasonable. */ - err = device_get_status (ufs_device, DEV_GET_SIZE, sizes, &sizescnt); - assert (sizescnt == DEV_GET_SIZE_COUNT); - if (sizes[DEV_GET_SIZE_RECORD_SIZE] != DEV_BSIZE) - { - fprintf (stderr, "Bad device record size %d (should be %d)\n", - sizes[DEV_GET_SIZE_RECORD_SIZE], DEV_BSIZE); - exit (1); - } - - diskpagersize = sizes[DEV_GET_SIZE_DEVICE_SIZE]; - assert (diskpagersize >= SBSIZE + SBOFF); + if (diskfs_device_block_size != DEV_BSIZE) + error (4, err, "%s: Bad device record size %d (should be %d)", + diskfs_device_arg, diskfs_device_block_size, DEV_BSIZE); + if (diskfs_log2_device_block_size == 0) + error (4, err, "%s: Device block size (%d) not a power of 2", + diskfs_device_arg, diskfs_device_block_size); + + disk_size = diskfs_device_size << diskfs_log2_device_block_size; + assert (disk_size >= SBSIZE + SBOFF); /* Map the entire disk. */ create_disk_pager (); @@ -214,7 +106,7 @@ main (int argc, char **argv) diskfs_spawn_first_thread (); err = vm_map (mach_task_self (), (vm_address_t *)&disk_image, - diskpagersize, 0, 1, diskpagerport, 0, 0, + disk_size, 0, 1, diskpagerport, 0, 0, VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), VM_INHERIT_NONE); @@ -222,13 +114,12 @@ main (int argc, char **argv) get_hypermetadata (); - if (diskpagersize < sblock->fs_size * sblock->fs_fsize) + if (disk_size < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size (%d) less than necessary " + "Disk size (%ld) less than necessary " "(superblock says we need %ld)\n", - sizes[DEV_GET_SIZE_DEVICE_SIZE], - sblock->fs_size * sblock->fs_fsize); + disk_size, sblock->fs_size * sblock->fs_fsize); exit (1); } @@ -258,38 +149,10 @@ main (int argc, char **argv) /* 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 outside world. */ - (void) diskfs_startup_diskfs (bootstrap); - - if (bootstrap == MACH_PORT_NULL) - /* We are the bootstrap filesystem; do special boot-time setup. */ - diskfs_start_bootstrap (argv); + diskfs_startup_diskfs (bootstrap); /* And this thread is done with its work. */ cthread_exit (0); -} - - -void -diskfs_init_completed () -{ - mach_port_t proc, startup; - error_t err; - - proc = getproc (); - proc_register_version (proc, diskfs_host_priv, "ufs", HURD_RELEASE, - ufs_version); - err = proc_getmsgport (proc, 1, &startup); - if (!err) - { - startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL, - "ufs", diskfs_host_priv); - mach_port_deallocate (mach_task_self (), startup); - } - mach_port_deallocate (mach_task_self (), proc); -} - -void -thread_cancel (thread_t foo __attribute__ ((unused))) -{ + return 0; } -- cgit v1.2.3 From c5f73a54a6c4162a220b3e53d5f623d5e353a14a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:15:56 +0000 Subject: (main): Only print section headers if not in preen mode. (main): Use getopt to parse command line options. (usage): New function. (options): New variable. (lfname, lfmode): Variables moved here from setup.c. (lfname): Made into a char* so that we can change it. (lfmode): Get rid of IFDIR; it's added when necessary. --- ufs-fsck/main.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 65f60453..5fbabc76 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -18,43 +18,105 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include + #include "fsck.h" -/* Pretty primitive, I'm afraid. */ +char *lfname = "lost+found"; +mode_t lfmode = 0755; + +#define USAGE "Usage: %s [OPTION...] DEVICE\n" + +static void +usage(int status) +{ + if (status != 0) + fprintf(stderr, "Try `%s --help' for more information.\n", + program_invocation_name); + else + { + printf(USAGE, program_invocation_name); + printf("\ +\n\ + -p, --preen Terse automatic mode\n\ + -y, --yes Automatically answer yes to all questions\n\ + -n, --no Automatically answer no to all questions\n\ + -l, --lost+found=NAME The name of the lost+found directory in /\n\ + -m, --lf-mode=MODE The name of the lost+found directory in /\n\ + --help Give this usage message\n\ +"); + } + + exit(status); +} + +#define SHORT_OPTIONS "pynlm&" + +static struct option options[] = +{ + {"preen", no_argument, 0, 'p'}, + {"yes", no_argument, 0, 'y'}, + {"no", no_argument, 0, 'n'}, + {"lost+found", required_argument, 0, 'l'}, + {"lf-mode", required_argument, 0, 'm'}, + {"help", no_argument, 0, '&'}, + {0, 0, 0, 0} +}; int main (int argc, char **argv) { - if (argc != 2) + int opt; + + preen = nowrite = noquery = 0; + + while ((opt = getopt_long (argc, argv, SHORT_OPTIONS, options, 0)) != EOF) + switch (opt) + { + case 'p': preen = 1; break; + case 'y': noquery = 1; break; + case 'n': nowrite = 1; break; + case 'l': lfname = optarg; break; + case 'm': lfmode = strtol (optarg, 0, 8); break; + case '&': usage(0); + default: usage(1); + } + + if (argv[optind] == 0 || argv[optind + 1] != 0) { - fprintf (stderr, "Usage: %s device", argv[0]); - exit (1); + fprintf(stderr, USAGE, program_invocation_name); + usage (1); } - - preen = 0; - - if (!setup (argv[1])) + + if (!setup (argv[optind])) exit (1); - printf ("** Phase 1 -- Check Blocks and Sizes\n"); + if (!preen) + printf ("** Phase 1 -- Check Blocks and Sizes\n"); pass1 (); if (duplist) { - printf ("** Phase 1b -- Rescan for More Duplicates\n"); + if (!preen) + printf ("** Phase 1b -- Rescan for More Duplicates\n"); pass1b (); } - printf ("** Phase 2 -- Check Pathnames\n"); + if (!preen) + printf ("** Phase 2 -- Check Pathnames\n"); pass2 (); - printf ("** Phase 3 -- Check Connectivity\n"); + if (!preen) + printf ("** Phase 3 -- Check Connectivity\n"); pass3 (); - printf ("** Phase 4 -- Check Reference Counts\n"); + if (!preen) + printf ("** Phase 4 -- Check Reference Counts\n"); pass4 (); - printf ("** Phase 5 -- Check Cyl Groups\n"); + if (!preen) + printf ("** Phase 5 -- Check Cyl Groups\n"); pass5 (); if (fsmodified) -- cgit v1.2.3 From 34d69fc621e7aa3bb9155d8bec8bd4bd276b08b7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:17:08 +0000 Subject: (linkup): Print the value of LFNAME rather than `lost+found'. (searchdir, changeino): Fix backward compare. (linkup): Don't fail when makeentry succeeds. (searchdir): Make searchdir return zero if there's an error during the search. (linkup): Print appropiate error messages if searchdir fails. (validdir): Get rid of extra newlines in error messages -- everyone who calls this routine prints extra information if it fails, which should immediately follow. --- ufs-fsck/dir.c | 89 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index dc1f1dda..8d32aee4 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -89,15 +89,15 @@ validdir (ino_t dir, char *action) return 1; case UNALLOC: - pfatal ("CANNOT %s I=%d; NOT ALLOCATED\n", action, dir); + pfatal ("CANNOT %s I=%d; NOT ALLOCATED", action, dir); return 0; case BADDIR: - pfatal ("CANNOT %s I=%d; BAD BLOCKS\n", action, dir); + pfatal ("CANNOT %s I=%d; BAD BLOCKS", action, dir); return 0; case REG: - pfatal ("CANNOT %s I=%d; NOT DIRECTORY\n", action, dir); + pfatal ("CANNOT %s I=%d; NOT DIRECTORY", action, dir); return 0; default: @@ -106,8 +106,9 @@ validdir (ino_t dir, char *action) } /* Search directory DIR for name NAME. If NAME is found, then - set *INO to the inode of the entry; otherwise clear INO. */ -void + set *INO to the inode of the entry; otherwise clear INO. Returns 1 if all + was normal, or 0 if there was some error doing the search. */ +int searchdir (ino_t dir, char *name, ino_t *ino) { struct dinode dino; @@ -126,15 +127,15 @@ searchdir (ino_t dir, char *name, ino_t *ino) if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) return; + if (dp->d_ino == 0 || dp->d_ino > maxino) continue; - if (DIRECT_NAMLEN (dp) != len) - continue; - if (!strcmp (dp->d_name, name)) - continue; - - *ino = dp->d_ino; - return; + + if (DIRECT_NAMLEN (dp) == len && strcmp (dp->d_name, name) == 0) + { + *ino = dp->d_ino; + return; + } } } @@ -163,12 +164,14 @@ searchdir (ino_t dir, char *name, ino_t *ino) *ino = 0; if (!validdir (dir, "READ")) - return; + return 0; getinode (dir, &dino); len = strlen (name); datablocks_iterate (&dino, checkdirblock); + + return 1; } /* Change the existing entry in DIR for name NAME to be @@ -195,16 +198,16 @@ changeino (ino_t dir, char *name, ino_t ino) if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) return 0; + if (dp->d_ino == 0 || dp->d_ino > maxino) continue; - if (DIRECT_NAMLEN (dp) != len) - continue; - if (!strcmp (dp->d_name, name)) - continue; - - dp->d_ino = ino; - madechange = 1; - return 1; + + if (DIRECT_NAMLEN (dp) == len && strcmp (dp->d_name, name) == 0) + { + dp->d_ino = ino; + madechange = 1; + return 1; + } } return 0; } @@ -427,16 +430,21 @@ allocdir (ino_t parent, ino_t request, mode_t mode) int linkup (ino_t ino, ino_t parent) { + int search_failed; struct dinode lfdino; char *tempname; ino_t foo; if (lfdir == 0) { - searchdir (ROOTINO, lfname, &lfdir); + if (!searchdir (ROOTINO, lfname, &lfdir)) + { + pfatal ("FAILURE SEARCHING FOR %s\n", lfname); + return 0; + } if (lfdir == 0) { - pwarn ("NO lost+found DIRECTORY"); + pwarn ("NO %s DIRECTORY", lfname); if (preen || reply ("CREATE")) { lfdir = allocdir (ROOTINO, 0, lfmode); @@ -459,8 +467,7 @@ linkup (ino_t ino, ino_t parent) } if (!lfdir) { - pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); - printf ("\n\n"); + pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); return 0; } } @@ -471,7 +478,7 @@ linkup (ino_t ino, ino_t parent) { ino_t oldlfdir; - pfatal ("lost+found IS NOT A DIRECTORY"); + pfatal ("%s IS NOT A DIRECTORY", lfname); if (!reply ("REALLOCATE")) return 0; @@ -480,14 +487,12 @@ linkup (ino_t ino, ino_t parent) lfdir = allocdir (ROOTINO, 0, lfmode); if (!lfdir) { - pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); - printf ("\n\n"); + pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); return 0; } if (!changeino (ROOTINO, lfname, lfdir)) { - pfatal ("SORRY, CANNOT CREATE lost+found DIRECTORY"); - printf ("\n\n"); + pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); return 0; } @@ -499,24 +504,30 @@ linkup (ino_t ino, ino_t parent) if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF)) { - pfatal ("SORRY. lost+found DIRECTORY NOT ALLOCATED.\n\n"); + pfatal ("SORRY. %s DIRECTORY NOT ALLOCATED\n", lfname); return 0; } + asprintf (&tempname, "#%d", ino); - searchdir (lfdir, tempname, &foo); + search_failed = !searchdir (lfdir, tempname, &foo); while (foo) { char *newname; asprintf (&newname, "%sa", tempname); free (tempname); tempname = newname; - searchdir (lfdir, tempname, &foo); + search_failed = !searchdir (lfdir, tempname, &foo); } - if (makeentry (lfdir, ino, tempname)) + if (search_failed) { free (tempname); - pfatal("SORRY. NO SPACE IN lost+found DIRECTORY"); - printf("\n\n"); + pfatal ("FAILURE SEARCHING FOR %s in %s\n", tempname, lfname); + return 0; + } + if (!makeentry (lfdir, ino, tempname)) + { + free (tempname); + pfatal("SORRY, NO SPACE IN %s DIRECTORY\n", lfname); return 0; } free (tempname); @@ -529,7 +540,7 @@ linkup (ino_t ino, ino_t parent) { if (!changeino (ino, "..", lfdir)) { - pfatal ("CANNOT ADJUST .. link I=%u", ino); + pfatal ("CANNOT ADJUST .. link I=%u\n", ino); return 0; } /* Forget about link to old parent */ @@ -537,7 +548,7 @@ linkup (ino_t ino, ino_t parent) } else if (!makeentry (ino, lfdir, "..")) { - pfatal ("CANNOT CREAT .. link I=%u", ino); + pfatal ("CANNOT CREAT .. link I=%u\n", ino); return 0; } @@ -556,5 +567,3 @@ linkup (ino_t ino, ino_t parent) } return 1; } - - -- cgit v1.2.3 From 09e045446610c64d4dff9b0cb3ab7d897a74959c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:18:35 +0000 Subject: (pass1): Only print progress report if not in preen mode. (pass1): Change the extent of DBWARN & IBWARN so that they actually work. (pass1): Call pfix instead of printf. --- ufs-fsck/pass1.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index c97ffc33..f9ad9047 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -69,14 +69,13 @@ pass1 () blkerror = 1; wasbad = 1; if (nblkrngerrors == 0) - printf ("I=%d HAS BAD BLOCKS\n", number); + pwarn ("I=%d HAS BAD BLOCKS\n", number); if (nblkrngerrors++ > MAXBAD) { pwarn ("EXCESSIVE BAD BLKS I=%d", number); if (preen || reply ("SKIP")) { - if (preen) - printf (" (SKIPPING)\n"); + pfix ("SKIPPING"); return RET_STOP; } } @@ -85,7 +84,7 @@ pass1 () for (; nfrags > 0; bno++, nfrags--) { if (outofrange && check_range (bno, 1)) - printf ("BAD BLOCK %lu\n", bno); + pwarn ("BAD BLOCK %lu\n", bno); else { if (!testbmap (bno)) @@ -94,16 +93,15 @@ pass1 () { blkerror = 1; if (nblkduperrors == 0) - printf ("I=%d HAS DUPLICATE BLOCKS\n", number); - printf ("DUPLICATE BLOCK %ld\n", bno); + pwarn ("I=%d HAS DUPLICATE BLOCKS\n", number); + pwarn ("DUPLICATE BLOCK %ld\n", bno); wasbad = 1; if (nblkduperrors++ > MAXBAD) { pwarn ("EXCESSIVE DUP BLKS I=%d", number); if (preen || reply ("SKIP")) { - if (preen) - printf (" (SKIPPING)\n"); + pfix ("SKIPPING"); return RET_STOP; } } @@ -162,7 +160,11 @@ pass1 () for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++) for (i = 0; i < sblock->fs_ipg; i++, number++) { - if (!(number % 10000)) + /* These record whether we've already complained about extra + direct/indirect blocks. */ + int dbwarn = 0, ibwarn = 0; + + if (!preen && !(number % 10000)) printf ("I=%d\n", number); if (number < ROOTINO) @@ -185,8 +187,7 @@ pass1 () pwarn ("PARTIALLY ALLOCATED INODE I=%d", number); if (preen || reply ("CLEAR")) { - if (preen) - printf (" (CLEARED)\n"); + pfix ("CLEARED"); clear_inode (number, dp); } } @@ -212,7 +213,7 @@ pass1 () continue; } inodestate[number] = UNALLOC; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", + pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", number); holdallblocks = 1; } @@ -279,7 +280,7 @@ pass1 () } inodestate[number] = UNALLOC; holdallblocks = 1; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%d " + pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d " "AS ALLOCATED\n", number); ndb = 0; } @@ -295,7 +296,7 @@ pass1 () continue; } inodestate[number] = UNALLOC; - printf ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", + pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", number); holdallblocks = 1; } @@ -326,7 +327,6 @@ pass1 () amount necessary to be zero. */ for (lbn = ndb; lbn < NDADDR; lbn++) { - int dbwarn = 0; if (dp->di_db[lbn]) { if (!dbwarn) @@ -336,8 +336,7 @@ pass1 () number); if (preen || reply ("DEALLOCATE")) { - if (preen) - printf (" (DEALLOCATED)\n"); + pfix ("DEALLOCATED"); dp->di_db[lbn] = 0; dbwarn = 2; } @@ -353,7 +352,6 @@ pass1 () ndb /= NINDIR (sblock); for (; lbn < NIADDR; lbn++) { - int ibwarn = 0; if (dp->di_ib[lbn]) { if (ibwarn) @@ -363,8 +361,7 @@ pass1 () number); if (preen || reply ("DEALLOCATE")) { - if (preen) - printf (" (DEALLOCATED)\n"); + pfix ("DEALLOCATED"); dp->di_ib[lbn] = 0; ibwarn = 2; } @@ -400,7 +397,7 @@ pass1 () pfatal ("DUPLICATE or BAD BLOCKS"); else { - printf ("I=%d has ", number); + pwarn ("I=%d has ", number); if (nblkduperrors) { printf ("%d DUPLICATE BLOCKS", nblkduperrors); @@ -425,10 +422,9 @@ pass1 () number, dp->di_blocks, nblocks); if (preen || reply ("CORRECT")) { - if (preen) - printf (" (CORRECTED)"); dp->di_blocks = nblocks; write_inode (number, dp); + pfix ("CORRECTED"); } } -- cgit v1.2.3 From f1b7b63560c04f69c854a2ffe563a857c058df6d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:20:00 +0000 Subject: (pass2): Adjust our record of link counts when we add/change dir entries; also print error messages when we can't. (pass2): Use changed pinode. (pass2): Call pfix instead of printf. --- ufs-fsck/pass2.c | 56 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 6f508074..28982384 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -92,8 +92,7 @@ pass2 () /* Check INO */ if (inodestate[dp->d_ino] == UNALLOC) { - printf ("REF TO UNALLOCATED NODE; DIR"); - pinode (dnp->i_number); + pinode (dnp->i_number, "REF TO UNALLOCATED NODE IN"); if (reply ("REMOVE")) { dp->d_ino = 0; @@ -183,8 +182,7 @@ pass2 () pwarn ("FOUND IN DIR I=%d", dnp->i_number); if (preen || reply ("REMOVE")) { - if (preen) - printf (" (REMOVED)"); + pfix ("REMOVED"); dp->d_ino = 0; mod = 1; } @@ -276,11 +274,10 @@ pass2 () dnp->i_number, dnp->i_isize, DIRBLKSIZ); if (preen || reply ("ADJUST")) { - if (preen) - printf (" (ADJUSTED)"); getinode (dnp->i_number, &dino); dino.di_size = roundup (dnp->i_isize, DIRBLKSIZ); write_inode (dnp->i_number, &dino); + pfix ("ADJUSTED"); } } bzero (&dino, sizeof (struct dinode)); @@ -311,20 +308,30 @@ pass2 () if (dnp->i_parent && dnp->i_dotdot == 0) { dnp->i_dotdot = dnp->i_parent; - - printf ("MISSING `..' IN DIR"); - pinode (dnp->i_number); + pinode (dnp->i_number, "MISSING `..' IN"); if (reply ("FIX")) - makeentry (dnp->i_number, dnp->i_parent, ".."); + if (makeentry (dnp->i_number, dnp->i_parent, "..")) + linkfound[dnp->i_parent]++; + else + pfatal ("COULDN'T ADD `..'\n"); } else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) { - printf ("BAD INODE NUMBER FOR `..' IN DIR"); - pinode (dnp->i_number); + pinode (dnp->i_number, "BAD INODE NUMBER FOR `..' IN"); if (reply ("FIX")) { - dnp->i_dotdot = dnp->i_parent; - changeino (dnp->i_number, "..", dnp->i_parent); + ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot; + dnp->i_dotdot = parent; + if (changeino (dnp->i_number, "..", parent)) + /* Adjust what the parent's link count should be; the actual + count will be corrected in an later pass. */ + { + linkfound[parent]++; + if (inodestate[old_dotdot] != UNALLOC) + linkfound[old_dotdot]--; + } + else + pfatal ("COULDN'T CHANGE `..'\n"); } } @@ -332,19 +339,28 @@ pass2 () if (dnp->i_dot == 0) { dnp->i_dot = dnp->i_number; - printf ("MISSING `.' IN DIR"); - pinode (dnp->i_number); + pinode (dnp->i_number, "MISSING `.' IN"); if (reply ("FIX")) - makeentry (dnp->i_number, dnp->i_number, "."); + if (makeentry (dnp->i_number, dnp->i_number, ".")) + linkfound[dnp->i_number]++; + else + pfatal ("COULDN'T ADD `.'\n"); } else if (dnp->i_dot != dnp->i_number) { - printf ("BAD INODE NUMBER FOR `.' IN DIR"); - pinode (dnp->i_number); + pinode (dnp->i_number, "BAD INODE NUMBER FOR `.' IN"); if (reply ("FIX")) { + ino_t old_dot = dnp->i_dot; dnp->i_dot = dnp->i_number; - changeino (dnp->i_number, ".", dnp->i_number); + if (changeino (dnp->i_number, ".", dnp->i_number)) + { + linkfound[dnp->i_number]++; + if (inodestate[old_dot] != UNALLOC) + linkfound[old_dot]--; + } + else + pfatal ("COULDN'T CHANGE `.'\n"); } } } -- cgit v1.2.3 From 1d7ee02b6e09ef2b5cf94b942028d0894a282b19 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:21:04 +0000 Subject: (pass3): Use changed pinode. (pass3): Call pfix instead of printf. --- ufs-fsck/pass3.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/pass3.c b/ufs-fsck/pass3.c index 2af148ee..7353c9f2 100644 --- a/ufs-fsck/pass3.c +++ b/ufs-fsck/pass3.c @@ -57,13 +57,13 @@ pass3 () { if (inodestate[dnp->i_number] & DIR_REF) errexit ("ORPHANED DIR MARKED WITH CONNECT"); - pwarn ("UNREF DIR"); - pinode (dnp->i_number); - if (preen) - printf (" (RECONNECTED)"); + pinode (dnp->i_number, "UNREF"); if (preen || reply ("RECONNECT")) - if (linkup (dnp->i_number, dnp->i_dotdot)) - dnp->i_parent = dnp->i_dotdot = lfdir; + { + if (linkup (dnp->i_number, dnp->i_dotdot)) + dnp->i_parent = dnp->i_dotdot = lfdir; + pfix ("RECONNECTED"); + } } } } -- cgit v1.2.3 From f36207c8ebc118edcffa68bd596257415903c4fc Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:21:52 +0000 Subject: (pass4): If an unlinked file can't be reconnected, offer to clear it. Once a reconnect attempt fails, don't try again. (pass4): Use changed pinode. (pass4): Call pfix instead of printf. --- ufs-fsck/pass4.c | 49 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 7ba50baf..bd1c7541 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -24,6 +24,8 @@ void pass4() { ino_t number; + /* True if any reconnect attempt failed, in which case we don't try again. */ + int reconn_failed = 0; for (number = ROOTINO; number < maxino; number++) { @@ -31,19 +33,15 @@ pass4() { if (linkcount[number] != linkfound[number]) { - struct dinode dino; - getinode (number, &dino); - pwarn ("LINK COUNT %s", - (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE"); - pinode (number); - printf (" COUNT %d SHOULD BE %d", linkcount[number], - linkfound[number]); - if (preen) - printf (" (ADJUSTED)"); + pinode (number, "LINK COUNT %d SHOULD BE %d IN", + linkcount[number], linkfound[number]); if (preen || reply ("ADJUST")) { + struct dinode dino; + getinode (number, &dino); dino.di_nlink = linkfound[number]; write_inode (number, &dino); + pfix ("ADJUSTED"); } } } @@ -59,48 +57,31 @@ pass4() we want to clear it; if the size is positive, then we want to reattach in. */ struct dinode dino; + + pinode (number, "UNREF"); getinode (number, &dino); - - if (dino.di_size) + if (dino.di_size && !reconn_failed) { /* This can't happen for dirctories because pass 3 should already have reset them up. */ if ((DI_MODE (&dino) & IFMT) == IFDIR) errexit ("NO LINKS TO NONZERO DIRECTORY"); - pwarn ("UNREF FILE"); - pinode (number); - if (preen) - printf (" (RECONNECTED)"); if (preen || reply ("RECONNECT")) - linkup (number, -1); + reconn_failed = !linkup (number, -1); + if (!reconn_failed) + pfix ("RECONNECTED"); } - else + if (dino.di_size == 0 || reconn_failed) { - pwarn ("UNREF %s", - (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE"); - pinode (number); - if (preen) - printf (" (CLEARED)"); if (preen || reply ("CLEAR")) { inodestate[number] = UNALLOC; clear_inode (number, &dino); } + pfix ("CLEARED"); } } } } - - - - - - - - - - - - -- cgit v1.2.3 From df23a6366c08d22b675426d3a1b22578bd580051 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:22:27 +0000 Subject: (pass5): Call pfix instead of printf. --- ufs-fsck/pass5.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index dccd2140..a38ac426 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -185,8 +185,7 @@ pass5 () pwarn ("ILLEGAL ROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); newcg->cg_rotor = 0; cg->cg_rotor = 0; writecg = 1; @@ -197,8 +196,7 @@ pass5 () pwarn ("ILLEGAL FROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); newcg->cg_frotor = 0; cg->cg_frotor = 0; writecg = 1; @@ -209,8 +207,7 @@ pass5 () pwarn ("ILLEGAL IROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); newcg->cg_irotor = 0; cg->cg_irotor = 0; writecg = 1; @@ -308,8 +305,7 @@ pass5 () pwarn ("FREE BLK COUNTS FOR CG %d WRONG IN SUPERBLOCK", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); bcopy (&newcg->cg_cs, &sbcsums[c], sizeof (struct csum)); writecsum = 1; } @@ -321,8 +317,7 @@ pass5 () pwarn ("BLKS OR INOS MISSING IN CG %d BIT MAPS", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); bcopy (cg_inosused (newcg), cg_inosused (cg), mapsize); writecg = 1; } @@ -333,8 +328,7 @@ pass5 () pwarn ("SUMMARY INFORMATION FOR CG %d BAD", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); bcopy (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize); writecg = 1; } @@ -345,8 +339,7 @@ pass5 () pwarn ("CYLINDER GROUP %d BAD", c); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); bcopy (newcg, cg, basesize); writecg = 1; } @@ -366,8 +359,7 @@ pass5 () pwarn ("TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK"); if (preen || reply ("FIX")) { - if (preen) - printf (" (FIXED)"); + pfix ("FIXED"); bcopy (&cstotal, &sblock->fs_cstotal, sizeof (struct csum)); sblock->fs_ronly = 0; sblock->fs_fmod = 0; -- cgit v1.2.3 From 2d5177fd19a408df9c492368876b469e8958bdec Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:23:28 +0000 Subject: (setup): Set DEVICE_NAME. (lfname, lfmode): Variables moved to main.c. --- ufs-fsck/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index f3faf07d..9d5d3d24 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -25,8 +25,8 @@ static char sblockbuf[SBSIZE]; struct fs *sblock = (struct fs *)sblockbuf; -char lfname[] = "lost+found"; -mode_t lfmode = IFDIR | 0755; +/* A string identifying what we're trying to check. */ +char *device_name = 0; /* Get ready to run on device with pathname DEV. */ int @@ -36,6 +36,8 @@ setup (char *dev) int changedsb; size_t bmapsize; + device_name = dev; + if (stat (dev, &st) == -1) { perror (dev); -- cgit v1.2.3 From 6c904583737f69b016eedecb9bed3ace6e7d78d6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:24:16 +0000 Subject: Declare DEVICE_NAME. Change declaration of pinode. Change LFNAME to char*. --- ufs-fsck/fsck.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 5bcc6014..6dbd0886 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -1,4 +1,3 @@ - /* Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell. @@ -53,6 +52,9 @@ char *typemap; /* Map of blocks allocated */ char *blockmap; +/* A string identifying what we're trying to check. */ +extern char *device_name; + /* Command line flags */ int nowrite; /* all questions fail */ @@ -114,9 +116,9 @@ int readfd, writefd; int fsmodified; int lfdir; -char lfname[]; -mode_t lfmode; +mode_t lfmode; +extern char *lfname; #define NBBY 8 #define howmany(x,y) (((x)+((y)-1))/(y)) @@ -163,11 +165,10 @@ void allblock_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); void record_directory (struct dinode *, ino_t); struct dirinfo *lookup_directory (ino_t); -void pinode (ino_t); - int reply (char *); +void pfix (char *fix); +void pinode (ino_t, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +int pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); int pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), noreturn)); -int pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); - -- cgit v1.2.3 From 2953c00ea439a81ad4f69aa5a32547ea097ad496 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 18 Oct 1995 17:24:57 +0000 Subject: (pfix): New function. (pfatal, pwarn, errexit): Print DEVICE_NAME too if in preen mode. (pinode): Take a message & args to print as well. --- ufs-fsck/utilities.c | 65 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index d5ff8c1b..32ce52d7 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -164,6 +164,9 @@ pfatal (char *fmt, ...) { va_list args; int ret; + + if (preen && device_name) + printf ("%s: ", device_name); va_start (args, fmt); ret = vprintf (fmt, args); @@ -181,6 +184,9 @@ errexit (char *fmt, ...) { va_list args; + if (preen && device_name) + printf ("%s: ", device_name); + va_start (args, fmt); vprintf (fmt, args); va_end (args); @@ -196,12 +202,24 @@ pwarn (char *fmt, ...) va_list args; int ret; + if (preen && device_name) + printf ("%s: ", device_name); + va_start (args, fmt); ret = vprintf (fmt, args); va_end (args); + return ret; } +/* Print how a problem was fixed in preen mode. */ +void +pfix (char *fix) +{ + if (preen) + printf (" (%s)\n", fix); +} + /* Ask the user a question; return 1 if the user says yes, and 0 if the user says no. */ int @@ -244,27 +262,40 @@ reply (char *question) /* Print a helpful description of the given inode number. */ void -pinode (ino_t ino) +pinode (ino_t ino, char *fmt, ...) { - struct dinode dino; - struct passwd *pw; - char *p; + if (fmt) + { + va_list args; + va_start (args, fmt); + vprintf (fmt, args); + va_end (args); + putchar (' '); + } - printf (" I=%d ", ino); if (ino < ROOTINO || ino > maxino) - return; - getinode (ino, &dino); - - printf (" OWNER="); - pw = getpwuid (dino.di_uid); - if (pw) - printf ("%s ", pw->pw_name); + printf (" NODE I=%d", ino); else - printf ("%lu ", dino.di_uid); + { + char *p; + struct dinode dino; + struct passwd *pw; + + getinode (ino, &dino); + + printf ("%s I=%d", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE", + ino); + + pw = getpwuid (dino.di_uid); + if (pw) + printf (" OWNER=%s", pw->pw_name); + else + printf (" OWNER=%lu", dino.di_uid); - printf (" MODE=%o\n", DI_MODE (&dino)); - printf ("SIZE=%llu ", dino.di_size); - p = ctime (&dino.di_mtime.ts_sec); - printf ("MTIME=%12.12s %4.4s ", &p[4], &p[20]); + printf (" MODE=%o", DI_MODE (&dino)); + printf (" SIZE=%llu ", dino.di_size); + p = ctime (&dino.di_mtime.ts_sec); + printf (" MTIME=%12.12s %4.4s", &p[4], &p[20]); + } } -- cgit v1.2.3 From 99e1a1cbb3b4cb72e794d48735280a106c28f1c8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:23:12 +0000 Subject: (diskfs_lookup, diskfs_dirempty): Give diskfs_get_filemap a protection arg. --- ufs/dir.c | 15 ++++++--------- ufs/sizes.c | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index ff79cc1e..f8150d64 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -95,6 +95,8 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, struct node *np = 0; int retry_dotdot = 0; memory_object_t memobj; + vm_prot_t prot = + (type == LOOKUP) ? VM_PROT_READ : (VM_PROT_READ | VM_PROT_WRITE); vm_address_t buf = 0; vm_size_t buflen = 0; int blockaddr; @@ -136,17 +138,12 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, ds->stat = LOOKING; /* Map in the directory contents. */ - memobj = diskfs_get_filemap (dp); + memobj = diskfs_get_filemap (dp, prot); buf = 0; /* We allow extra space in case we have to do an EXTEND. */ buflen = round_page (dp->dn_stat.st_size + DIRBLKSIZ); - if (type == LOOKUP) - /* Map read-only; we won't be writing */ - err = vm_map (mach_task_self (), &buf, buflen, 0, 1, memobj, 0, 0, - VM_PROT_READ, VM_PROT_READ, 0); - else - err = vm_map (mach_task_self (), &buf, buflen, 0, 1, memobj, 0, 0, - VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, 0); + err = vm_map (mach_task_self (), + &buf, buflen, 0, 1, memobj, 0, 0, prot, prot, 0); mach_port_deallocate (mach_task_self (), memobj); inum = 0; @@ -664,7 +661,7 @@ diskfs_dirempty(struct node *dp, memory_object_t memobj; error_t err; - memobj = diskfs_get_filemap (dp); + memobj = diskfs_get_filemap (dp, VM_PROT_READ); buf = 0; err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, diff --git a/ufs/sizes.c b/ufs/sizes.c index f4f81393..0dadac28 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -101,7 +101,7 @@ diskfs_truncate (struct node *np, pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); - obj = diskfs_get_filemap (np); + obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); poke_pages (obj, round_page (length), round_page (np->allocsize)); mach_port_deallocate (mach_task_self (), obj); pager_flush_some (upi->p, round_page (length), @@ -588,7 +588,7 @@ diskfs_grow (struct node *np, { mach_port_t obj; - obj = diskfs_get_filemap (np); + obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); poke_pages (obj, trunc_page (poke_off), round_page (poke_off + poke_len)); mach_port_deallocate (mach_task_self (), obj); -- cgit v1.2.3 From 896c358bc0391572de2a635d9c2ddd91d4a90671 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:28:46 +0000 Subject: (diskfs_readonly_changed): New function. (get_hypermetadata): Move compat_mode futzing & disk size validation here from main. Only allocate SBLOCK if not already done. Deallocate any old ZEROBLOCK and CSUM storage. (zeroblock, sblock, csum): Define (were common). (diskfs_readonly_changed): New function. --- ufs/hyper.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 0aab1819..d8064a29 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -21,10 +21,22 @@ static int oldformat = 0; +vm_address_t zeroblock = 0; + +struct fs *sblock = 0; +struct csum *csum = 0; + void get_hypermetadata (void) { - sblock = malloc (SBSIZE); + if (!sblock) + sblock = malloc (SBSIZE); + + /* Free previous values. */ + if (zeroblock) + vm_deallocate (mach_task_self (), zeroblock, sblock->fs_bsize); + if (csum) + free (csum); assert (!diskfs_catch_exception ()); bcopy (disk_image + SBOFF, sblock, SBSIZE); @@ -95,7 +107,7 @@ get_hypermetadata (void) else direct_symlink_extension = 0; - csum = malloc (fsaddr (sblock, howmany (sblock->fs_cssize, + csum = malloc (fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); assert (!diskfs_catch_exception ()); @@ -103,6 +115,27 @@ get_hypermetadata (void) csum, fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); diskfs_end_catch_exception (); + + if ((diskfs_device_size << diskfs_log2_device_block_size) + < sblock->fs_size * sblock->fs_fsize) + { + fprintf (stderr, + "Disk size (%ld) less than necessary " + "(superblock says we need %ld)\n", + diskfs_device_size << diskfs_log2_device_block_size, + sblock->fs_size * sblock->fs_fsize); + exit (1); + } + + vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); + + /* If the filesystem has new features in it, don't pay attention to + the user's request not to use them. */ + if ((sblock->fs_inodefmt == FS_44INODEFMT + || direct_symlink_extension) + && compat_mode == COMPAT_BSD42) + /* XXX should syslog to this effect */ + compat_mode = COMPAT_BSD44; } /* Write the csum data. This isn't backed by a pager because it is @@ -192,4 +225,20 @@ copy_sblock () diskfs_end_catch_exception (); } +void diskfs_readonly_changed (int readonly) +{ + vm_protect (mach_task_self (), + (vm_address_t)disk_image, + diskfs_device_size << diskfs_log2_device_block_size, + 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE)); + if (readonly) + sblock_dirty = 0; + else + { + sblock->fs_clean = 0; + strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ + sblock_dirty = 1; + diskfs_set_hypermetadata (1, 0); + } +} -- cgit v1.2.3 From e167a21a91011a3612558160d85ce53931b47ba5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:30:59 +0000 Subject: (diskfs_get_filemap): Add PROT parameter, & use it. (diskfs_pager_users): Split out block_caching & enable_caching. (block_caching, enable_caching, diskfs_max_user_pager_prot): New functions. (flush_node_pager): New function. --- ufs/pager.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 27 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 3456d404..10ce2a10 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -437,10 +437,40 @@ diskfs_file_update (struct node *np, diskfs_node_update (np, wait); } +/* Invalidate any pager data associated with NODE. */ +void +flush_node_pager (struct node *node) +{ + struct user_pager_info *upi; + struct disknode *dn = node->dn; + struct dirty_indir *dirty = dn->dirty; + + spin_lock (&node2pagelock); + upi = dn->fileinfo; + if (upi) + ports_port_ref (upi->p); + spin_unlock (&node2pagelock); + + if (upi) + { + pager_flush (upi->p, 1); + ports_port_deref (upi->p); + } + + dn->dirty = 0; + + while (dirty) + { + struct dirty_indir *next = dirty->next; + free (dirty); + dirty = next; + } +} + /* Call this to create a FILE_DATA pager and return a send right. - NP must be locked. */ + NP must be locked. PROT is the max protection desired. */ mach_port_t -diskfs_get_filemap (struct node *np) +diskfs_get_filemap (struct node *np, vm_prot_t prot) { struct user_pager_info *upi; mach_port_t right; @@ -458,6 +488,7 @@ diskfs_get_filemap (struct node *np) upi = malloc (sizeof (struct user_pager_info)); upi->type = FILE_DATA; upi->np = np; + upi->max_prot = prot; diskfs_nref_light (np); upi->p = pager_create (upi, pager_bucket, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); @@ -467,6 +498,8 @@ diskfs_get_filemap (struct node *np) } else { + np->dn->fileinfo->max_prot |= prot; + /* Because NP->dn->fileinfo->p is not a real reference, this might be nearly deallocated. If that's so, then the port right will be null. In that case, clear here @@ -523,13 +556,9 @@ allow_pager_softrefs (struct node *np) ports_port_deref (upi->p); } -/* Tell diskfs if there are pagers exported, and if none, then - prevent any new ones from showing up. */ -int -diskfs_pager_users () +static void +block_caching () { - int npagers; - error_t block_cache (void *arg) { struct pager *p = arg; @@ -538,6 +567,14 @@ diskfs_pager_users () return 0; } + /* Loop through the pagers and turn off caching one by one, + synchronously. That should cause termination of each pager. */ + ports_bucket_iterate (pager_bucket, block_cache); +} + +static void +enable_caching () +{ error_t enable_cache (void *arg) { struct pager *p = arg; @@ -560,34 +597,78 @@ diskfs_pager_users () return 0; } - npagers = ports_count_bucket (pager_bucket); + ports_bucket_iterate (pager_bucket, enable_cache); +} + +/* Tell diskfs if there are pagers exported, and if none, then + prevent any new ones from showing up. */ +int +diskfs_pager_users () +{ + int npagers = ports_count_bucket (pager_bucket); + if (npagers <= 1) return 0; - if (MAY_CACHE == 0) + if (MAY_CACHE) { - ports_enable_bucket (pager_bucket); - return 1; - } - - /* Loop through the pagers and turn off caching one by one, - synchronously. That should cause termination of each pager. */ - ports_bucket_iterate (pager_bucket, block_cache); + block_caching (); - /* Give it a second; the kernel doesn't actually shutdown - immediately. XXX */ - sleep (1); + /* Give it a second; the kernel doesn't actually shutdown + immediately. XXX */ + sleep (1); - npagers = ports_count_bucket (pager_bucket); - if (npagers <= 1) - return 0; + npagers = ports_count_bucket (pager_bucket); + if (npagers <= 1) + return 0; + + /* Darn, there are actual honest users. Turn caching back on, + and return failure. */ + enable_caching (); + } - /* Darn, there are actual honest users. Turn caching back on, - and return failure. */ - ports_bucket_iterate (pager_bucket, enable_cache); + ports_enable_bucket (pager_bucket); + return 1; } +/* Return the bitwise or of the maximum prot parameter (the second arg to + diskfs_get_filemap) for all active user pagers. */ +vm_prot_t +diskfs_max_user_pager_prot () +{ + vm_prot_t max_prot = 0; + int npagers = ports_count_bucket (pager_bucket); + + if (npagers > 1) + /* More than just the disk pager. */ + { + error_t add_pager_max_prot (void *v_p) + { + struct pager *p = v_p; + struct user_pager_info *upi = pager_get_upi (p); + if (upi->type == FILE_DATA) + max_prot |= upi->max_prot; + /* Stop iterating if MAX_PROT is as filled as it's going to get. */ + return + (max_prot == (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)) ? 1 : 0; + } + + block_caching (); /* Make any silly pagers go away. */ + + /* Give it a second; the kernel doesn't actually shutdown + immediately. XXX */ + sleep (1); + + ports_bucket_iterate (pager_bucket, add_pager_max_prot); + + enable_caching (); + } + + ports_enable_bucket (pager_bucket); + + return 1; +} /* Call this to find out the struct pager * corresponding to the FILE_DATA pager of inode IP. This should be used *only* as a subsequent @@ -638,4 +719,3 @@ diskfs_sync_everything (int wait) ports_bucket_iterate (pager_bucket, sync_one); sync_disk (wait); } - -- cgit v1.2.3 From 0794f9e13cd2cf1bfc87c81006c9c275bd337f5d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:46:01 +0000 Subject: (struct user_pager_info): Add max_prot field. (struct rwlock): Structure deleted. (rwlock_init, rwlock_reader_unlock, rwlock_reader_lock, rwlock_writer_lock, rwlock_writer_unlock): Functions deleted. (zeroblock, sblock, csum): Declare extern. (flush_node_pager, flush_pokes): New declarations. --- ufs/ufs.h | 88 +++++---------------------------------------------------------- 1 file changed, 6 insertions(+), 82 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index d0000e34..8771c372 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -32,16 +32,6 @@ /* #undef DONT_CACHE_MEMORY_OBJECTS */ -/* Simple reader/writer lock. */ -struct rwlock -{ - struct mutex master; - struct condition wakeup; - int readers; - int writers_waiting; - int readers_waiting; -}; - struct disknode { ino_t number; @@ -60,23 +50,6 @@ struct disknode struct user_pager_info *fileinfo; }; -/* Get a reader lock on reader-writer lock LOCK for disknode DN */ -extern inline void -rwlock_reader_lock (struct rwlock *lock) -{ - mutex_lock (&lock->master); - if (lock->readers == -1 || lock->writers_waiting) - { - lock->readers_waiting++; - do - condition_wait (&lock->wakeup, &lock->master); - while (lock->readers == -1 || lock->writers_waiting); - lock->readers_waiting--; - } - lock->readers++; - mutex_unlock (&lock->master); -} - /* Identifies a particular block and where it's found when interpreting indirect block structure. */ struct iblock_spec @@ -96,58 +69,6 @@ struct dirty_indir struct dirty_indir *next; }; -/* Get a writer lock on reader-writer lock LOCK for disknode DN */ -extern inline void -rwlock_writer_lock (struct rwlock *lock) -{ - mutex_lock (&lock->master); - if (lock->readers) - { - lock->writers_waiting++; - do - condition_wait (&lock->wakeup, &lock->master); - while (lock->readers); - lock->writers_waiting--; - } - lock->readers = -1; - mutex_unlock (&lock->master); -} - -/* Release a reader lock on reader-writer lock LOCK for disknode DN */ -extern inline void -rwlock_reader_unlock (struct rwlock *lock) -{ - mutex_lock (&lock->master); - assert (lock->readers); - lock->readers--; - if (lock->readers_waiting || lock->writers_waiting) - condition_broadcast (&lock->wakeup); - mutex_unlock (&lock->master); -} - -/* Release a writer lock on reader-writer lock LOCK for disknode DN */ -extern inline void -rwlock_writer_unlock (struct rwlock *lock) -{ - mutex_lock (&lock->master); - assert (lock->readers == -1); - lock->readers = 0; - if (lock->readers_waiting || lock->writers_waiting) - condition_broadcast (&lock->wakeup); - mutex_unlock (&lock->master); -} - -/* Initialize reader-writer lock LOCK */ -extern inline void -rwlock_init (struct rwlock *lock) -{ - mutex_init (&lock->master); - condition_init (&lock->wakeup); - lock->readers = 0; - lock->readers_waiting = 0; - lock->writers_waiting = 0; -} - struct user_pager_info { struct node *np; @@ -157,15 +78,16 @@ struct user_pager_info FILE_DATA, } type; struct pager *p; + vm_prot_t max_prot; }; struct user_pager_info *diskpager; mach_port_t diskpagerport; -vm_address_t zeroblock; +extern vm_address_t zeroblock; -struct fs *sblock; -struct csum *csum; +extern struct fs *sblock; +extern struct csum *csum; int sblock_dirty; int csum_dirty; @@ -278,6 +200,7 @@ void sin_unmap (struct node *); void din_unmap (struct node *); void drop_pager_softrefs (struct node *); void allow_pager_softrefs (struct node *); +void flush_node_pager (struct node *); /* From subr.c: */ void ffs_fragacct (struct fs *, int, long [], int); @@ -290,3 +213,4 @@ int scanc (u_int, u_char *, u_char [], int); /* From pokeloc.c: */ void record_poke (void *, vm_size_t); void sync_disk (int); +void flush_pokes (); -- cgit v1.2.3 From b614f2c8bb637f0e12a1786b8bb15248be441626 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:47:24 +0000 Subject: (main): Always include VM_PROT_WRITE in max prot. Move stuff into get_hypermetadata. Writable init code moved to diskfs_readonly_changed. (diskfs_reload_global_state): New function. --- ufs/main.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index f360220b..5a447f94 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -108,39 +108,12 @@ main (int argc, char **argv) err = vm_map (mach_task_self (), (vm_address_t *)&disk_image, disk_size, 0, 1, diskpagerport, 0, 0, VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), - VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), + VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_NONE); assert (!err); get_hypermetadata (); - if (disk_size < sblock->fs_size * sblock->fs_fsize) - { - fprintf (stderr, - "Disk size (%ld) less than necessary " - "(superblock says we need %ld)\n", - disk_size, sblock->fs_size * sblock->fs_fsize); - exit (1); - } - - vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); - - /* If the filesystem has new features in it, don't pay attention to - the user's request not to use them. */ - if ((sblock->fs_inodefmt == FS_44INODEFMT - || direct_symlink_extension) - && compat_mode == COMPAT_BSD42) - /* XXX should syslog to this effect */ - compat_mode = COMPAT_BSD44; - - if (!diskfs_readonly) - { - sblock->fs_clean = 0; - strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ - sblock_dirty = 1; - diskfs_set_hypermetadata (1, 0); - } - inode_init (); /* Find our root node. */ @@ -156,3 +129,12 @@ main (int argc, char **argv) return 0; } + +error_t +diskfs_reload_global_state () +{ + flush_pokes (); + pager_flush (diskpager->p, 1); + get_hypermetadata (); + return 0; +} -- cgit v1.2.3 From d77d7cbde90553aa4178cba7e1591e0e6d4818c5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:49:33 +0000 Subject: (diskfs_node_reload): New function. (iget): Move allocsize setting into read_disknode. --- ufs/inode.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index b15c9848..179a85bc 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -83,11 +83,6 @@ iget (ino_t inum, struct node **npp) spin_unlock (&diskfs_node_refcnt_lock); err = read_disknode (np); - - if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) - np->allocsize = fragroundup (sblock, np->dn_stat.st_size); - else - np->allocsize = blkroundup (sblock, np->dn_stat.st_size); if (!diskfs_readonly && !np->dn_stat.st_gen) { @@ -271,6 +266,24 @@ read_disknode (struct node *np) diskfs_end_catch_exception (); if (!S_ISBLK (st->st_mode) && !S_ISCHR (st->st_mode)) st->st_rdev = 0; + + if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) + np->allocsize = fragroundup (sblock, np->dn_stat.st_size); + else + np->allocsize = blkroundup (sblock, np->dn_stat.st_size); + + return 0; +} + +error_t diskfs_node_reload (struct node *node) +{ + if (node->dn->dirents) + { + free (node->dn->dirents); + node->dn->dirents = 0; + } + flush_node_pager (node); + read_disknode (node); return 0; } -- cgit v1.2.3 From 200ab835f25a0e4c5612d30fdf113e0fc62e841a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 20:53:28 +0000 Subject: (flush_pokes): New function. --- ufs/pokeloc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c index 0e7235ad..e137090f 100644 --- a/ufs/pokeloc.c +++ b/ufs/pokeloc.c @@ -47,6 +47,25 @@ record_poke (void *loc, vm_size_t length) spin_unlock (&pokelistlock); } +/* Get rid of any outstanding pokes. */ +void +flush_pokes () +{ + struct pokeloc *pl; + + spin_lock (&pokelistlock); + pl = pokelist; + pokelist = 0; + spin_unlock (&pokelistlock); + + while (pl) + { + struct pokeloc *next = pl->next; + free (pl); + pl = next; + } +} + /* Sync all the modified pieces of disk */ void sync_disk (int wait) -- cgit v1.2.3 From 03cba24ed5b3ed2b6177117711c55bdbffd764ef Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 22:20:29 +0000 Subject: ($(target)): Depend on libshouldbeinlibc.a. --- ufs-fsck/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index e5c83b64..0b05bcbf 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -30,5 +30,6 @@ installationdir = $(sbindir) vpath tables.c ../ufs -include ../Makeconf +$(target): ../libshouldbeinlibc/libshouldbeinlibc.a +include ../Makeconf -- cgit v1.2.3 From f8b56b162e761621ca88e003c5a753a59bbcc8d4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Oct 1995 22:21:23 +0000 Subject: (main): Exit with a non-zero status if we fixed anything. Use argp to parse options. (options): Converted to argp format. (args_doc): New variable. (USAGE, usage, SHORT_OPTIONS): Removed. Include instead of . --- ufs-fsck/main.c | 98 +++++++++++++++++++++++---------------------------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 5fbabc76..a2d4855c 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -19,77 +19,56 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include -#include +#include #include "fsck.h" char *lfname = "lost+found"; mode_t lfmode = 0755; - -#define USAGE "Usage: %s [OPTION...] DEVICE\n" -static void -usage(int status) +static struct argp_option options[] = { - if (status != 0) - fprintf(stderr, "Try `%s --help' for more information.\n", - program_invocation_name); - else - { - printf(USAGE, program_invocation_name); - printf("\ -\n\ - -p, --preen Terse automatic mode\n\ - -y, --yes Automatically answer yes to all questions\n\ - -n, --no Automatically answer no to all questions\n\ - -l, --lost+found=NAME The name of the lost+found directory in /\n\ - -m, --lf-mode=MODE The name of the lost+found directory in /\n\ - --help Give this usage message\n\ -"); - } - - exit(status); -} - -#define SHORT_OPTIONS "pynlm&" - -static struct option options[] = -{ - {"preen", no_argument, 0, 'p'}, - {"yes", no_argument, 0, 'y'}, - {"no", no_argument, 0, 'n'}, - {"lost+found", required_argument, 0, 'l'}, - {"lf-mode", required_argument, 0, 'm'}, - {"help", no_argument, 0, '&'}, - {0, 0, 0, 0} + {"preen", 'p', 0, 0, "Terse automatic mode"}, + {"yes", 'y', 0, 0, "Automatically answer yes to all questions"}, + {"no", 'n', 0, 0, "Automatically answer no to all questions"}, + {"lost+found", 'l', "NAME", 0, "The name of the lost+found directory in /"}, + {"lf-mode", 'm', "MODE", 0, "The mode of the lost+found directory in /"}, + {0, 0} }; - +char *args_doc = "DEVICE"; + int main (int argc, char **argv) { - int opt; - - preen = nowrite = noquery = 0; - - while ((opt = getopt_long (argc, argv, SHORT_OPTIONS, options, 0)) != EOF) - switch (opt) - { - case 'p': preen = 1; break; - case 'y': noquery = 1; break; - case 'n': nowrite = 1; break; - case 'l': lfname = optarg; break; - case 'm': lfmode = strtol (optarg, 0, 8); break; - case '&': usage(0); - default: usage(1); - } - - if (argv[optind] == 0 || argv[optind + 1] != 0) + char *device = 0; + error_t parse_opt (int key, char *arg, struct argp_state *state) { - fprintf(stderr, USAGE, program_invocation_name); - usage (1); + switch (key) + { + case 'p': preen = 1; break; + case 'y': noquery = 1; break; + case 'n': nowrite = 1; break; + case 'l': lfname = arg; break; + case 'm': lfmode = strtol (arg, 0, 8); break; + case ARGP_KEY_ARG: + if (!device) + { + device = arg; + break; + } + /* Fall through */ + case ARGP_KEY_NO_ARGS: + argp_help (state->argp, stderr, ARGP_HELP_STD_USAGE); /* exits */ + default: return EINVAL; + } + return 0; } + struct argp argp = {options, parse_opt, args_doc}; - if (!setup (argv[optind])) + preen = nowrite = noquery = 0; + argp_parse (&argp, argc, argv, 0, 0); + + if (!setup (device)) exit (1); if (!preen) @@ -121,5 +100,6 @@ main (int argc, char **argv) if (fsmodified) printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n"); - return 0; -} + + exit (fsmodified ? 2 : 0); +} -- cgit v1.2.3 From bc0d016208fdadf1efbd42c23015388df2718d15 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 21 Oct 1995 00:18:53 +0000 Subject: (diskfs_max_user_pager_prot): Return what we discovered, instead of 1. --- ufs/pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index 10ce2a10..87217908 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -667,7 +667,7 @@ diskfs_max_user_pager_prot () ports_enable_bucket (pager_bucket); - return 1; + return max_prot; } /* Call this to find out the struct pager * corresponding to the -- cgit v1.2.3 From 56672c06056088303b4c5bb14a560df007b2d25a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 6 Nov 1995 21:09:16 +0000 Subject: (trivfs_S_file_get_storage_info): Add FLAGS argument. --- devio/io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devio/io.c b/devio/io.c index d244524b..7bdfaa71 100644 --- a/devio/io.c +++ b/devio/io.c @@ -319,7 +319,8 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, size_t *block_size, char *dev_name, mach_port_t *dev_port, mach_msg_type_name_t *dev_port_type, - char **misc, unsigned *misc_len) + char **misc, unsigned *misc_len, + int *flags) { error_t err; if (!cred) @@ -333,6 +334,7 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, if (!err) { *class = STORAGE_DEVICE; + *flags = 0; (*runs)[0] = 0; (*runs)[1] = dev->size / dev->dev_block_size; -- cgit v1.2.3 From c3dea1b90345dbc206b1d4d290c0cbbe902deced Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 6 Nov 1995 21:12:07 +0000 Subject: (main): Add FLAGS arg to trivfs_startup call. --- devio/devio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devio/devio.c b/devio/devio.c index 3427cbe6..11b41f70 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -155,7 +155,7 @@ void main(int argc, char *argv[]) /* Reply to our parent */ err = - trivfs_startup(bootstrap, + trivfs_startup(bootstrap, 0, fsys_port_class, port_bucket, root_port_class, port_bucket, NULL); -- cgit v1.2.3 From b61796c023e118c77fc9e2c618d5610376095cf7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 6 Nov 1995 21:14:46 +0000 Subject: (main): Add FLAGS arg to diskfs_startup_diskfs call. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 5a447f94..bb002208 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -122,7 +122,7 @@ main (int argc, char **argv) /* 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 outside world. */ - diskfs_startup_diskfs (bootstrap); + diskfs_startup_diskfs (bootstrap, 0); /* And this thread is done with its work. */ cthread_exit (0); -- cgit v1.2.3 From b97f588ea5284d2a126d38953a4e373db1312772 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 6 Nov 1995 21:15:08 +0000 Subject: (diskfs_S_file_get_storage_info): Add FLAGS argument. --- ufs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 179a85bc..08438e70 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -614,7 +614,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, mach_port_t *storage_port, mach_msg_type_name_t *storage_port_type, char **storage_data, - u_int *storage_data_len) + u_int *storage_data_len, + int *flags) { error_t err; struct node *np; @@ -691,6 +692,7 @@ diskfs_S_file_get_storage_info (struct protid *cred, diskfs_end_catch_exception (); *class = STORAGE_DEVICE; + *flags = 0; *block_size = DEV_BSIZE; if (diskfs_device_name) -- cgit v1.2.3 From 0a9502bf66dcdc1156616c06646021ceba69f383 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 8 Nov 1995 21:46:47 +0000 Subject: (trivfs_S_file_set_size): Renamed from trivfs_S_file_truncate. --- devio/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devio/io.c b/devio/io.c index 7bdfaa71..840daaeb 100644 --- a/devio/io.c +++ b/devio/io.c @@ -184,7 +184,7 @@ trivfs_S_io_write (struct trivfs_protid *cred, /* Truncate file. */ kern_return_t -trivfs_S_file_truncate (struct trivfs_protid *cred, off_t size) +trivfs_S_file_set_size (struct trivfs_protid *cred, off_t size) { if (!cred) return EOPNOTSUPP; -- cgit v1.2.3 From 4c972b4fb48bdb7e8177bd56b6e4b412c01ebb73 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 Nov 1995 19:19:06 +0000 Subject: (struct dirstat): New member `nbytes'. (dirscanblock): If DS->type is COMPRESS, still look for TAKE/SHRINK possibilities. Also, if it's COMPRESS, still look to see if the current block can be compressed with fewer byte copies. --- ufs/dir.c | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index f8150d64..5906cb01 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -73,6 +73,10 @@ struct dirstat /* For stat HERE_TIS, type REMOVE, this is the address of the immediately previous direct in this directory block, or zero if this is the first. */ struct directory_entry *preventry; + + /* For stat COMPRESS, this is the number of bytes needed to be copied + in order to undertake the compression. */ + size_t nbytes; }; size_t diskfs_dirstat_size = sizeof (struct dirstat); @@ -311,17 +315,22 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, { int nfree = 0; int needed = 0; - int countup = 0; vm_address_t currentoff, prevoff; - struct directory_entry *entry; + struct directory_entry *entry = 0; int nentries = 0; - - if (ds && ds->stat == LOOKING) + size_t nbytes = 0; + int looking = 0; + int countcopies = 0; + int consider_compress = 0; + + if (ds && (ds->stat == LOOKING + || ds->stat == COMPRESS)) { - countup = 1; + looking = 1; + countcopies = 1; needed = DIRSIZ (namelen); } - + for (currentoff = blockaddr, prevoff = 0; currentoff < blockaddr + DIRBLKSIZ; prevoff = currentoff, currentoff += entry->d_reclen) @@ -341,35 +350,41 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, return ENOENT; } - if (countup) + if (looking || countcopies) { int thisfree; + /* Count how much free space this entry has in it. */ if (entry->d_ino == 0) thisfree = entry->d_reclen; else thisfree = entry->d_reclen - DIRSIZ (DIRECT_NAMLEN (entry)); + + /* If this isn't at the front of the block, then it will + have to be copied if we do a compression; count the + number of bytes there too. */ + if (countcopies && currentoff != blockaddr) + nbytes += DIRSIZ (DIRECT_NAMLEN (entry)); + if (ds->stat == COMPRESS && nbytes > ds->nbytes) + /* The previously found compress is better than + this one, so don't bother counting any more. */ + countcopies = 0; + if (thisfree >= needed) { ds->type = CREATE; ds->stat = entry->d_ino == 0 ? TAKE : SHRINK; ds->entry = entry; ds->idx = idx; - countup = 0; + looking = countcopies = 0; } else { nfree += thisfree; if (nfree >= needed) - { - ds->type = CREATE; - ds->stat = COMPRESS; - ds->entry = (struct directory_entry *) blockaddr; - ds->idx = idx; - countup = 0; - } - } + consider_compress = 1; + } } if (entry->d_ino) @@ -382,6 +397,17 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, break; } + if (consider_compress + && (ds->type == LOOKING + || (ds->type == COMPRESS && ds->nbytes > nbytes))) + { + ds->type = CREATE; + ds->stat = COMPRESS; + ds->entry = (struct directory_entry *) blockaddr; + ds->idx = idx; + ds->nbytes = nbytes; + } + if (currentoff >= blockaddr + DIRBLKSIZ) { int i; -- cgit v1.2.3 From 66ac141f9ee471ac01a9454faaee58824f4db9de Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 4 Dec 1995 22:01:16 +0000 Subject: (trivfs_S_file_set_size, trivfs_S_file_sync, trivfs_S_file_syncfs, trivfs_S_file_get_storage_info): Add totally gratuitous, annoying, and trouble-making reply-port args. (trivfs_S_file_get_storage_info): Use inline return if possible. --- devio/io.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/devio/io.c b/devio/io.c index 840daaeb..7d8dec41 100644 --- a/devio/io.c +++ b/devio/io.c @@ -184,7 +184,9 @@ trivfs_S_io_write (struct trivfs_protid *cred, /* Truncate file. */ kern_return_t -trivfs_S_file_set_size (struct trivfs_protid *cred, off_t size) +trivfs_S_file_set_size (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + off_t size) { if (!cred) return EOPNOTSUPP; @@ -294,7 +296,9 @@ trivfs_S_io_mod_owner (struct trivfs_protid *cred, device. */ kern_return_t -trivfs_S_file_sync (struct trivfs_protid *cred, int wait) +trivfs_S_file_sync (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int wait) { if (cred) return dev_sync (((struct open *)cred->po->hook)->dev, wait); @@ -303,7 +307,9 @@ trivfs_S_file_sync (struct trivfs_protid *cred, int wait) } kern_return_t -trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) +trivfs_S_file_syncfs (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int wait, int dochildren) { if (!cred) return dev_sync (((struct open *)cred->po->hook)->dev, wait); @@ -314,7 +320,10 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, int wait, int dochildren) /* ---------------------------------------------------------------- */ error_t -trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, +trivfs_S_file_get_storage_info (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + int *class, off_t **runs, unsigned *runs_len, size_t *block_size, char *dev_name, mach_port_t *dev_port, @@ -322,15 +331,22 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, char **misc, unsigned *misc_len, int *flags) { - error_t err; + error_t err = 0; + if (!cred) err = EOPNOTSUPP; else { struct dev *dev = ((struct open *)cred->po->hook)->dev; - err = vm_allocate (mach_task_self (), - (vm_address_t *)runs, 2 * sizeof (off_t), 1); + if (*runs_len < 2 * sizeof (off_t)) + { + *runs_len = 2 * sizeof (off_t); + err = + vm_allocate (mach_task_self (), + (vm_address_t *)runs, *runs_len, 1); + } + if (!err) { *class = STORAGE_DEVICE; @@ -353,5 +369,6 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, int *class, *misc_len = 0; } } + return err; } -- cgit v1.2.3 From 748c574a54af4bbc87e548b6f6bb8cfddccb6ccf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Dec 1995 18:14:33 +0000 Subject: (diskfs_lookup): If we are returning an error, then set the dirstat to be ignored by drop_dirstat. --- ufs/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index 5906cb01..b2147007 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -269,7 +269,11 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type, if ((err && err != ENOENT) || !ds || ds->type == LOOKUP) - vm_deallocate (mach_task_self (), buf, buflen); + { + vm_deallocate (mach_task_self (), buf, buflen); + if (ds) + ds->type = LOOKUP; /* set to be ignored by drop_dirstat */ + } else { ds->mapbuf = buf; -- cgit v1.2.3 From 6fbd84e4a1c38eb56e250e0b0f0cfc4845b06715 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 15 Dec 1995 18:35:44 +0000 Subject: (ST): Variable holding the proper settrans command, which use. (_CWD): Use this variable to pass down the current directory to sub MAKEDEVS. (console): Use the new term syntax. (tty[0-9]?|tty[0-9a-f]): New rule for normal ttys. ([pt]ty[pqPQ]?): New rule for ptys (both master and slave). ([pt]ty[pqPQ]): New rule for making sets of ptys. --- devio/MAKEDEV | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 8cb630cc..ad228edc 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -5,36 +5,52 @@ PATH=/bin +ST="settrans -cg" + +_CWD=${_CWD:-`pwd`} +export _CWD + for I; do case "$I" in std) $0 console tty null zero # fd ;; - console) - settrans -cf console /hurd/term console `pwd`/console ;; - tty) - settrans -cf tty /hurd/magic tty ;; + console|tty[0-9]?|tty[0-9a-f]) + $ST $I /hurd/term $_CWD/$I device $I;; null) - settrans -cf null /hurd/null ;; + $ST $I /hurd/null ;; zero) - settrans -cf zero /hurd/null -z ;; + $ST $I /hurd/null -z ;; fd) - settrans -cf fd /hurd/magic fd + $ST $I /hurd/magic fd ln -f -s fd/0 stdin ln -f -s fd/1 stdout ln -f -s fd/2 stderr ;; + # ptys + [pt]ty[pqPQ]?) + # Make one pty, both the master and slave halves + ID="`expr substr $I 4 99`" + $ST pty$ID /hurd/term $_CWD/pty$ID pty-master $_CWD/tty$ID + $ST tty$ID /hurd/term $_CWD/tty$ID pty-slave $_CWD/pty$ID + ;; + [pt]ty[pqPQ]) + # Make a bunch of ptys + $0 ${I}0 ${I}1 ${I}2 ${I}3 ${I}4 ${I}5 ${I}6 ${I}7 + $0 ${I}8 ${I}9 ${I}a ${I}b ${I}c ${I}d ${I}e ${I}f + ;; + fd*|mt*) - settrans -cf r$I /hurd/devio $I - settrans -cf $I /hurd/devio -b $I + $ST r$I /hurd/devio $I + $ST $I /hurd/devio -b $I ;; [hrs]d*) case "$I" in [a-z][a-z][0-9][a-z]) - settrans -cf r$I /hurd/devio $I - settrans -cf $I /hurd/devio -b $I + $ST r$I /hurd/devio $I + $ST $I /hurd/devio -b $I ;; *) echo 1>&2 $0: $I: Must supply a device number and partition -- cgit v1.2.3 From d0f17bee98ce10720e3a3bef5c81d69a07765d3a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 30 Dec 1995 04:46:54 +0000 Subject: (std): Make `fd' one of the standard devices. --- devio/MAKEDEV | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index ad228edc..4adbf331 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -13,7 +13,7 @@ export _CWD for I; do case "$I" in std) - $0 console tty null zero # fd + $0 console tty null zero fd ;; console|tty[0-9]?|tty[0-9a-f]) $ST $I /hurd/term $_CWD/$I device $I;; -- cgit v1.2.3 From 8854b41ec40b311f04cf2711e50302c5c0340207 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 1 Jan 1996 21:38:04 +0000 Subject: (pager_unlock_page): When allocating block in direct array, clear it synchronously just like we do when it goes in the indirect array. --- ufs/pager.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/pager.c b/ufs/pager.c index 87217908..26f5f322 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -1,5 +1,5 @@ /* Pager for ufs - Copyright (C) 1994, 1995 Free Software Foundation + Copyright (C) 1994, 1995, 1996 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 @@ -244,6 +244,8 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; assert (lblkno (sblock, address) < NDADDR); + diskfs_device_write_sync (fsbtodb (sblock, bno), + zeroblock, sblock->fs_bsize); indirs[0].bno = di->di_db[lblkno (sblock, address)] = bno; record_poke (di, sizeof (struct dinode)); } -- cgit v1.2.3 From da8b4a25a4634e497d0d7758a55f2a8818ccc469 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 5 Jan 1996 00:10:02 +0000 Subject: (main): Don't map disk image here; create_disk_pager now does it. --- ufs/main.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index bb002208..59e56df4 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1995 Free Software Foundation +/* + Copyright (C) 1994, 1995, 1996 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 @@ -81,7 +81,7 @@ main (int argc, char **argv) if (bootstrap == MACH_PORT_NULL) error (2, 0, "Must be started as a translator"); } - + /* Initialize the diskfs library. Must come before any other diskfs call. */ diskfs_init_diskfs (); @@ -105,13 +105,6 @@ main (int argc, char **argv) /* Start the first request thread, to handle RPCs and page requests. */ diskfs_spawn_first_thread (); - err = vm_map (mach_task_self (), (vm_address_t *)&disk_image, - disk_size, 0, 1, diskpagerport, 0, 0, - VM_PROT_READ | (diskfs_readonly ? 0 : VM_PROT_WRITE), - VM_PROT_READ | VM_PROT_WRITE, - VM_INHERIT_NONE); - assert (!err); - get_hypermetadata (); inode_init (); @@ -123,14 +116,14 @@ main (int argc, char **argv) set properly, it is safe to export our fsys control port to the outside world. */ diskfs_startup_diskfs (bootstrap, 0); - + /* And this thread is done with its work. */ cthread_exit (0); return 0; } -error_t +error_t diskfs_reload_global_state () { flush_pokes (); -- cgit v1.2.3 From 1426f83a3331dc74ac9b9b5e29c78d88186adb04 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 5 Jan 1996 00:24:25 +0000 Subject: (get_hypermetadata, copy_sblock): Don't put diskfs_catch_exception () inside assert, bonehead! Use assert_perror on a variable of its result. --- ufs/hyper.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index d8064a29..01c06b89 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -1,5 +1,5 @@ /* Fetching and storing the hypermetadata (superblock and cg summary info). - Copyright (C) 1994, 1995 Free Software Foundation + Copyright (C) 1994, 1995, 1996 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 @@ -29,6 +29,8 @@ struct csum *csum = 0; void get_hypermetadata (void) { + error_t err; + if (!sblock) sblock = malloc (SBSIZE); @@ -38,10 +40,11 @@ get_hypermetadata (void) if (csum) free (csum); - assert (!diskfs_catch_exception ()); + err = diskfs_catch_exception (); + assert_perror (err); bcopy (disk_image + SBOFF, sblock, SBSIZE); diskfs_end_catch_exception (); - + if (sblock->fs_magic != FS_MAGIC) { fprintf (stderr, "Bad magic number %#lx (should be %#x)\n", @@ -109,7 +112,7 @@ get_hypermetadata (void) csum = malloc (fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); - + assert (!diskfs_catch_exception ()); bcopy (disk_image + fsaddr (sblock, sblock->fs_csaddr), csum, @@ -119,7 +122,7 @@ get_hypermetadata (void) if ((diskfs_device_size << diskfs_log2_device_block_size) < sblock->fs_size * sblock->fs_fsize) { - fprintf (stderr, + fprintf (stderr, "Disk size (%ld) less than necessary " "(superblock says we need %ld)\n", diskfs_device_size << diskfs_log2_device_block_size, @@ -158,20 +161,20 @@ diskfs_set_hypermetadata (int wait, int clean) } /* Copy into a page-aligned buffer to avoid bugs in kernel device code. */ - + bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), &buf, bufsize); if (!err) - { + { bcopy (csum, (void *) buf, sblock->fs_cssize); diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize); csum_dirty = 0; vm_deallocate (mach_task_self (), buf, bufsize); } - + spin_unlock (&alloclock); } @@ -179,9 +182,12 @@ diskfs_set_hypermetadata (int wait, int clean) void copy_sblock () { + error_t err; + int clean = 1; /* XXX wrong... */ - - assert (!diskfs_catch_exception ()); + + err = diskfs_catch_exception (); + assert_perror (err); spin_lock (&alloclock); -- cgit v1.2.3 From 44d8dbf91974525971fa8a6e041a8d8de7142c72 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Jan 1996 16:50:10 +0000 Subject: (diskfs_reload_global_state): Use `disk_pager' in place of `diskpager->p'. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 59e56df4..b7dd13c5 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -127,7 +127,7 @@ error_t diskfs_reload_global_state () { flush_pokes (); - pager_flush (diskpager->p, 1); + pager_flush (disk_pager, 1); get_hypermetadata (); return 0; } -- cgit v1.2.3 From e8ece98bb0e5bbecece2456549a7a47842eb2c37 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Jan 1996 16:51:10 +0000 Subject: (indir_release): Use `disk_pager' in place of `diskpager->p'. --- ufs/sizes.c | 116 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 0dadac28..0ecc7d31 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -1,5 +1,5 @@ /* File growth and truncation - Copyright (C) 1993, 1994, 1995 Free Software Foundation + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation This file is part of the GNU Hurd. @@ -8,7 +8,7 @@ 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, +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. @@ -67,7 +67,7 @@ diskfs_truncate (struct node *np, np->dn_set_ctime = np->dn_set_mtime = 1; return 0; } - + /* If the file is not being trucated to a block boundary, the zero the partial bit in the new last block. */ offset = blkoff (sblock, length); @@ -75,11 +75,11 @@ diskfs_truncate (struct node *np, { int bsize; /* size of new last block */ int savesize = np->allocsize; - + np->allocsize = length; /* temporary */ bsize = blksize (sblock, np, lblkno (sblock, length)); np->allocsize = savesize; - diskfs_node_rdwr (np, (void *) zeroblock, length, + diskfs_node_rdwr (np, (void *) zeroblock, length, bsize - offset, 1, 0, 0); diskfs_file_update (np, 1); } @@ -94,11 +94,11 @@ diskfs_truncate (struct node *np, if (upi) ports_port_ref (upi->p); spin_unlock (&node2pagelock); - + if (upi) { mach_port_t obj; - + pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); @@ -123,7 +123,7 @@ diskfs_truncate (struct node *np, lbn = lblkno (sblock, length - 1); err = fetch_indir_spec (np, lbn, indirs); /* err XXX */ - + /* We don't support triple indirs */ assert (indirs[3].offset == -2); @@ -132,7 +132,7 @@ diskfs_truncate (struct node *np, /* BSD carefully finds out how far to clear; it's vastly simpler to just clear everything after the new last block. */ - + /* Free direct blocks */ if (indirs[0].offset < 0) { @@ -162,14 +162,14 @@ diskfs_truncate (struct node *np, record_poke (sindir, sblock->fs_bsize); } } - + /* Free single indirect blocks */ if (indirs[1].offset < 0) { /* ...mapped from the inode */ if (di->di_ib[INDIR_SINGLE] && indirs[1].offset == -2) { - blocksfreed += indir_release (np, di->di_ib[INDIR_SINGLE], + blocksfreed += indir_release (np, di->di_ib[INDIR_SINGLE], INDIR_SINGLE); di->di_ib[INDIR_SINGLE] = 0; } @@ -189,33 +189,33 @@ diskfs_truncate (struct node *np, record_poke (dindir, sblock->fs_bsize); } } - + /* Free double indirect block */ assert (indirs[2].offset < 0); /* which must be mapped from the inode */ if (indirs[2].offset == -2) { if (di->di_ib[INDIR_DOUBLE]) { - blocksfreed += indir_release (np, di->di_ib[INDIR_DOUBLE], + blocksfreed += indir_release (np, di->di_ib[INDIR_DOUBLE], INDIR_DOUBLE); di->di_ib[INDIR_DOUBLE] = 0; } } - - /* Finally, check to see if the new last direct block is + + /* Finally, check to see if the new last direct block is changing size; if so release any frags necessary. */ if (lbn >= 0 && lbn < NDADDR && di->di_db[lbn]) { long oldspace, newspace; daddr_t bn; - + bn = di->di_db[lbn]; oldspace = blksize (sblock, np, lbn); np->allocsize = fragroundup (sblock, length); newspace = blksize (sblock, np, lbn); - + assert (newspace); - + if (oldspace - newspace) { bn += numfrags (sblock, newspace); @@ -247,18 +247,18 @@ diskfs_truncate (struct node *np, { /* The strategy is to reduce LBN until we get one that's allocated; then reduce allocsize accordingly, then call diskfs_grow. */ - + do err = fetch_indir_spec (np, --lbn, indirs); /* err XXX */ while (indirs[0].bno == 0 && lbn >= 0); - + assert ((lbn + 1) * sblock->fs_bsize < np->allocsize); np->allocsize = (lbn + 1) * sblock->fs_bsize; diskfs_grow (np, length, 0); } - + diskfs_end_catch_exception (); /* Now we can permit delayed copies again. */ @@ -273,7 +273,7 @@ diskfs_truncate (struct node *np, MEMORY_OBJECT_COPY_DELAY, 0); ports_port_deref (upi->p); } - + return err; } @@ -287,9 +287,9 @@ indir_release (struct node *np, daddr_t bno, int level) daddr_t *addrs; int i; struct dirty_indir *d, *prev, *next; - + assert (bno); - + addrs = indir_block (bno); for (i = 0; i < NINDIR (sblock); i++) if (addrs[i]) @@ -302,7 +302,7 @@ indir_release (struct node *np, daddr_t bno, int level) else count += indir_release (np, addrs[i], level - 1); } - + /* Subtlety: this block is no longer necessary; the information the kernel has cached corresponding to ADDRS is now unimportant. Consider that if this block is allocated to a file, it will then @@ -311,9 +311,9 @@ indir_release (struct node *np, daddr_t bno, int level) the block from the kernel's memory, making sure we do it synchronously--and BEFORE we attach it to the free list with ffs_blkfree. */ - pager_flush_some (diskpager->p, fsaddr (sblock, bno), sblock->fs_bsize, 1); + pager_flush_some (disk_pager, fsaddr (sblock, bno), sblock->fs_bsize, 1); - /* We should also take this block off the inode's list of + /* We should also take this block off the inode's list of dirty indirect blocks if it's there. */ prev = 0; d = np->dn->dirty; @@ -346,7 +346,7 @@ indir_release (struct node *np, daddr_t bno, int level) -/* Implement the diskfs_grow callback; see for the +/* Implement the diskfs_grow callback; see for the interface description. */ error_t diskfs_grow (struct node *np, @@ -359,8 +359,8 @@ diskfs_grow (struct node *np, struct dinode *di = dino (np->dn->number); off_t poke_off = 0; size_t poke_len = 0; - - /* Zero an sblock->fs_bsize piece of disk starting at BNO, + + /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect blocks before setting the pointer to them to ensure that an indirect block absolutely never points to garbage. */ @@ -383,12 +383,12 @@ diskfs_grow (struct node *np, size = fragroundup (sblock, blkoff (sblock, end)); if (size == 0) size = sblock->fs_bsize; - + rwlock_writer_lock (&np->dn->allocptrlock); /* The old last block of the file. */ olbn = lblkno (sblock, np->allocsize - 1); - + /* This is the size of that block if it is in the NDADDR array. */ osize = fragroundup (sblock, blkoff (sblock, np->allocsize)); if (osize == 0) @@ -410,7 +410,7 @@ diskfs_grow (struct node *np, di->di_db[olbn] = bno; record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - + diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, sblock->fs_bsize - osize); @@ -427,7 +427,7 @@ diskfs_grow (struct node *np, if (lbn < NDADDR) { daddr_t bno, old_pbn = di->di_db[lbn]; - + if (old_pbn != 0) { /* The last block is already allocated. Therefore we @@ -435,24 +435,24 @@ diskfs_grow (struct node *np, what we're up to. */ assert (size > osize); assert (lbn == olbn); - - err = ffs_realloccg (np, lbn, + + err = ffs_realloccg (np, lbn, ffs_blkpref (np, lbn, lbn, di->di_db), osize, size, &bno, cred); if (err) goto out; - + di->di_db[lbn] = bno; - record_poke (di, sizeof (struct dinode)); + record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - + diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), zeroblock, size - osize); if (bno != old_pbn) { assert (!poke_len); - + /* Make sure the old contents get written out to the new address by poking the pages. */ poke_off = lbn * sblock->fs_bsize; @@ -462,12 +462,12 @@ diskfs_grow (struct node *np, else { /* Allocate a new last block. */ - err = ffs_alloc (np, lbn, + err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn, lbn, di->di_db), size, &bno, cred); if (err) goto out; - + di->di_db[lbn] = bno; record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; @@ -480,23 +480,23 @@ diskfs_grow (struct node *np, struct iblock_spec indirs[NIADDR + 1]; daddr_t *siblock; daddr_t bno; - + /* Count the number of levels of indirection. */ err = fetch_indir_spec (np, lbn, indirs); if (err) goto out; - + /* Make sure we didn't miss the NDADDR case above somehow. */ assert (indirs[0].offset != -1); - + /* See if we need a triple indirect block; fail if so. */ assert (indirs[1].offset == -1 || indirs[2].offset == -1); - + /* Check to see if this block is allocated. If it is that's an error. */ assert (indirs[0].bno == 0); - + /* We need to set SIBLOCK to the single indirect block array; see if the single indirect block is allocated. */ if (indirs[1].bno == 0) @@ -516,7 +516,7 @@ diskfs_grow (struct node *np, else { daddr_t *diblock; - + /* We need to set diblock to the double indirect block array; see if the double indirect block is allocated. */ if (indirs[2].bno == 0) @@ -525,7 +525,7 @@ diskfs_grow (struct node *np, supported. */ assert (indirs[2].offset == -1); err = ffs_alloc (np, lbn, - ffs_blkpref (np, lbn, + ffs_blkpref (np, lbn, INDIR_DOUBLE, di->di_ib), sblock->fs_bsize, &bno, 0); if (err) @@ -534,13 +534,13 @@ diskfs_grow (struct node *np, indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; record_poke (di, sizeof (struct dinode)); } - + diblock = indir_block (indirs[2].bno); mark_indir_dirty (np, indirs[2].bno); - + /* Now we can allocate the single indirect block */ - err = ffs_alloc (np, lbn, - ffs_blkpref (np, lbn, + err = ffs_alloc (np, lbn, + ffs_blkpref (np, lbn, indirs[1].offset, diblock), sblock->fs_bsize, &bno, 0); if (err) @@ -550,12 +550,12 @@ diskfs_grow (struct node *np, record_poke (diblock, sblock->fs_bsize); } } - + siblock = indir_block (indirs[1].bno); mark_indir_dirty (np, indirs[1].bno); /* Now we can allocate the data block. */ - err = ffs_alloc (np, lbn, + err = ffs_alloc (np, lbn, ffs_blkpref (np, lbn, indirs[0].offset, siblock), sblock->fs_bsize, &bno, 0); if (err) @@ -565,7 +565,7 @@ diskfs_grow (struct node *np, diskfs_device_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); } - + out: if (!err) { @@ -587,7 +587,7 @@ diskfs_grow (struct node *np, if (poke_len) { mach_port_t obj; - + obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); poke_pages (obj, trunc_page (poke_off), round_page (poke_off + poke_len)); @@ -607,7 +607,7 @@ poke_pages (memory_object_t obj, vm_address_t addr, poke; vm_size_t len; error_t err; - + while (start < end) { len = 8 * vm_page_size; -- cgit v1.2.3 From 0e2ced4de1118fed20b94191e6b294b81906930a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Jan 1996 16:52:06 +0000 Subject: (sync_disk): Use `disk_pager' in place of `diskpager->p'. --- ufs/pokeloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c index e137090f..d09942e8 100644 --- a/ufs/pokeloc.c +++ b/ufs/pokeloc.c @@ -1,5 +1,5 @@ /* Remember where we've written the disk to speed up sync - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -20,7 +20,7 @@ #include "ufs.h" -struct pokeloc +struct pokeloc { vm_offset_t offset; vm_size_t length; @@ -36,7 +36,7 @@ record_poke (void *loc, vm_size_t length) { struct pokeloc *pl = malloc (sizeof (struct pokeloc)); vm_offset_t offset; - + offset = loc - disk_image; pl->offset = trunc_page (offset); pl->length = round_page (offset + length) - pl->offset; @@ -71,11 +71,11 @@ void sync_disk (int wait) { struct pokeloc *pl, *tmp; - + spin_lock (&pokelistlock); for (pl = pokelist; pl; pl = tmp) { - pager_sync_some (diskpager->p, pl->offset, pl->length, wait); + pager_sync_some (disk_pager, pl->offset, pl->length, wait); tmp = pl->next; free (pl); } -- cgit v1.2.3 From 6eebcfcac97283bb0024e1a7dff24493eb7a1490 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Jan 1996 16:54:03 +0000 Subject: (diskfs_shutdown_pager, diskfs_sync_everything): Use `disk_pager' in place of `diskpager->p'. (create_disk_pager): Rewritten using disk_pager_setup. --- ufs/pager.c | 136 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 65 insertions(+), 71 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 26f5f322..695a006b 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -43,7 +43,7 @@ find_address (struct user_pager_info *upi, struct rwlock **nplock) { error_t err; - + assert (upi->type == DISK || upi->type == FILE_DATA); if (upi->type == DISK) @@ -53,13 +53,13 @@ find_address (struct user_pager_info *upi, *nplock = 0; return 0; } - else + else { struct iblock_spec indirs[NIADDR + 1]; struct node *np; - + np = upi->np; - + rwlock_reader_lock (&np->dn->allocptrlock); *nplock = &np->dn->allocptrlock; @@ -68,12 +68,12 @@ find_address (struct user_pager_info *upi, rwlock_reader_unlock (&np->dn->allocptrlock); return EIO; } - + if (offset + __vm_page_size > np->allocsize) *disksize = np->allocsize - offset; else *disksize = __vm_page_size; - + err = fetch_indir_spec (np, lblkno (sblock, offset), indirs); if (err) rwlock_reader_unlock (&np->dn->allocptrlock); @@ -85,13 +85,13 @@ find_address (struct user_pager_info *upi, else *addr = 0; } - + return err; } } -/* Implement the pager_read_page callback from the pager library. See +/* Implement the pager_read_page callback from the pager library. See for the interface description. */ error_t pager_read_page (struct user_pager_info *pager, @@ -103,11 +103,11 @@ pager_read_page (struct user_pager_info *pager, struct rwlock *nplock; daddr_t addr; int disksize; - + err = find_address (pager, page, &addr, &disksize, &nplock); if (err) return err; - + if (addr) { err = diskfs_device_read_sync (addr, (void *)buf, disksize); @@ -124,14 +124,14 @@ pager_read_page (struct user_pager_info *pager, vm_allocate (mach_task_self (), buf, __vm_page_size, 1); *writelock = 1; } - + if (nplock) rwlock_reader_unlock (nplock); - + return err; } -/* Implement the pager_write_page callback from the pager library. See +/* Implement the pager_write_page callback from the pager library. See for the interface description. */ error_t pager_write_page (struct user_pager_info *pager, @@ -142,11 +142,11 @@ pager_write_page (struct user_pager_info *pager, int disksize; struct rwlock *nplock; error_t err; - + err = find_address (pager, page, &addr, &disksize, &nplock); if (err) return err; - + if (addr) err = diskfs_device_write_sync (addr, buf, disksize); else @@ -154,17 +154,17 @@ pager_write_page (struct user_pager_info *pager, printf ("Attempt to write unallocated disk\n."); printf ("Object %p\tOffset %#x\n", pager, page); fflush (stdout); - err = 0; /* unallocated disk; + err = 0; /* unallocated disk; error would be pointless */ } - + if (nplock) rwlock_reader_unlock (nplock); - + return err; } -/* Implement the pager_unlock_page callback from the pager library. See +/* Implement the pager_unlock_page callback from the pager library. See for the interface description. */ error_t pager_unlock_page (struct user_pager_info *pager, @@ -177,7 +177,7 @@ pager_unlock_page (struct user_pager_info *pager, struct disknode *dn; struct dinode *di; - /* Zero an sblock->fs_bsize piece of disk starting at BNO, + /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect blocks before setting the pointer to them to ensure that an indirect block absolutely never points to garbage. */ @@ -196,13 +196,13 @@ pager_unlock_page (struct user_pager_info *pager, if (pager->type == DISK) return 0; - + np = pager->np; dn = np->dn; di = dino (dn->number); rwlock_writer_lock (&dn->allocptrlock); - + /* If this is the last block, we don't let it get unlocked. */ if (address + __vm_page_size > blkroundup (sblock, np->allocsize) - sblock->fs_bsize) @@ -212,7 +212,7 @@ pager_unlock_page (struct user_pager_info *pager, rwlock_writer_unlock (&dn->allocptrlock); return EIO; } - + err = fetch_indir_spec (np, lblkno (sblock, address), indirs); if (err) { @@ -228,10 +228,10 @@ pager_unlock_page (struct user_pager_info *pager, } /* See if we need a triple indirect block; fail if we do. */ - assert (indirs[0].offset == -1 - || indirs[1].offset == -1 + assert (indirs[0].offset == -1 + || indirs[1].offset == -1 || indirs[2].offset == -1); - + /* Check to see if this block is allocated. */ if (indirs[0].bno == 0) { @@ -252,7 +252,7 @@ pager_unlock_page (struct user_pager_info *pager, else { daddr_t *siblock; - + /* We need to set siblock to the single indirect block array; see if the single indirect block is allocated. */ if (indirs[1].bno == 0) @@ -272,7 +272,7 @@ pager_unlock_page (struct user_pager_info *pager, else { daddr_t *diblock; - + /* We need to set diblock to the double indirect block array; see if the double indirect block is allocated. */ @@ -281,7 +281,7 @@ pager_unlock_page (struct user_pager_info *pager, /* This assert because triple indirection is not supported. */ assert (indirs[2].offset == -1); - + err = ffs_alloc (np, lblkno (sblock, address), ffs_blkpref (np, lblkno (sblock, address), @@ -296,9 +296,9 @@ pager_unlock_page (struct user_pager_info *pager, diblock = indir_block (indirs[2].bno); mark_indir_dirty (np, indirs[2].bno); - + /* Now we can allocate the single indirect block */ - + err = ffs_alloc (np, lblkno (sblock, address), ffs_blkpref (np, lblkno (sblock, address), indirs[1].offset, diblock), @@ -310,7 +310,7 @@ pager_unlock_page (struct user_pager_info *pager, record_poke (diblock, sblock->fs_bsize); } } - + siblock = indir_block (indirs[1].bno); mark_indir_dirty (np, indirs[1].bno); @@ -330,14 +330,14 @@ pager_unlock_page (struct user_pager_info *pager, record_poke (siblock, sblock->fs_bsize); } } - + out: diskfs_end_catch_exception (); rwlock_writer_unlock (&dn->allocptrlock); return err; } -/* Implement the pager_report_extent callback from the pager library. See +/* Implement the pager_report_extent callback from the pager library. See for the interface description. */ inline error_t pager_report_extent (struct user_pager_info *pager, @@ -352,7 +352,7 @@ pager_report_extent (struct user_pager_info *pager, *size = diskfs_device_size << diskfs_log2_device_block_size; else *size = pager->np->allocsize; - + return 0; } @@ -377,7 +377,7 @@ void pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) { } - + static void @@ -389,23 +389,17 @@ thread_function (any_t foo __attribute__ ((unused))) 1, MACH_PORT_NULL); } -/* Create a the DISK pager, initializing DISKPAGER, and DISKPAGERPORT */ +/* Create the DISK pager. */ void -create_disk_pager () +create_disk_pager (void) { - pager_bucket = ports_create_bucket (); - - cthread_detach (cthread_fork ((cthread_fn_t) thread_function, (any_t) 0)); - - diskpager = malloc (sizeof (struct user_pager_info)); - diskpager->type = DISK; - diskpager->np = 0; - diskpager->p = pager_create (diskpager, pager_bucket, - MAY_CACHE, MEMORY_OBJECT_COPY_NONE); - diskpagerport = pager_get_port (diskpager->p); - mach_port_insert_right (mach_task_self (), diskpagerport, diskpagerport, - MACH_MSG_TYPE_MAKE_SEND); -} + struct user_pager_info *upi = malloc (sizeof (struct user_pager_info)); + + upi->type = DISK; + upi->np = 0; + disk_pager_setup (upi, MAY_CACHE); + upi->p = disk_pager; +} /* This syncs a single file (NP) to disk. Wait for all I/O to complete if WAIT is set. NP->lock must be held. */ @@ -421,13 +415,13 @@ diskfs_file_update (struct node *np, if (upi) ports_port_ref (upi->p); spin_unlock (&node2pagelock); - + if (upi) { pager_sync (upi->p, wait); ports_port_deref (upi->p); } - + for (d = np->dn->dirty; d; d = tmp) { sync_disk_blocks (d->bno, sblock->fs_bsize, wait); @@ -452,13 +446,13 @@ flush_node_pager (struct node *node) if (upi) ports_port_ref (upi->p); spin_unlock (&node2pagelock); - + if (upi) { pager_flush (upi->p, 1); ports_port_deref (upi->p); } - + dn->dirty = 0; while (dirty) @@ -480,7 +474,7 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) assert (S_ISDIR (np->dn_stat.st_mode) || S_ISREG (np->dn_stat.st_mode) || (S_ISLNK (np->dn_stat.st_mode) - && (!direct_symlink_extension + && (!direct_symlink_extension || np->dn_stat.st_size >= sblock->fs_maxsymlinklen))); spin_lock (&node2pagelock); @@ -513,12 +507,12 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) while (right == MACH_PORT_NULL); spin_unlock (&node2pagelock); - + mach_port_insert_right (mach_task_self (), right, right, MACH_MSG_TYPE_MAKE_SEND); return right; -} +} /* Call this when we should turn off caching so that unused memory object ports get freed. */ @@ -526,7 +520,7 @@ void drop_pager_softrefs (struct node *np) { struct user_pager_info *upi; - + spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) @@ -545,13 +539,13 @@ void allow_pager_softrefs (struct node *np) { struct user_pager_info *upi; - + spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) ports_port_ref (upi->p); spin_unlock (&node2pagelock); - + if (MAY_CACHE && upi) pager_change_attributes (upi->p, 1, MEMORY_OBJECT_COPY_DELAY, 0); if (upi) @@ -564,11 +558,11 @@ block_caching () error_t block_cache (void *arg) { struct pager *p = arg; - + pager_change_attributes (p, 0, MEMORY_OBJECT_COPY_DELAY, 1); return 0; } - + /* Loop through the pagers and turn off caching one by one, synchronously. That should cause termination of each pager. */ ports_bucket_iterate (pager_bucket, block_cache); @@ -581,7 +575,7 @@ enable_caching () { struct pager *p = arg; struct user_pager_info *upi = pager_get_upi (p); - + pager_change_attributes (p, 1, MEMORY_OBJECT_COPY_DELAY, 0); /* It's possible that we didn't have caching on before, because @@ -619,7 +613,7 @@ diskfs_pager_users () /* Give it a second; the kernel doesn't actually shutdown immediately. XXX */ sleep (1); - + npagers = ports_count_bucket (pager_bucket); if (npagers <= 1) return 0; @@ -628,7 +622,7 @@ diskfs_pager_users () and return failure. */ enable_caching (); } - + ports_enable_bucket (pager_bucket); return 1; @@ -674,7 +668,7 @@ diskfs_max_user_pager_prot () /* Call this to find out the struct pager * corresponding to the FILE_DATA pager of inode IP. This should be used *only* as a subsequent - argument to register_memory_fault_area, and will be deleted when + argument to register_memory_fault_area, and will be deleted when the kernel interface is fixed. NP must be locked. */ struct pager * diskfs_get_filemap_pager_struct (struct node *np) @@ -692,7 +686,7 @@ diskfs_shutdown_pager () { struct pager *p = arg; /* Make sure the disk pager is done last. */ - if (p != diskpager->p) + if (p != disk_pager) pager_shutdown (p); return 0; } @@ -700,7 +694,7 @@ diskfs_shutdown_pager () copy_sblock (); write_all_disknodes (); ports_bucket_iterate (pager_bucket, shutdown_one); - pager_shutdown (diskpager->p); + pager_shutdown (disk_pager); } /* Sync all the pagers. */ @@ -711,11 +705,11 @@ diskfs_sync_everything (int wait) { struct pager *p = arg; /* Make sure the disk pager is done last. */ - if (p != diskpager->p) + if (p != disk_pager) pager_sync (p, wait); return 0; } - + copy_sblock (); write_all_disknodes (); ports_bucket_iterate (pager_bucket, sync_one); -- cgit v1.2.3 From f581c957585a4ed88422839bd1526b6ef651b2c1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Jan 1996 16:55:44 +0000 Subject: (diskpager, diskpagerport, disk_image): Variables removed. Include instead. (sync_disk_blocks): Use `disk_pager' in place of `diskpager->p'. --- ufs/ufs.h | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 8771c372..0f310d1b 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1995 Free Software Foundation +/* + Copyright (C) 1994, 1995, 1996 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 @@ -32,7 +32,7 @@ /* #undef DONT_CACHE_MEMORY_OBJECTS */ -struct disknode +struct disknode { ino_t number; @@ -48,7 +48,7 @@ struct disknode struct dirty_indir *dirty; struct user_pager_info *fileinfo; -}; +}; /* Identifies a particular block and where it's found when interpreting indirect block structure. */ @@ -69,10 +69,10 @@ struct dirty_indir struct dirty_indir *next; }; -struct user_pager_info +struct user_pager_info { struct node *np; - enum pager_type + enum pager_type { DISK, FILE_DATA, @@ -81,8 +81,7 @@ struct user_pager_info vm_prot_t max_prot; }; -struct user_pager_info *diskpager; -mach_port_t diskpagerport; +#include extern vm_address_t zeroblock; @@ -91,8 +90,6 @@ extern struct csum *csum; int sblock_dirty; int csum_dirty; -void *disk_image; - spin_lock_t node2pagelock; spin_lock_t alloclock; @@ -111,7 +108,7 @@ enum compat_mode /* If this is set, then this filesystem has two extensions: 1) directory entries include the type field. - 2) symlink targets might be written directly in the di_db field + 2) symlink targets might be written directly in the di_db field of the dinode. */ int direct_symlink_extension; @@ -136,7 +133,7 @@ extern inline struct dinode * dino (ino_t inum) { return (struct dinode *) - (disk_image + (disk_image + fsaddr (sblock, ino_to_fsba (sblock, inum)) + ino_to_fsbo (sblock, inum) * sizeof (struct dinode)); } @@ -159,7 +156,7 @@ cg_locate (int ncg) extern inline void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait) { - pager_sync_some (diskpager->p, fsaddr (sblock, blkno), nbytes, wait); + pager_sync_some (disk_pager, fsaddr (sblock, blkno), nbytes, wait); } /* Sync an disk inode */ @@ -170,7 +167,7 @@ sync_dinode (int inum, int wait) } /* From alloc.c: */ -error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, +error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, struct protid *); void ffs_blkfree(struct node *, daddr_t bno, long size); daddr_t ffs_blkpref (struct node *, daddr_t, int, daddr_t *); -- cgit v1.2.3 From 4abfbe4f0d351e27eb35b2c5a91d6833283bb0e4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 16 Jan 1996 21:42:13 +0000 Subject: (trivfs_modify_stat): The peropen hook holds a struct open, not a struct dev. --- devio/devio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devio/devio.c b/devio/devio.c index 11b41f70..d0f2b9fb 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -233,11 +233,12 @@ int trivfs_allow_open = O_READ | O_WRITE; void trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) { - struct dev *dev = cred->po->hook; + struct open *open = cred->po->hook; - if (dev) + if (open) /* An open device. */ { + struct dev *dev = open->dev; vm_size_t size = dev->size; if (dev->block_size > 1) -- cgit v1.2.3 From 0de2a41da1be00201e65a2cec1d80ae1bc550722 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 27 Jan 1996 16:32:39 +0000 Subject: (trivfs_goaway): Handle errors from ports_inhibit_class_rpcs. Allow rpcs to resume if we're going to return EBUSY. --- devio/devio.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/devio/devio.c b/devio/devio.c index d0f2b9fb..f1eb428a 100644 --- a/devio/devio.c +++ b/devio/devio.c @@ -271,6 +271,7 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) error_t trivfs_goaway (struct trivfs_control *fsys, int flags) { + error_t err; int force = (flags & FSYS_GOAWAY_FORCE); int nosync = (flags & FSYS_GOAWAY_NOSYNC); @@ -280,7 +281,12 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) exit (0); /* Wait until all pending rpcs are done. */ - ports_inhibit_class_rpcs (root_port_class); + err = ports_inhibit_class_rpcs (root_port_class); + if (err == EINTR || (err && !force)) + { + mutex_unlock (&device_lock); + return err; + } if (force && nosync) /* Exit with extreme prejudice. */ @@ -310,6 +316,7 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) busy: /* Allow normal operations to proceed. */ ports_enable_class (root_port_class); + ports_resume_class_rpcs (root_port_class); mutex_unlock(&device_lock); /* Complain that there are still users. */ -- cgit v1.2.3 From ce7f83eb2327315f38f31eaf7cd22aded2610695 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 30 Jan 1996 17:34:17 +0000 Subject: Grok `tty'. --- devio/MAKEDEV | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 4adbf331..4e6872a6 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -21,6 +21,8 @@ for I; do $ST $I /hurd/null ;; zero) $ST $I /hurd/null -z ;; + tty) + $ST $I /hurd/magic tty ;; fd) $ST $I /hurd/magic fd ln -f -s fd/0 stdin -- cgit v1.2.3 From 9b82dd57efc2370720627abb5ba3f79f4b9c2e69 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 17 Feb 1996 21:06:50 +0000 Subject: (main): Check error return from diskfs_init_diskfs. --- ufs/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index b7dd13c5..ea43acce 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -83,7 +83,9 @@ main (int argc, char **argv) } /* Initialize the diskfs library. Must come before any other diskfs call. */ - diskfs_init_diskfs (); + err = diskfs_init_diskfs (); + if (err) + error (4, err, "init"); err = diskfs_device_open (); if (err) -- cgit v1.2.3 From 0ed9021be7cd90ebb9116ea3ba26f50cc81105f7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 20 Feb 1996 18:38:10 +0000 Subject: Add rule for `time', and add `time' to std. --- devio/MAKEDEV | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 4e6872a6..bf5217dc 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -13,7 +13,7 @@ export _CWD for I; do case "$I" in std) - $0 console tty null zero fd + $0 console tty null zero fd time ;; console|tty[0-9]?|tty[0-9a-f]) $ST $I /hurd/term $_CWD/$I device $I;; @@ -29,6 +29,8 @@ for I; do ln -f -s fd/1 stdout ln -f -s fd/2 stderr ;; + time) + $ST $I /hurd/devport time ;; # ptys [pt]ty[pqPQ]?) -- cgit v1.2.3 From fd66050fcf2ba9fc8c3c81e222fcc99a7bf03d42 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 21 Feb 1996 10:57:07 +0000 Subject: Implement proper handling of the filesystem `clean bit'. (ufs_clean): New variable. (get_hypermetadata): Set it from the fs_clean flag. If not clean, complain and force read-only. Complain when ignoring COMPAT_BSD42. (diskfs_set_hypermetadata): Set the clean flag in the superblock when CLEAN and fs was clean to start with. (copy_sblock): Remove bogus clean flag frobnication. --- ufs/hyper.c | 107 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 36 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 01c06b89..fc2bb1ed 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -18,13 +18,16 @@ #include "ufs.h" #include #include +#include -static int oldformat = 0; +static int ufs_clean; /* fs clean before we started writing? */ -vm_address_t zeroblock = 0; +static int oldformat; -struct fs *sblock = 0; -struct csum *csum = 0; +vm_address_t zeroblock; + +struct fs *sblock; +struct csum *csum; void get_hypermetadata (void) @@ -75,6 +78,18 @@ get_hypermetadata (void) assert ((sblock->fs_bsize % DEV_BSIZE) == 0); assert (__vm_page_size <= sblock->fs_bsize); + /* Examine the clean bit and force read-only if unclean. */ + ufs_clean = sblock->fs_clean; + if (! ufs_clean) + { + error (0, 0, "warning: FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck"); + if (! diskfs_readonly) + { + diskfs_readonly = 1; + error (0, 0, "MOUNTED READ-ONLY; MUST USE `fsysopts --writable'"); + } + } + /* If this is an old filesystem, then we have some more work to do; some crucial constants might not be set; we are therefore forced to set them here. */ @@ -137,8 +152,11 @@ get_hypermetadata (void) if ((sblock->fs_inodefmt == FS_44INODEFMT || direct_symlink_extension) && compat_mode == COMPAT_BSD42) - /* XXX should syslog to this effect */ - compat_mode = COMPAT_BSD44; + { + compat_mode = COMPAT_BSD44; + error (0, 0, + "4.2 compat mode requested on 4.4 fs--switched to 4.4 mode"); + } } /* Write the csum data. This isn't backed by a pager because it is @@ -154,28 +172,36 @@ diskfs_set_hypermetadata (int wait, int clean) spin_lock (&alloclock); - if (!csum_dirty) + if (csum_dirty) { - spin_unlock (&alloclock); - return; - } + /* Copy into a page-aligned buffer to avoid bugs in kernel device + code. */ - /* Copy into a page-aligned buffer to avoid bugs in kernel device code. */ + bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); - bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); + err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), + &buf, bufsize); + if (!err) + { + bcopy (csum, (void *) buf, sblock->fs_cssize); + diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), + buf, bufsize); + csum_dirty = 0; + vm_deallocate (mach_task_self (), buf, bufsize); + } + } - err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), - &buf, bufsize); - if (!err) + if (clean && ufs_clean && !sblock->fs_clean) { - bcopy (csum, (void *) buf, sblock->fs_cssize); - diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), - buf, bufsize); - csum_dirty = 0; - vm_deallocate (mach_task_self (), buf, bufsize); + /* The filesystem is clean, so set the clean flag. */ + sblock->fs_clean = 1; + sblock_dirty = 1; } spin_unlock (&alloclock); + + /* Update the superblock if necessary (clean bit was just set). */ + copy_sblock (); } /* Copy the sblock into the disk */ @@ -184,21 +210,15 @@ copy_sblock () { error_t err; - int clean = 1; /* XXX wrong... */ - err = diskfs_catch_exception (); assert_perror (err); spin_lock (&alloclock); - if (clean && !diskfs_readonly) - { - sblock->fs_clean = 1; - sblock_dirty = 1; - } - if (sblock_dirty) { + assert (! diskfs_readonly); + if (sblock->fs_postblformat == FS_42POSTBLFMT || oldformat) { @@ -221,17 +241,23 @@ copy_sblock () sblock_dirty = 0; } - if (clean && !diskfs_readonly) + if (!diskfs_readonly && sblock->fs_clean) { + /* We just sync'd with the clean flag set, but we are still a + writable filesystem. Clear the flag in core, but don't write the + superblock yet. This should ensure that the flag will be written + as clear as soon as we make any modifications. */ sblock->fs_clean = 0; sblock_dirty = 1; } spin_unlock (&alloclock); + diskfs_end_catch_exception (); } -void diskfs_readonly_changed (int readonly) +void +diskfs_readonly_changed (int readonly) { vm_protect (mach_task_self (), (vm_address_t)disk_image, @@ -239,12 +265,21 @@ void diskfs_readonly_changed (int readonly) 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE)); if (readonly) - sblock_dirty = 0; - else { - sblock->fs_clean = 0; - strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ - sblock_dirty = 1; - diskfs_set_hypermetadata (1, 0); + /* We know we are sync'd now. The superblock is marked as dirty + because we cleared the clean flag immediately after sync'ing. + But now we want to leave it marked clean and not touch it further. */ + sblock_dirty = 0; + return; } + + strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ + + if (sblock->fs_clean) + sblock->fs_clean = 0; + else + error (0, 0, "WARNING: UNCLEANED FILESYSTEM NOW WRITABLE"); + + sblock_dirty = 1; + diskfs_set_hypermetadata (1, 0); } -- cgit v1.2.3 From fbf3f8beef691c62d1d1432b732512fa63c4bead Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 23 Feb 1996 20:27:01 +0000 Subject: (get_hypermetadata): Use diskfs_device_arg in unclean msgs. --- ufs/hyper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index fc2bb1ed..be51b360 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -82,11 +82,15 @@ get_hypermetadata (void) ufs_clean = sblock->fs_clean; if (! ufs_clean) { - error (0, 0, "warning: FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck"); + error (0, 0, + "%s: warning: FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck", + diskfs_device_arg); if (! diskfs_readonly) { diskfs_readonly = 1; - error (0, 0, "MOUNTED READ-ONLY; MUST USE `fsysopts --writable'"); + error (0, 0, + "%s: MOUNTED READ-ONLY; MUST USE `fsysopts --writable'", + diskfs_device_arg); } } -- cgit v1.2.3 From 1b97ed9b94155d608c7dcf47b2e9b655996aeec2 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 27 Feb 1996 20:26:54 +0000 Subject: Initial revision --- ufs-utils/stati.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 ufs-utils/stati.c diff --git a/ufs-utils/stati.c b/ufs-utils/stati.c new file mode 100644 index 00000000..ca980ecd --- /dev/null +++ b/ufs-utils/stati.c @@ -0,0 +1,211 @@ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rich $alz of BBN Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; + +static char copyright[] __attribute__ ((unused)); +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; +static char sccsid[] __attribute__ ((unused)); +#endif /* not lint */ + +/* Modified by Michael I. Bushnell for GNU Hurd. */ + +#include +#include + +#include "../ufs/dinode.h" +#include "../ufs/fs.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXPHYS (64 * 1024) +#define DEV_BSIZE 512 + +/* Returns a nice representation of a struct timespec in a static buffer. */ +static char * +timespec_rep (struct timespec *ts) +{ + static char buf[200], *p = buf; + if (ts->ts_sec || ts->ts_nsec) + { + time_t time = ts->ts_sec; + strcpy (buf, ctime (&time)); + p += strlen (buf); + if (p[-1] == '\n') + p--; + *p++ = ';'; + *p++ = ' '; + } + snprintf (p, buf + sizeof buf - p, "[%ld, %ld]", ts->ts_sec, ts->ts_nsec); + return buf; +} + +/* Returns a nice representation of a uid in a static buffer. */ +static char * +uid_rep (uid_t uid) +{ + static char buf[200]; + struct passwd *pw = getpwuid (uid); + if (pw) + snprintf (buf, sizeof buf, "%d(%s)", uid, pw->pw_name); + else + snprintf (buf, sizeof buf, "%d", uid); + return buf; +} + +/* Returns a nice representation of a gid in a static buffer. */ +static char * +gid_rep (gid_t gid) +{ + static char buf[200]; + struct group *gr = getgrgid (gid); + if (gr) + snprintf (buf, sizeof buf, "%d(%s)", gid, gr->gr_name); + else + snprintf (buf, sizeof buf, "%d", gid); + return buf; +} + +int +main(argc, argv) + int argc; + char *argv[]; +{ + register struct fs *sbp; + register struct dinode *ip; + register int fd; + struct dinode ibuf[MAXBSIZE / sizeof (struct dinode)]; + long bsize; + off_t offset; + int inonum; + char *fs, sblock[SBSIZE]; + + if (argc < 3) { + (void)fprintf(stderr, "usage: stati filesystem inode ...\n"); + exit(1); + } + + fs = *++argv; + + /* get the superblock. */ + if ((fd = open(fs, O_RDWR, 0)) < 0) + { + perror (fs); + exit (1); + } + if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0) + { + perror (fs); + exit (1); + } + if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock)) { + (void)fprintf(stderr, + "stati: %s: can't read the superblock.\n", fs); + exit(1); + } + + sbp = (struct fs *)sblock; + if (sbp->fs_magic != FS_MAGIC) { + (void)fprintf(stderr, + "stati: %s: superblock magic number 0x%lux, not 0x%x.\n", + fs, sbp->fs_magic, FS_MAGIC); + exit(1); + } + bsize = sbp->fs_bsize; + + /* remaining arguments are inode numbers. */ + while (*++argv) { + /* get the inode number. */ + if ((inonum = atoi(*argv)) <= 0) { + (void)fprintf(stderr, + "stati: %s is not a valid inode number.\n", *argv); + exit(1); + } + + /* read in the appropriate block. */ + offset = ino_to_fsba(sbp, inonum); /* inode to fs blk */ + offset = fsbtodb(sbp, offset); /* fs blk disk blk */ + offset *= DEV_BSIZE; /* disk blk to bytes */ + + /* seek and read the block */ + if (lseek(fd, offset, SEEK_SET) < 0) + { + perror (fs); + exit (1); + } + if (read(fd, ibuf, bsize) != bsize) + { + perror (fs); + exit (1); + } + + /* get the inode within the block. */ + ip = &ibuf[ino_to_fsbo(sbp, inonum)]; + + if (argc > 3) + printf ("inode: %d\n", inonum); + + printf ("nlink: %d\n", ip->di_nlink); + printf ("size: %qd\n", ip->di_size); + printf ("atime: %s\n", timespec_rep (&ip->di_atime)); + printf ("mtime: %s\n", timespec_rep (&ip->di_mtime)); + printf ("ctime: %s\n", timespec_rep (&ip->di_ctime)); + printf ("flags: %#lx\n", ip->di_flags); + printf ("blocks: %ld\n", ip->di_blocks); + printf ("gener: %ld\n", ip->di_gen); + printf ("uid: %s\n", uid_rep (ip->di_uid)); + printf ("gid: %s\n", gid_rep (ip->di_gid)); + printf ("trans: %ld\n", ip->di_trans); + + if (argv[1]) + putchar ('\n'); + } + (void)close(fd); + exit(0); +} -- cgit v1.2.3 From 452957c00bb385f232d1bbc14789e8e3bc777cc6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 5 Mar 1996 23:00:13 +0000 Subject: Update to new location. --- ufs-utils/Makefile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index d7a16396..b22aa382 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1994 Free Software Foundation +# Copyright (C) 1994, 1996 Free Software Foundation # Written by Michael I. Bushnell. # # This file is part of the GNU Hurd. @@ -18,13 +18,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -dir := newfs -makemode := utility +dir := ufs-utils +makemode := utilities -SRCS = mkfs.c # newfs.c -OBJS = mkfs.o # newfs.o -target = mkfs.ufs +targets = mkfs.ufs clri.ufs stati.ufs +target-suffix = .ufs +SRCS = mkfs.c clri.c stati.c installationdir = $(sbindir) +OBJS = $(SRCS:.c=.o) + +all: $(targets) + include ../Makeconf -- cgit v1.2.3 From b3c86bcc4afbb986931c5b54cca43b9cc3a3c074 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 13 Mar 1996 23:44:54 +0000 Subject: Initial revision --- ufs-utils/dlabel.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 ufs-utils/dlabel.c diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c new file mode 100644 index 00000000..dbae0457 --- /dev/null +++ b/ufs-utils/dlabel.c @@ -0,0 +1,81 @@ +/* Get the disklabel from a device node + + Copyright (C) 1996 Free Software Foundation, Inc. + + Written by Miles Bader + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, 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 +#include +#include +#include +#include +#include /* Ick */ +#include + +static error_t +fd_get_device (int fd, device_t *device) +{ + error_t err; + string_t name; + int class, flags = 0; + size_t block_size; + off_t *runs = 0; + char *misc = 0; + size_t runs_len = 0, misc_len = 0; + file_t node = getdport (fd); + + if (node == MACH_PORT_NULL) + return errno; + + err = file_get_storage_info (node, &class, &runs, &runs_len, &block_size, + name, device, &misc, &misc_len, &flags); + if (!err) + { + if (runs_len != 2 || runs[0] != 0 || class != STORAGE_DEVICE) + /* This doesn't seem to be a handle on the whole device; be picky. */ + err = ENODEV; + if (runs_len) + vm_deallocate (mach_task_self (), (vm_address_t)runs, runs_len); + if (misc_len) + vm_deallocate (mach_task_self (), (vm_address_t)misc, misc_len); + } + + mach_port_deallocate (mach_task_self (), node); + + return err; +} + +error_t +fd_get_disklabel (int fd, struct disklabel *label) +{ + device_t device; + error_t err = fd_get_device (fd, &device); + + if (! err) + { + mach_msg_type_number_t label_len = sizeof *label / sizeof (integer_t); + + err = device_get_status (device, DIOCGDINFO, + (dev_status_t)label, &label_len); + if (!err && label_len != sizeof *label / sizeof (integer_t)) + err = ERANGE; + + mach_port_deallocate (mach_task_self (), device); + } + + return err; +} -- cgit v1.2.3 From 88ce3cbe98f20eab434ba7e11332fb0c5135496c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 13 Mar 1996 23:45:09 +0000 Subject: (SRCS): Add dlabel.c. (mkfs.ufs): New target. --- ufs-utils/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index b22aa382..01845450 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -23,12 +23,14 @@ makemode := utilities targets = mkfs.ufs clri.ufs stati.ufs target-suffix = .ufs -SRCS = mkfs.c clri.c stati.c +SRCS = mkfs.c clri.c stati.c dlabel.c installationdir = $(sbindir) OBJS = $(SRCS:.c=.o) all: $(targets) +mkfs.ufs: mkfs.o dlabel.o ../libshouldbeinlibc/libshouldbeinlibc.a + include ../Makeconf -- cgit v1.2.3 From b32509445090c11ca81df8a2e66fe33ccde8b190 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 13 Mar 1996 23:47:12 +0000 Subject: (options, args_doc, doc): New variables for option parsing. (struct amark): New type. (amarks_add, amarks_contains): New functions. (default_disklabel): New variable. (main): Most arguments are now options (and optional). Allow many more parameters to be specified. Consult the disk label for some defaults. (...most functions...): Add explicit return type declarations where necessary. Fix printf format specifications. Get rid of #ifdefs for MFS. (started, malloc, realloc, calloc, free): Functions removed. (mfs, membase): Variables removed. , , , , , : New includes --- ufs-utils/mkfs.c | 629 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 319 insertions(+), 310 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index dd293fde..4d0d4ab9 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,10 +33,16 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.8 1996/03/13 23:47:12 miles Exp $"; #endif /* not lint */ #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -49,6 +55,9 @@ static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; #include #include +#include +#include + /* Begin misc additions for GNU Hurd */ /* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD @@ -64,8 +73,6 @@ static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; ((sizeof (struct directory_entry) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) #endif -#define NBBY 8 - #define MAXPHYS (64 * 1024) /* Provide mode from struct dinode * */ @@ -86,6 +93,11 @@ static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; * make file system for cylinder-group style file systems */ +extern error_t fd_get_disklabel (int fd, struct disklabel *lab); +static void mkfs (), initcg (), fsinit (), setblock (); +static void iput (), rdfs (), clrblock (), wtfs (); +static int makedir (), isblock (); + /* * We limit the size of the inode map to be no more than a * third of the cylinder group space, since we must leave at @@ -103,9 +115,6 @@ static char *rcsid = "$Id: mkfs.c,v 1.7 1994/11/24 23:39:21 roland Exp $"; * variables set up by front end. */ #define extern -#ifdef MFS -extern int mfs; /* run as the memory based filesystem */ -#endif extern int Nflag; /* run mkfs without writing file system */ extern int Oflag; /* format as an 4.3BSD file system */ extern int fssize; /* file system size */ @@ -132,9 +141,6 @@ extern int maxbpg; /* maximum blocks per file in a cyl group */ extern int nrpos; /* # of distinguished rotational positions */ extern int bbsize; /* boot block size */ extern int sbsize; /* superblock size */ -extern u_long memleft; /* virtual memory available */ -extern caddr_t membase; /* start address of memory based filesystem */ -extern caddr_t malloc(), calloc(); #undef extern union { @@ -154,113 +160,270 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; int fsi, fso; daddr_t alloc(); + +#define _STRINGIFY(arg) #arg +#define STRINGIFY(arg) _STRINGIFY (arg) + +static const struct argp_option options[] = { + {0,0,0,0,0, 1}, + {"just-print", 'N', 0, 0, + "Just print the file system parameters that would be used"}, + {"old-format", 'O', 0, 0, "Create a 4.3BSD format filesystem"}, + {"max-contig", 'a', "BLOCKS", 0, + "The maximum number of contiguous blocks that will be laid out before" + " forcing a rotational delay; the default is no limit"}, + {"block-size", 'b', "BYTES", 0, "The block size of the file system"}, + {"group-cylinders", 'c', "N", 0, + "The number of cylinders per cylinder group; the default 16"}, + {"rot-delay", 'd', "MSEC", 0, + "The expected time to service a transfer completion interrupt and" + " initiate a new transfer on the same disk; the default is 0"}, + {"max-bpg", 'e', "BLOCKS", 0, + "Maximum number of blocks any single file can allocate out of a cylinder" + " group before it is forced to begin allocating blocks from another" + " cylinder group; the default is about one quarter of the total blocks" + " in a cylinder group"}, + {"frag-size", 'f', "BYTES", 0, "The fragment size"}, + {"inode-density", 'i', "BYTES", 0, + "The density of inodes in the file system, in bytes of data space per" + " inode; the default is one inode per 4 filesystem frags"}, + {"minfree", 'm', "PERCENT", 0, + "The percentage of space reserved from normal users; the default is " + STRINGIFY (MINFREE) "%"}, + {"rot-positions", 'n', "N", 0, + "The number of distinct rotational positions; the default is 8"}, + {"optimization", 'o', "METH", 0, "``space'' or ``time''"}, + {"size", 's', "SECTORS", 0, "The size of the file system"}, + + {0,0,0,0, + "The following options override the standard sizes for the disk" + " geometry; their default values are taken from the disk label:", 2}, + + {"sector-size", 'S', "BYTES", 0, "The size of a sector (usually 512)"}, + {"skew", 'k', "SECTORS", 0, "Sector 0 skew, per track"}, + {"interleave", 'l', "LOG-PHYS-RATIO", 0, "Hardware sector interleave"}, + {"rpm", 'r', "RPM", 0, "The speed of the disk in revolutions per minute"}, + {"tracks", 't', "N", 0, "The number of tracks/cylinder"}, + {"sectors", 'u', "N", 0, + "The number of sectors per track (does not include sectors reserved for" + " bad block replacement"}, + {"spare-sectors", 'p', "N", 0, + "Spare sectors (for bad sector replacement) at the end of each track"}, + {"cyl-spare-sectors", 'x', "N", 0, + "Spare sectors (for bad sector replacement) at the end of the last track" + " in each cylinder"}, + {0, 0} +}; +static char *args_doc = "DEVICE"; +static char *doc = 0; + +struct amark { void *addr; struct amark *next; }; +static void +amarks_add (struct amark **amarks, void *addr) + { + struct amark *up = malloc (sizeof (struct amark)); + assert (up != 0); + up->addr = addr; + up->next = *amarks; + *amarks = up; + } +static int +amarks_contains (struct amark *amarks, void *addr) + { + while (amarks) + if (amarks->addr == addr) + return 1; + else + amarks = amarks->next; + return 0; + } + +static const struct disklabel default_disklabel = { + d_rpm: 3600, + d_interleave: 1, + d_secsize: DEV_BSIZE, + d_sparespertrack: 0, + d_sparespercyl: 0, + d_trackskew: 0, + d_cylskew: 0, + d_headswitch: 0, + d_trkseek: 0, +}; + +void main (int argc, char **argv) { - void usage () - { - fprintf (stderr, - "Usage: %s [-N] special nsect ntrak npseck tskew ileave\n", - argv[0]); - exit (1); - } - /* Usage is - mkfs [-N] special nsect ntrak npsect tskew ileave - - All other parameters are computed from defaults and the device itself. */ - char **args; int fdo, fdi; - char *device; - struct stat st; + char *device = 0; + struct amark *uparams = 0; + error_t label_err = 0; + struct disklabel label_buf, *label = 0; + int nspares = 0, ncspares = 0; - if (argc == 8) + /* Parse our options... */ + error_t parse_opt (int key, char *arg, struct argp_state *state) { - if (argv[1][0] != '-' || argv[1][1] != 'N' || argv[1][2] != '\0') - usage (); - Nflag = 1; - args = &argv[2]; + switch (key) + { + case 'N': Nflag = 1; break; + case 'O': Oflag = 1; break; + + /* Mark &VAR as being a uparam, and return a lvalue for VAR. */ +#define UP(var) (amarks_add (&uparams, &var), var) + /* Record an integer uparam into VAR. */ +#define UP_INT(var) { int _i = atoi (arg); UP (var) = _i; } + + case 'a': UP_INT (maxcontig); break; + case 'b': UP_INT (bsize); break; + case 'c': UP_INT (cpg); break; + case 'd': UP_INT (rotdelay); break; + case 'e': UP_INT (maxbpg); break; + case 'f': UP_INT (fsize); break; + case 'i': UP_INT (density); break; + case 'm': UP_INT (minfree); break; + case 'n': UP_INT (nrpos); break; + case 's': UP_INT (fssize); break; + case 'S': UP_INT (sectorsize); break; + case 'k': UP_INT (trackskew); break; + case 'l': UP_INT (interleave); break; + case 'r': UP_INT (rpm); break; + case 't': UP_INT (ntracks); break; + case 'u': UP_INT (nsectors); break; + case 'p': UP_INT (nspares); break; + case 'x': UP_INT (ncspares); break; + + case 'o': + amarks_add (&uparams, &opt); + if (strcmp (arg, "time") == 0) + opt = FS_OPTTIME; + else if (strcmp (arg, "space") == 0) + opt = FS_OPTSPACE; + else + argp_error (state->argp, + "%s: Invalid value for --optimization", arg); + break; + + case ARGP_KEY_ARG: + if (state->arg_num > 0) + return EINVAL; + device = arg; + + default: + return EINVAL; + } + return 0; } - else if (argc != 7) - usage (); - else - args = &argv[1]; - - /* Default computation taken from 4.4 BSD newfs.c */ - - device = args[0]; - fdi = open (device, O_RDONLY); - if (fdi == -1) + const struct argp argp = { options, parse_opt, args_doc, doc }; + + /* Tries to get the disklabel for DEVICE; if it can't, then if PARAM_NAME + is 0, returns 0, otherwise an error is printed (using PARAM_NAME) and + the program exits. */ + struct disklabel *dl (char *param_name) { - perror (device); - exit (1); + if (! label) + { + if (! label_err) + { + label_err = fd_get_disklabel (fdi, &label_buf); + if (! label_err) + label = &label_buf; + } + if (label_err && param_name) + error (9, label_err, "%s: Can't get disklabel", device); + } + return label; } - fdo = open (device, O_WRONLY); - if (fdo == -1) + /* Tries to get the integer field at offset OFFS from the disklabel for + DEVICE; if it can't, then if PARAM_NAME is 0, returns the corresponding + value from DEFAULT_DISKLABEL, otherwise an error is printed and the + program exits. */ + int dl_int (char *param_name, size_t offs) { - perror (device); - exit (1); + struct disklabel *l = dl (param_name); + return *(int *)((char *)(l ?: &default_disklabel) + offs); } - if (fstat (fdi, &st) == -1) + /* A version of dl_int that takes the field name instead of an offset. */ +#define DL_INT(param_name, field) \ + dl_int (param_name, offsetof (struct disklabel, field)) + + /* Like dl_int, but adjust for any difference in sector size between the + disklabel and SECTORSIZE. */ + int dl_secs (char *param_name, size_t offs) { - perror ("stat"); - exit (1); + int val = dl_int (param_name, offs); + int dl_ss = DL_INT (0, d_secsize); + if (sectorsize < dl_ss) + error (10, 0, + "%s: %d: Sector size is less than device sector size (%d)", + device, sectorsize, dl_ss); + else if (sectorsize > dl_ss) + if (sectorsize % dl_ss != 0) + error (11, 0, + "%s: %d: Sector size not a multiple of device sector size (%d)", + device, sectorsize, dl_ss); + else + val /= sectorsize / dl_ss; + return val; } + /* A version of dl_secs that takes the field name instead of an offset. */ +#define DL_SECS(param_name, field) \ + dl_secs (param_name, offsetof (struct disklabel, field)) -#ifdef MFS - mfs = 0; -#endif - Oflag = 0; - fssize = st.st_size / DEV_BSIZE; + /* Parse our arguments. */ + argp_parse (&argp, argc, argv, 0, 0); - ntracks = atoi (args[2]); - if (ntracks == 0) - { - fprintf (stderr, "Bogus ntracks: %d\n", ntracks); - exit (1); - } - - nsectors = atoi (args[1]); - if (nsectors == 0) - { - fprintf (stderr, "Bogus nsectors: %d\n", nsectors); - exit (1); - } + fdi = open (device, O_RDONLY); + if (fdi == -1) + error (2, errno, "%s", device); + fdo = open (device, O_WRONLY); + if (fdo == -1) + error (3, errno, "%s", device); - nphyssectors = atoi (args[3]); - if (nphyssectors == 0) - { - fprintf (stderr, "Bogus npsect: %d\n", nphyssectors); - exit (1); - } + /* If VAR hasn't been set by the user, set it to DEF_VAL. */ +#define DEFAULT(var, def_val) \ + (amarks_contains (uparams, &var) ? 0 : (((var) = (def_val)), 0)) + + DEFAULT (sectorsize, DEV_BSIZE); + DEFAULT (fssize, + ({ struct stat st; + if (fstat (fdi, &st) == -1) + error (4, errno, "%s: Cannot get size", device); + st.st_size / sectorsize; })); + DEFAULT (ntracks, DL_INT ("tracks", d_ntracks)); + DEFAULT (nsectors, DL_SECS ("sectors", d_nsectors)); + DEFAULT (nspares, DL_SECS (0, d_sparespertrack)); + DEFAULT (ncspares, DL_SECS (0, d_sparespercyl)); + + if (nspares >= nsectors) + error (5, 0, "%d: Too many spare sectors per track", nspares); + if (ncspares >= nsectors) + error (5, 0, "%d: Too many spare sectors per cylinder", ncspares); + nphyssectors = nsectors + nspares; secpercyl = nsectors * ntracks; - sectorsize = DEV_BSIZE; - - rpm = 3600; - - interleave = atoi (args[5]); + DEFAULT (rpm, DL_INT (0, d_rpm)); + DEFAULT (interleave, DL_INT (0, d_interleave)); + DEFAULT (trackskew, DL_SECS (0, d_trackskew)); + DEFAULT (headswitch, DL_INT (0, d_headswitch)); + DEFAULT (trackseek, DL_INT (0, d_trkseek)); - trackskew = atoi (args[4]); - - /* These aren't used by the GNU ufs, so who cares? */ - headswitch = 0; - trackseek = 0; + DEFAULT (fsize, 1024); + DEFAULT (bsize, 8192); - fsize = 1024; - bsize = 8192; - - cpg = 16; - cpgflg = 0; - minfree = MINFREE; - opt = DEFAULTOPT ; - density = 4 * fsize; + DEFAULT (cpg, 16); + DEFAULT (cpgflg, 0); + DEFAULT (minfree, MINFREE); + DEFAULT (opt, DEFAULTOPT); + DEFAULT (density, 4 * fsize); /* maxcontig = MAX (1, MIN (MAXPHYS, MAXBSIZE) / bsize - 1); */ - maxcontig = 0; - rotdelay = 4; + DEFAULT (maxcontig, 0); + DEFAULT (rotdelay, 4); #define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) - maxbpg = MAXBLKPG (bsize); - nrpos = 8; + DEFAULT (maxbpg, MAXBLKPG (bsize)); + DEFAULT (nrpos, 8); + bbsize = BBSIZE; sbsize = SBSIZE; @@ -268,9 +431,8 @@ main (int argc, char **argv) exit (0); } - - - + +void mkfs(pp, fsys, fi, fo) struct partition *pp; char *fsys; @@ -281,34 +443,11 @@ mkfs(pp, fsys, fi, fo) long used, mincpgcnt, bpcg; long mapcramped, inodecramped; long postblsize, rotblsize, totalsbsize; - int ppid, status; time_t utime; quad_t sizepb; - void started(); #ifndef STANDALONE time(&utime); -#endif -#ifdef MFS - if (mfs) { - ppid = getpid(); - (void) signal(SIGUSR1, started); - if (i = fork()) { - if (i == -1) { - perror("mfs"); - exit(10); - } - if (waitpid(i, &status, 0) != -1 && WIFEXITED(status)) - exit(WEXITSTATUS(status)); - exit(11); - /* NOTREACHED */ - } - (void)malloc(0); - if (fssize * sectorsize > memleft) - fssize = (memleft - 16384) / sectorsize; - if ((membase = malloc(fssize * sectorsize)) == 0) - exit(12); - } #endif fsi = fi; fso = fo; @@ -332,36 +471,36 @@ mkfs(pp, fsys, fi, fo) sblock.fs_nsect = nsectors; sblock.fs_ntrak = ntracks; if (sblock.fs_ntrak <= 0) - printf("preposterous ntrak %d\n", sblock.fs_ntrak), exit(14); + printf("preposterous ntrak %ld\n", sblock.fs_ntrak), exit(14); if (sblock.fs_nsect <= 0) - printf("preposterous nsect %d\n", sblock.fs_nsect), exit(15); + printf("preposterous nsect %ld\n", sblock.fs_nsect), exit(15); /* * collect and verify the block and fragment sizes */ sblock.fs_bsize = bsize; sblock.fs_fsize = fsize; if (!POWEROF2(sblock.fs_bsize)) { - printf("block size must be a power of 2, not %d\n", + printf("block size must be a power of 2, not %ld\n", sblock.fs_bsize); exit(16); } if (!POWEROF2(sblock.fs_fsize)) { - printf("fragment size must be a power of 2, not %d\n", + printf("fragment size must be a power of 2, not %ld\n", sblock.fs_fsize); exit(17); } if (sblock.fs_fsize < sectorsize) { - printf("fragment size %d is too small, minimum is %d\n", + printf("fragment size %ld is too small, minimum is %d\n", sblock.fs_fsize, sectorsize); exit(18); } if (sblock.fs_bsize < MINBSIZE) { - printf("block size %d is too small, minimum is %d\n", + printf("block size %ld is too small, minimum is %d\n", sblock.fs_bsize, MINBSIZE); exit(19); } if (sblock.fs_bsize < sblock.fs_fsize) { - printf("block size (%d) cannot be smaller than fragment size (%d)\n", + printf("block size (%ld) cannot be smaller than fragment size (%ld)\n", sblock.fs_bsize, sblock.fs_fsize); exit(20); } @@ -377,7 +516,7 @@ mkfs(pp, fsys, fi, fo) for (sblock.fs_fragshift = 0, i = sblock.fs_frag; i > 1; i >>= 1) sblock.fs_fragshift++; if (sblock.fs_frag > MAXFRAG) { - printf("fragment size %d is too small, minimum with block size %d is %d\n", + printf("fragment size %ld is too small, minimum with block size %ld is %ld\n", sblock.fs_fsize, sblock.fs_bsize, sblock.fs_bsize / MAXFRAG); exit(21); @@ -470,7 +609,7 @@ mkfs(pp, fsys, fi, fo) if (mincpc == 1 || sblock.fs_frag == 1 || sblock.fs_bsize == MINBSIZE) break; - printf("With a block size of %d %s %d\n", sblock.fs_bsize, + printf("With a block size of %ld %s %ld\n", sblock.fs_bsize, "minimum bytes per inode is", (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); sblock.fs_bsize >>= 1; @@ -489,24 +628,24 @@ mkfs(pp, fsys, fi, fo) } if (inodecramped) { if (inospercg > MAXIPG(&sblock)) { - printf("Minimum bytes per inode is %d\n", + printf("Minimum bytes per inode is %ld\n", (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); } else if (!mapcramped) { printf("With %d bytes per inode, ", density); - printf("minimum cylinders per group is %d\n", mincpg); + printf("minimum cylinders per group is %ld\n", mincpg); } } if (mapcramped) { - printf("With %d sectors per cylinder, ", sblock.fs_spc); - printf("minimum cylinders per group is %d\n", mincpg); + printf("With %ld sectors per cylinder, ", sblock.fs_spc); + printf("minimum cylinders per group is %ld\n", mincpg); } if (inodecramped || mapcramped) { if (sblock.fs_bsize != bsize) - printf("%s to be changed from %d to %d\n", + printf("%s to be changed from %d to %ld\n", "This requires the block size", bsize, sblock.fs_bsize); if (sblock.fs_fsize != fsize) - printf("\t%s to be changed from %d to %d\n", + printf("\t%s to be changed from %d to %ld\n", "and the fragment size", fsize, sblock.fs_fsize); exit(23); @@ -516,7 +655,7 @@ mkfs(pp, fsys, fi, fo) */ sblock.fs_cpg = cpg; if (sblock.fs_cpg % mincpc != 0) { - printf("%s groups must have a multiple of %d cylinders\n", + printf("%s groups must have a multiple of %ld cylinders\n", cpgflg ? "Cylinder" : "Warning: cylinder", mincpc); sblock.fs_cpg = roundup(sblock.fs_cpg, mincpc); if (!cpgflg) @@ -548,7 +687,7 @@ mkfs(pp, fsys, fi, fo) exit(24); } if (sblock.fs_cpg < mincpg) { - printf("cylinder groups must have at least %d cylinders\n", + printf("cylinder groups must have at least %ld cylinders\n", mincpg); exit(25); } else if (sblock.fs_cpg != cpg) { @@ -562,7 +701,7 @@ mkfs(pp, fsys, fi, fo) printf("Block size restricts"); else printf("Bytes per inode restrict"); - printf(" cylinders per group to %d.\n", sblock.fs_cpg); + printf(" cylinders per group to %ld.\n", sblock.fs_cpg); if (cpgflg) exit(27); } @@ -619,7 +758,7 @@ mkfs(pp, fsys, fi, fo) } if (totalsbsize > SBSIZE || sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) { - printf("%s %s %d %s %d.%s", + printf("%s %s %ld %s %ld.%s", "Warning: insufficient space in super block for\n", "rotational layout tables with nsect", sblock.fs_nsect, "and ntrak", sblock.fs_ntrak, @@ -656,10 +795,10 @@ next: sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(&sblock); i = MIN(~sblock.fs_cgmask, sblock.fs_ncg - 1); if (cgdmin(&sblock, i) - cgbase(&sblock, i) >= sblock.fs_fpg) { - printf("inode blocks/cyl group (%d) >= data blocks (%d)\n", + printf("inode blocks/cyl group (%ld) >= data blocks (%ld)\n", cgdmin(&sblock, i) - cgbase(&sblock, i) / sblock.fs_frag, sblock.fs_fpg / sblock.fs_frag); - printf("number of cylinders per cylinder group (%d) %s.\n", + printf("number of cylinders per cylinder group (%ld) %s.\n", sblock.fs_cpg, "must be increased"); exit(29); } @@ -667,15 +806,15 @@ next: if ((i = fssize - j * sblock.fs_fpg) < sblock.fs_fpg && cgdmin(&sblock, j) - cgbase(&sblock, j) > i) { if (j == 0) { - printf("Filesystem must have at least %d sectors\n", + printf("Filesystem must have at least %ld sectors\n", NSPF(&sblock) * (cgdmin(&sblock, 0) + 3 * sblock.fs_frag)); exit(30); } - printf("Warning: inode blocks/cyl group (%d) >= data blocks (%d) in last\n", + printf("Warning: inode blocks/cyl group (%ld) >= data blocks (%ld) in last\n", (cgdmin(&sblock, j) - cgbase(&sblock, j)) / sblock.fs_frag, i / sblock.fs_frag); - printf(" cylinder group. This implies %d sector(s) cannot be allocated.\n", + printf(" cylinder group. This implies %ld sector(s) cannot be allocated.\n", i * NSPF(&sblock)); sblock.fs_ncg--; sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; @@ -683,12 +822,8 @@ next: NSPF(&sblock); warn = 0; } - if (warn -#ifdef MFS - && !mfs -#endif - ) { - printf("Warning: %d sector(s) in last cylinder unallocated\n", + if (warn) { + printf("Warning: %ld sector(s) in last cylinder unallocated\n", sblock.fs_spc - (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) * sblock.fs_spc)); @@ -720,51 +855,34 @@ next: sblock.fs_cstotal.cs_nffree = 0; sblock.fs_fmod = 0; sblock.fs_ronly = 0; + /* * Dump out summary information about file system. */ -#ifdef MFS - if (!mfs) -#endif - { - printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", - fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, - "cylinders", sblock.fs_ntrak, sblock.fs_nsect); + printf("%s:\t%ld sectors in %ld %s of %ld tracks, %ld sectors\n", + fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, + "cylinders", sblock.fs_ntrak, sblock.fs_nsect); #define B2MBFACTOR (1 / (1024.0 * 1024.0)) - printf("\t%.1fMB in %d cyl groups (%d c/g, %.2fMB/g, %d i/g)\n", - (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, - sblock.fs_ncg, sblock.fs_cpg, - (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR, - sblock.fs_ipg); + printf("\t%.1fMB in %ld cyl groups (%ld c/g, %.2fMB/g, %ld i/g)\n", + (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, + sblock.fs_ncg, sblock.fs_cpg, + (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR, + sblock.fs_ipg); #undef B2MBFACTOR - } + /* * Now build the cylinders group blocks and * then print out indices of cylinder groups. */ -#ifdef MFS - if (!mfs) -#endif - printf("super-block backups (for fsck -b #) at:"); + printf("super-block backups (for fsck -b #) at:"); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); -#ifdef MFS - if (mfs) - continue; -#endif if (cylno % 8 == 0) printf("\n"); - printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); + printf(" %ld,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); } -#ifdef MFS - if (!mfs) -#endif - printf("\n"); - if (Nflag -#ifdef MFS - && !mfs -#endif - ) + printf("\n"); + if (Nflag) exit(0); /* * Now construct the initial file system, @@ -793,32 +911,19 @@ next: pp->p_fsize = sblock.fs_fsize; pp->p_frag = sblock.fs_frag; pp->p_cpg = sblock.fs_cpg; -#endif - /* - * Notify parent process of success. - * Dissociate from session and tty. - */ -#ifdef MFS - if (mfs) { - kill(ppid, SIGUSR1); - (void) setsid(); - (void) close(0); - (void) close(1); - (void) close(2); - (void) chdir("/"); - } #endif } - + /* * Initialize a cylinder group. */ +void initcg(cylno, utime) int cylno; time_t utime; { + long i; daddr_t cbase, d, dlower, dupper, dmax, blkno; - long i, j, s; register struct csum *cs; /* @@ -897,7 +1002,8 @@ initcg(cylno, utime) sblock.fs_dsize += dlower; } sblock.fs_dsize += acg.cg_ndblk - dupper; - if (i = dupper % sblock.fs_frag) { + i = dupper % sblock.fs_frag; + if (i) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { setbit(cg_blksfree(&acg), dupper); @@ -959,7 +1065,7 @@ initcg(cylno, utime) wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), sblock.fs_bsize, (char *)&acg); } - + /* * initialize the file system */ @@ -1004,11 +1110,10 @@ struct odirectory_entry olost_found_dir[] = { #endif char buf[MAXBSIZE]; +void fsinit(utime) time_t utime; { - int i; - /* * initialize the node */ @@ -1042,12 +1147,7 @@ fsinit(utime) /* * create the root directory */ -#ifdef MFS - if (mfs) - node.di_model = IFDIR | 01777; - else -#endif - node.di_model = IFDIR | UMASK; + node.di_model = IFDIR | UMASK; node.di_modeh = 0; node.di_nlink = PREDEFDIR; if (Oflag) @@ -1064,6 +1164,7 @@ fsinit(utime) * construct a set of directory entries in "buf". * return size of directory. */ +int makedir(protodir, entries) register struct directory_entry *protodir; int entries; @@ -1141,6 +1242,7 @@ goth: /* * Allocate an inode on the disk */ +void iput(ip, ino) register struct dinode *ip; register ino_t ino; @@ -1172,106 +1274,16 @@ iput(ip, ino) wtfs(d, sblock.fs_bsize, buf); } -/* - * Notify parent process that the filesystem has created itself successfully. - */ -void -started() -{ - - exit(0); -} - -/* - * Replace libc function with one suited to our needs. - */ -caddr_t -malloc(size) - register u_long size; -{ - char *base, *i; - static u_long pgsz; - struct rlimit rlp; - - if (pgsz == 0) { - base = sbrk(0); - pgsz = getpagesize() - 1; - i = (char *)((u_long)(base + pgsz) &~ pgsz); - base = sbrk(i - base); - if (getrlimit(RLIMIT_DATA, &rlp) < 0) - perror("getrlimit"); - rlp.rlim_cur = rlp.rlim_max; - if (setrlimit(RLIMIT_DATA, &rlp) < 0) - perror("setrlimit"); - memleft = rlp.rlim_max - (u_long)base; - } - size = (size + pgsz) &~ pgsz; - if (size > memleft) - size = memleft; - memleft -= size; - if (size == 0) - return (0); - return ((caddr_t)sbrk(size)); -} - -/* - * Replace libc function with one suited to our needs. - */ -caddr_t -realloc(ptr, size) - char *ptr; - u_long size; -{ - void *p; - - if ((p = malloc(size)) == NULL) - return (NULL); - bcopy(ptr, p, size); - free(ptr); - return (p); -} - -/* - * Replace libc function with one suited to our needs. - */ -char * -calloc(size, numelm) - u_long size, numelm; -{ - caddr_t base; - - size *= numelm; - base = malloc(size); - bzero(base, size); - return (base); -} - -/* - * Replace libc function with one suited to our needs. - */ -free(ptr) - char *ptr; -{ - - /* do not worry about it for now */ -} - /* * read a block from the file system */ +void rdfs(bno, size, bf) daddr_t bno; int size; char *bf; { int n; - -#ifdef MFS - if (mfs) { - bcopy(membase + bno * sectorsize, bf, size); - return; - } -#endif if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) { printf("seek error: %ld\n", bno); perror("rdfs"); @@ -1288,19 +1300,13 @@ rdfs(bno, size, bf) /* * write a block to the file system */ +void wtfs(bno, size, bf) daddr_t bno; int size; char *bf; { int n; - -#ifdef MFS - if (mfs) { - bcopy(bf, membase + bno * sectorsize, size); - return; - } -#endif if (Nflag) return; if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) { @@ -1319,6 +1325,7 @@ wtfs(bno, size, bf) /* * check if a block is available */ +int isblock(fs, cp, h) struct fs *fs; unsigned char *cp; @@ -1340,9 +1347,9 @@ isblock(fs, cp, h) return ((cp[h >> 3] & mask) == mask); default: #ifdef STANDALONE - printf("isblock bad fs_frag %d\n", fs->fs_frag); + printf("isblock bad fs_frag %ld\n", fs->fs_frag); #else - fprintf(stderr, "isblock bad fs_frag %d\n", fs->fs_frag); + fprintf(stderr, "isblock bad fs_frag %ld\n", fs->fs_frag); #endif return (0); } @@ -1351,6 +1358,7 @@ isblock(fs, cp, h) /* * take a block out of the map */ +void clrblock(fs, cp, h) struct fs *fs; unsigned char *cp; @@ -1371,9 +1379,9 @@ clrblock(fs, cp, h) return; default: #ifdef STANDALONE - printf("clrblock bad fs_frag %d\n", fs->fs_frag); + printf("clrblock bad fs_frag %ld\n", fs->fs_frag); #else - fprintf(stderr, "clrblock bad fs_frag %d\n", fs->fs_frag); + fprintf(stderr, "clrblock bad fs_frag %ld\n", fs->fs_frag); #endif return; } @@ -1382,6 +1390,7 @@ clrblock(fs, cp, h) /* * put a block into the map */ +void setblock(fs, cp, h) struct fs *fs; unsigned char *cp; @@ -1402,9 +1411,9 @@ setblock(fs, cp, h) return; default: #ifdef STANDALONE - printf("setblock bad fs_frag %d\n", fs->fs_frag); + printf("setblock bad fs_frag %ld\n", fs->fs_frag); #else - fprintf(stderr, "setblock bad fs_frag %d\n", fs->fs_frag); + fprintf(stderr, "setblock bad fs_frag %ld\n", fs->fs_frag); #endif return; } -- cgit v1.2.3 From 77b32ea8095faf6ca609c6f95119214a55db0d10 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 18 Mar 1996 17:33:48 +0000 Subject: (diskfs_max_user_pager_prot) [add_pager_max_prot]: (a == b) ? 1 : 0 ====> (a == b). --- ufs/pager.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 695a006b..8834f911 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -646,8 +646,7 @@ diskfs_max_user_pager_prot () if (upi->type == FILE_DATA) max_prot |= upi->max_prot; /* Stop iterating if MAX_PROT is as filled as it's going to get. */ - return - (max_prot == (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)) ? 1 : 0; + return max_prot == (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); } block_caching (); /* Make any silly pagers go away. */ -- cgit v1.2.3 From 2c04bec0780eb08fe86dbc63e518a028a4404197 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 19 Mar 1996 00:49:04 +0000 Subject: (main): Pass new arg to argp_parse. Use argp_usage correctly. --- ufs-fsck/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index a2d4855c..869ad258 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -1,5 +1,5 @@ /* Main program for GNU fsck - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -58,7 +58,7 @@ main (int argc, char **argv) } /* Fall through */ case ARGP_KEY_NO_ARGS: - argp_help (state->argp, stderr, ARGP_HELP_STD_USAGE); /* exits */ + argp_usage (state); default: return EINVAL; } return 0; @@ -66,7 +66,7 @@ main (int argc, char **argv) struct argp argp = {options, parse_opt, args_doc}; preen = nowrite = noquery = 0; - argp_parse (&argp, argc, argv, 0, 0); + argp_parse (&argp, argc, argv, 0, 0, 0); if (!setup (device)) exit (1); -- cgit v1.2.3 From 2115f0d8dbbdbe1a85cf1e3c0fad75657d9d94a4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 19 Mar 1996 00:51:01 +0000 Subject: (main): Pass new arg to argp_parse. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index ea43acce..787cb749 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -62,7 +62,7 @@ main (int argc, char **argv) off_t disk_size; mach_port_t bootstrap; - argp_parse (diskfs_device_startup_argp, argc, argv, 0, 0); + argp_parse (diskfs_device_startup_argp, argc, argv, 0, 0, 0); /* This must come after the args have been parsed, as this is where the host priv ports are set for booting. */ -- cgit v1.2.3 From e802372ce7210fe006b9207f810bc274d3dd9ff3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Mar 1996 19:36:27 +0000 Subject: (diskfs_dirrewrite_hard): Renamed from diskfs_dirrewrite. No longer call modification tracking routines. (diskfs_dirremove_hard): Renamed from diskfs_dirremove. No longer call modification tracking routines. (diskfs_direnter_hard): Renamed from diskfs_direnter. No longer call modification tracking routines. (diskfs_lookup_hard): Renamed from diskfs_lookup. --- ufs/dir.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index b2147007..16364071 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994, 1995 Free Software Foundation + Copyright (C) 1994, 1995, 1996 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 @@ -89,8 +89,8 @@ dirscanblock (vm_address_t blockoff, struct node *dp, int idx, char *name, /* Implement the diskfs_lookup from the diskfs library. See for the interface specification. */ error_t -diskfs_lookup (struct node *dp, char *name, enum lookup_type type, - struct node **npp, struct dirstat *ds, struct protid *cred) +diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, + struct node **npp, struct dirstat *ds, struct protid *cred) { error_t err; ino_t inum; @@ -458,11 +458,11 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, only be made if the directory has been held locked continuously since the preceding lookup call, and only if that call returned ENOENT. */ error_t -diskfs_direnter(struct node *dp, - char *name, - struct node *np, - struct dirstat *ds, - struct protid *cred) +diskfs_direnter_hard(struct node *dp, + char *name, + struct node *np, + struct dirstat *ds, + struct protid *cred) { struct directory_entry *new; int namelen = strlen (name); @@ -608,9 +608,6 @@ diskfs_direnter(struct node *dp, diskfs_file_update (dp, 1); - if (dp->dirmod_reqs) - diskfs_notice_dirchange (dp, DIR_CHANGED_NEW, name); - return 0; } @@ -620,8 +617,8 @@ diskfs_direnter(struct node *dp, directory has been locked continously since the call to lookup, and only if that call succeeded. */ error_t -diskfs_dirremove(struct node *dp, - struct dirstat *ds) +diskfs_dirremove_hard(struct node *dp, + struct dirstat *ds) { assert (ds->type == REMOVE); assert (ds->stat == HERE_TIS); @@ -644,9 +641,6 @@ diskfs_dirremove(struct node *dp, diskfs_file_update (dp, 1); - if (dp->dirmod_reqs) - diskfs_notice_dirchange (dp, DIR_CHANGED_UNLINK, ds->entry->d_name); - return 0; } @@ -658,9 +652,9 @@ diskfs_dirremove(struct node *dp, continuously since the call to lookup, and only if that call succeeded. */ error_t -diskfs_dirrewrite(struct node *dp, - struct node *np, - struct dirstat *ds) +diskfs_dirrewrite_hard(struct node *dp, + struct node *np, + struct dirstat *ds) { assert (ds->type == RENAME); assert (ds->stat == HERE_TIS); @@ -673,9 +667,6 @@ diskfs_dirrewrite(struct node *dp, diskfs_file_update (dp, 1); - if (dp->dirmod_reqs) - diskfs_notice_dirchange (dp, DIR_CHANGED_RENUMBER, ds->entry->d_name); - return 0; } -- cgit v1.2.3 From a14a84d7bfba8c138367a433cc6f562895ce5b54 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Mar 1996 21:02:17 +0000 Subject: (diskfs_lookup_hard): Don't do initial permission checking here. --- ufs/dir.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 16364071..73ed5f02 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -120,12 +120,6 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, if (namelen > MAXNAMLEN) return ENAMETOOLONG; - if (!S_ISDIR (dp->dn_stat.st_mode)) - return ENOTDIR; - err = diskfs_access (dp, S_IEXEC, cred); - if (err) - return err; - try_again: if (ds) { -- cgit v1.2.3 From 4591952861c94f2ae928ac560753b14283aac365 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Mar 1996 21:13:17 +0000 Subject: (diskfs_lookup_hard): Don't do final permission checking here. --- ufs/dir.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 73ed5f02..843735c2 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -238,16 +238,6 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, assert (0); } - /* If we will be modifying the directory, make sure it's allowed. */ - if (type == RENAME - || (type == REMOVE && inum) - || (type == CREATE && !inum)) - { - err = diskfs_checkdirmod (dp, np, cred); - if (err) - goto out; - } - if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING) { /* We didn't find any room, so mark ds to extend the dir */ -- cgit v1.2.3 From 4046ebcfba13acea67b27e2ecdcd217e6dca80c5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 23 Mar 1996 04:45:02 +0000 Subject: (read_symlink_hook): Only set NP's atime if !readonly. --- ufs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 08438e70..81fc8f75 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994, 1995 Free Software Foundation + Copyright (C) 1994, 1995, 1996 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 @@ -411,7 +411,9 @@ read_symlink_hook (struct node *np, return err; bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); - np->dn_set_atime = 1; + + if (! diskfs_readonly) + np->dn_set_atime = 1; diskfs_end_catch_exception (); return 0; -- cgit v1.2.3 From 669a5d218f78fe4761528a0208915b53c97b8f28 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 25 Mar 1996 08:09:03 +0000 Subject: After CC tool check, invoke AC_PROG_CC to set default CFLAGS and test for GCC. Barf if not GCC. --- configure.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 7603efca..dc5039d4 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.2 1995/09/21 23:07:35 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.3 1996/03/25 08:09:03 roland Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -12,7 +12,16 @@ gnu*) ;; esac AC_PROG_INSTALL + AC_CHECK_TOOL(CC, gcc) +# That check handles cross-compilation well, but AC_PROG_CC tests for GCC +# and sets default CFLAGS nicely for us, so do that too. +AC_PROG_CC +# Require GCC. +if test x$GCC != xyes; then + AC_MSG_ERROR([this code uses GNU C extensions, you must compile with GCC]) +fi + AC_CHECK_TOOL(LD, ld) AC_CHECK_TOOL(OBJCOPY, objcopy) AC_CHECK_TOOL(AR, ar) -- cgit v1.2.3 From 612d539a3edb9ab67412c0df900dd459da8525de Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 25 Mar 1996 18:08:16 +0000 Subject: (diskfs_null_dirstat): New function. --- ufs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ufs/dir.c b/ufs/dir.c index 843735c2..8fb2b39b 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -81,6 +81,14 @@ struct dirstat size_t diskfs_dirstat_size = sizeof (struct dirstat); +/* The user must define this function. Initialize DS such that + diskfs_drop_dirstat will ignore it. */ +void +diskfs_null_dirstat (struct dirstat *ds) +{ + ds->type = LOOKUP; +} + static error_t dirscanblock (vm_address_t blockoff, struct node *dp, int idx, char *name, int namelen, enum lookup_type type, struct dirstat *ds, -- cgit v1.2.3 From 2eb9f242fcddff34edf23c1dac966da7d2dda419 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 25 Mar 1996 18:08:40 +0000 Subject: (diskfs_null_dirstat): doc fix --- ufs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 8fb2b39b..e5c2e6e2 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -81,8 +81,7 @@ struct dirstat size_t diskfs_dirstat_size = sizeof (struct dirstat); -/* The user must define this function. Initialize DS such that - diskfs_drop_dirstat will ignore it. */ +/* Initialize DS such that diskfs_drop_dirstat will ignore it. */ void diskfs_null_dirstat (struct dirstat *ds) { -- cgit v1.2.3 From 6bdbc43fad9268b931b3262e15c6de50266f3c71 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 29 Mar 1996 17:23:49 +0000 Subject: (main): Print mode & {in,}direct blocks too. (mode_rep): New function. (timespec_rep): P shouldn't be static. --- ufs-utils/stati.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/ufs-utils/stati.c b/ufs-utils/stati.c index ca980ecd..bc3f2a14 100644 --- a/ufs-utils/stati.c +++ b/ufs-utils/stati.c @@ -51,6 +51,7 @@ static char sccsid[] __attribute__ ((unused)); #include #include +#include #include "../ufs/dinode.h" #include "../ufs/fs.h" @@ -67,11 +68,48 @@ static char sccsid[] __attribute__ ((unused)); #define MAXPHYS (64 * 1024) #define DEV_BSIZE 512 +/* Returns a nice representation of a file mode in a static buffer. */ +static char * +mode_rep (unsigned short mode) +{ + static char buf[30]; + char *p = buf; + + void add_perms (int shift, unsigned sid_mask) + { + unsigned short smode = mode << shift; + *p++ = (smode & S_IREAD) ? 'r' : '-'; + *p++ = (smode & S_IWRITE) ? 'w' : '-'; + *p++ = (smode & S_IEXEC) ? ((mode & sid_mask) ? 's' : 'x') : '-'; + } + + switch (mode & S_IFMT) + { + case S_IFREG: *p++ = '-'; break; + case S_IFDIR: *p++ = 'd'; break; + case S_IFCHR: *p++ = 'c'; break; + case S_IFBLK: *p++ = 'b'; break; + case S_IFLNK: *p++ = 'l'; break; + case S_IFSOCK:*p++ = 'p'; break; + case S_IFIFO: *p++ = 'f'; break; + default: *p++ = '?'; + } + + add_perms (0, S_ISUID); + add_perms (3, S_ISGID); + add_perms (6, 0); + + snprintf (p, buf + sizeof buf - p, " [%0o]", mode); + + return buf; +} + /* Returns a nice representation of a struct timespec in a static buffer. */ static char * timespec_rep (struct timespec *ts) { - static char buf[200], *p = buf; + static char buf[200]; + char *p = buf; if (ts->ts_sec || ts->ts_nsec) { time_t time = ts->ts_sec; @@ -79,7 +117,6 @@ timespec_rep (struct timespec *ts) p += strlen (buf); if (p[-1] == '\n') p--; - *p++ = ';'; *p++ = ' '; } snprintf (p, buf + sizeof buf - p, "[%ld, %ld]", ts->ts_sec, ts->ts_nsec); @@ -161,6 +198,8 @@ main(argc, argv) /* remaining arguments are inode numbers. */ while (*++argv) { + int i; + /* get the inode number. */ if ((inonum = atoi(*argv)) <= 0) { (void)fprintf(stderr, @@ -191,6 +230,7 @@ main(argc, argv) if (argc > 3) printf ("inode: %d\n", inonum); + printf ("mode: %s\n", mode_rep (ip->di_model)); printf ("nlink: %d\n", ip->di_nlink); printf ("size: %qd\n", ip->di_size); printf ("atime: %s\n", timespec_rep (&ip->di_atime)); @@ -201,6 +241,14 @@ main(argc, argv) printf ("gener: %ld\n", ip->di_gen); printf ("uid: %s\n", uid_rep (ip->di_uid)); printf ("gid: %s\n", gid_rep (ip->di_gid)); + printf ("dblks: "); + for (i = 0; i < NDADDR; i++) + printf ("%s%ld", (i == 0 ? "" : ", "), ip->di_db[i]); + putchar ('\n'); + printf ("iblks: "); + for (i = 0; i < NIADDR; i++) + printf ("%s%ld", (i == 0 ? "" : ", "), ip->di_ib[i]); + putchar ('\n'); printf ("trans: %ld\n", ip->di_trans); if (argv[1]) -- cgit v1.2.3 From 80cab6b2b790ea93fc76253fe73ebc3dca549e68 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 29 Mar 1996 17:24:11 +0000 Subject: (main): Argp interface changes. --- ufs-utils/mkfs.c | 360 +++++++++++++++++++++++++------------------------------ 1 file changed, 165 insertions(+), 195 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 4d0d4ab9..f8668277 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.8 1996/03/13 23:47:12 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.9 1996/03/29 17:24:11 miles Exp $"; #endif /* not lint */ #include @@ -251,11 +251,15 @@ static const struct disklabel default_disklabel = { d_trkseek: 0, }; +char *device = 0; + +#define deverr(code, err, fmt, args...) \ + error (code, err, "%s: " fmt, device , ##args) + void main (int argc, char **argv) { int fdo, fdi; - char *device = 0; struct amark *uparams = 0; error_t label_err = 0; struct disklabel label_buf, *label = 0; @@ -276,7 +280,7 @@ main (int argc, char **argv) case 'a': UP_INT (maxcontig); break; case 'b': UP_INT (bsize); break; - case 'c': UP_INT (cpg); break; + case 'c': UP_INT (cpg); cpgflg = 1; break; case 'd': UP_INT (rotdelay); break; case 'e': UP_INT (maxbpg); break; case 'f': UP_INT (fsize); break; @@ -300,8 +304,7 @@ main (int argc, char **argv) else if (strcmp (arg, "space") == 0) opt = FS_OPTSPACE; else - argp_error (state->argp, - "%s: Invalid value for --optimization", arg); + argp_error (state, "%s: Invalid value for --optimization", arg); break; case ARGP_KEY_ARG: @@ -354,14 +357,14 @@ main (int argc, char **argv) int val = dl_int (param_name, offs); int dl_ss = DL_INT (0, d_secsize); if (sectorsize < dl_ss) - error (10, 0, - "%s: %d: Sector size is less than device sector size (%d)", - device, sectorsize, dl_ss); + deverr (10, 0, + "%d: Sector size is less than device sector size (%d)", + sectorsize, dl_ss); else if (sectorsize > dl_ss) if (sectorsize % dl_ss != 0) - error (11, 0, - "%s: %d: Sector size not a multiple of device sector size (%d)", - device, sectorsize, dl_ss); + deverr (11, 0, + "%d: Sector size not a multiple of device sector size (%d)", + sectorsize, dl_ss); else val /= sectorsize / dl_ss; return val; @@ -371,7 +374,7 @@ main (int argc, char **argv) dl_secs (param_name, offsetof (struct disklabel, field)) /* Parse our arguments. */ - argp_parse (&argp, argc, argv, 0, 0); + argp_parse (&argp, argc, argv, 0, 0, 0); fdi = open (device, O_RDONLY); if (fdi == -1) @@ -388,7 +391,7 @@ main (int argc, char **argv) DEFAULT (fssize, ({ struct stat st; if (fstat (fdi, &st) == -1) - error (4, errno, "%s: Cannot get size", device); + deverr (4, errno, "Cannot get size"); st.st_size / sectorsize; })); DEFAULT (ntracks, DL_INT ("tracks", d_ntracks)); DEFAULT (nsectors, DL_SECS ("sectors", d_nsectors)); @@ -396,9 +399,9 @@ main (int argc, char **argv) DEFAULT (ncspares, DL_SECS (0, d_sparespercyl)); if (nspares >= nsectors) - error (5, 0, "%d: Too many spare sectors per track", nspares); + deverr (5, 0, "%d: Too many spare sectors per track", nspares); if (ncspares >= nsectors) - error (5, 0, "%d: Too many spare sectors per cylinder", ncspares); + deverr (5, 0, "%d: Too many spare sectors per cylinder", ncspares); nphyssectors = nsectors + nspares; secpercyl = nsectors * ntracks; @@ -413,7 +416,6 @@ main (int argc, char **argv) DEFAULT (bsize, 8192); DEFAULT (cpg, 16); - DEFAULT (cpgflg, 0); DEFAULT (minfree, MINFREE); DEFAULT (opt, DEFAULTOPT); DEFAULT (density, 4 * fsize); @@ -463,7 +465,7 @@ mkfs(pp, fsys, fi, fo) * Verify that its last block can actually be accessed. */ if (fssize <= 0) - printf("preposterous size %d\n", fssize), exit(13); + deverr (13, 0, "preposterous size %d", fssize); wtfs(fssize - 1, sectorsize, (char *)&sblock); /* * collect and verify the sector and track info @@ -471,39 +473,34 @@ mkfs(pp, fsys, fi, fo) sblock.fs_nsect = nsectors; sblock.fs_ntrak = ntracks; if (sblock.fs_ntrak <= 0) - printf("preposterous ntrak %ld\n", sblock.fs_ntrak), exit(14); + deverr (14, 0, "preposterous ntrak %ld", sblock.fs_ntrak); if (sblock.fs_nsect <= 0) - printf("preposterous nsect %ld\n", sblock.fs_nsect), exit(15); + deverr (15, 0, "preposterous nsect %ld", sblock.fs_nsect); /* * collect and verify the block and fragment sizes */ sblock.fs_bsize = bsize; sblock.fs_fsize = fsize; - if (!POWEROF2(sblock.fs_bsize)) { - printf("block size must be a power of 2, not %ld\n", - sblock.fs_bsize); - exit(16); - } - if (!POWEROF2(sblock.fs_fsize)) { - printf("fragment size must be a power of 2, not %ld\n", - sblock.fs_fsize); - exit(17); - } - if (sblock.fs_fsize < sectorsize) { - printf("fragment size %ld is too small, minimum is %d\n", - sblock.fs_fsize, sectorsize); - exit(18); - } - if (sblock.fs_bsize < MINBSIZE) { - printf("block size %ld is too small, minimum is %d\n", - sblock.fs_bsize, MINBSIZE); - exit(19); - } - if (sblock.fs_bsize < sblock.fs_fsize) { - printf("block size (%ld) cannot be smaller than fragment size (%ld)\n", - sblock.fs_bsize, sblock.fs_fsize); - exit(20); - } + if (!POWEROF2(sblock.fs_bsize)) + deverr (16, 0, + "block size must be a power of 2, not %ld", + sblock.fs_bsize); + if (!POWEROF2(sblock.fs_fsize)) + deverr (17, 0, + "fragment size must be a power of 2, not %ld", + sblock.fs_fsize); + if (sblock.fs_fsize < sectorsize) + deverr (18, 0, + "fragment size %ld is too small, minimum is %d", + sblock.fs_fsize, sectorsize); + if (sblock.fs_bsize < MINBSIZE) + deverr (19, 0, + "block size %ld is too small, minimum is %d", + sblock.fs_bsize, MINBSIZE); + if (sblock.fs_bsize < sblock.fs_fsize) + deverr (20, 0, + "block size (%ld) cannot be smaller than fragment size (%ld)", + sblock.fs_bsize, sblock.fs_fsize); sblock.fs_bmask = ~(sblock.fs_bsize - 1); sblock.fs_fmask = ~(sblock.fs_fsize - 1); sblock.fs_qbmask = ~sblock.fs_bmask; @@ -515,12 +512,11 @@ mkfs(pp, fsys, fi, fo) sblock.fs_frag = numfrags(&sblock, sblock.fs_bsize); for (sblock.fs_fragshift = 0, i = sblock.fs_frag; i > 1; i >>= 1) sblock.fs_fragshift++; - if (sblock.fs_frag > MAXFRAG) { - printf("fragment size %ld is too small, minimum with block size %ld is %ld\n", - sblock.fs_fsize, sblock.fs_bsize, - sblock.fs_bsize / MAXFRAG); - exit(21); - } + if (sblock.fs_frag > MAXFRAG) + deverr (21, 0, + "fragment size %ld is too small, minimum with block size %ld is %ld", + sblock.fs_fsize, sblock.fs_bsize, + sblock.fs_bsize / MAXFRAG); sblock.fs_nrpos = nrpos; sblock.fs_nindir = sblock.fs_bsize / sizeof(daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct dinode); @@ -587,11 +583,9 @@ mkfs(pp, fsys, fi, fo) if (sblock.fs_frag <= MAXFRAG) continue; } - if (sblock.fs_fsize == sblock.fs_bsize) { - printf("There is no block size that"); - printf(" can support this disk\n"); - exit(22); - } + if (sblock.fs_fsize == sblock.fs_bsize) + deverr (22, 0, + "There is no block size that can support this disk"); sblock.fs_frag >>= 1; sblock.fs_fragshift -= 1; sblock.fs_fsize <<= 1; @@ -609,9 +603,10 @@ mkfs(pp, fsys, fi, fo) if (mincpc == 1 || sblock.fs_frag == 1 || sblock.fs_bsize == MINBSIZE) break; - printf("With a block size of %ld %s %ld\n", sblock.fs_bsize, - "minimum bytes per inode is", - (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); + deverr (0, 0, + "With a block size of %ld %s %ld", sblock.fs_bsize, + "minimum bytes per inode is", + (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); sblock.fs_bsize >>= 1; sblock.fs_frag >>= 1; sblock.fs_fragshift -= 1; @@ -627,36 +622,40 @@ mkfs(pp, fsys, fi, fo) sblock.fs_ipg = inospercg; } if (inodecramped) { - if (inospercg > MAXIPG(&sblock)) { - printf("Minimum bytes per inode is %ld\n", - (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); - } else if (!mapcramped) { - printf("With %d bytes per inode, ", density); - printf("minimum cylinders per group is %ld\n", mincpg); - } - } - if (mapcramped) { - printf("With %ld sectors per cylinder, ", sblock.fs_spc); - printf("minimum cylinders per group is %ld\n", mincpg); - } - if (inodecramped || mapcramped) { - if (sblock.fs_bsize != bsize) - printf("%s to be changed from %d to %ld\n", - "This requires the block size", - bsize, sblock.fs_bsize); - if (sblock.fs_fsize != fsize) - printf("\t%s to be changed from %d to %ld\n", - "and the fragment size", - fsize, sblock.fs_fsize); - exit(23); + if (inospercg > MAXIPG(&sblock)) + deverr (0, 0, "Minimum bytes per inode is %ld", + (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); + else if (!mapcramped) + deverr (0, 0, + "With %d bytes per inode," + " minimum cylinders per group is %ld", + density, mincpg); } + if (mapcramped) + deverr (0, 0, + "With %ld sectors per cylinder," + " minimum cylinders per group is %ld", + sblock.fs_spc, mincpg); + if (inodecramped || mapcramped) + if (sblock.fs_bsize != bsize) + { + deverr (0, 0, + "This requires the block size to be changed from %d to %ld", + bsize, sblock.fs_bsize); + deverr (23, 0, + "and the fragment size to be changed from %d to %ld", + fsize, sblock.fs_fsize); + } + else + exit(23); /* * Calculate the number of cylinders per group */ sblock.fs_cpg = cpg; if (sblock.fs_cpg % mincpc != 0) { - printf("%s groups must have a multiple of %ld cylinders\n", - cpgflg ? "Cylinder" : "Warning: cylinder", mincpc); + deverr (0, 0, + "%s groups must have a multiple of %ld cylinders", + cpgflg ? "Cylinder" : "Warning: cylinder", mincpc); sblock.fs_cpg = roundup(sblock.fs_cpg, mincpc); if (!cpgflg) cpg = sblock.fs_cpg; @@ -682,29 +681,26 @@ mkfs(pp, fsys, fi, fo) INOPB(&sblock)); } sblock.fs_fpg = (sblock.fs_cpg * sblock.fs_spc) / NSPF(&sblock); - if ((sblock.fs_cpg * sblock.fs_spc) % NSPB(&sblock) != 0) { - printf("panic (fs_cpg * fs_spc) %% NSPF != 0"); - exit(24); - } - if (sblock.fs_cpg < mincpg) { - printf("cylinder groups must have at least %ld cylinders\n", - mincpg); - exit(25); - } else if (sblock.fs_cpg != cpg) { - if (!cpgflg) - printf("Warning: "); - else if (!mapcramped && !inodecramped) - exit(26); - if (mapcramped && inodecramped) - printf("Block size and bytes per inode restrict"); - else if (mapcramped) - printf("Block size restricts"); - else - printf("Bytes per inode restrict"); - printf(" cylinders per group to %ld.\n", sblock.fs_cpg); - if (cpgflg) - exit(27); - } + if ((sblock.fs_cpg * sblock.fs_spc) % NSPB(&sblock) != 0) + deverr (24, 0, "panic (fs_cpg * fs_spc) %% NSPF != 0"); + if (sblock.fs_cpg < mincpg) + deverr (25, 0, + "cylinder groups must have at least %ld cylinders", mincpg); + else if (sblock.fs_cpg != cpg) + { + if (cpgflg && !mapcramped && !inodecramped) + exit(26); + deverr (0, 0, + "%s%s cylinders per group to %ld", + (cpgflg ? "" : "Warning: "), + ((mapcramped && inodecramped) + ? "Block size and bytes per inode restrict" + : mapcramped ? "Block size restricts" + : "Bytes per inode restrict"), + sblock.fs_cpg); + if (cpgflg) + exit(27); + } sblock.fs_cgsize = fragroundup(&sblock, CGSIZE(&sblock)); /* * Now have size for file system and nsect and ntrak. @@ -716,10 +712,8 @@ mkfs(pp, fsys, fi, fo) sblock.fs_ncyl++; warn = 1; } - if (sblock.fs_ncyl < 1) { - printf("file systems must have at least one cylinder\n"); - exit(28); - } + if (sblock.fs_ncyl < 1) + deverr (28, 0, "file systems must have at least one cylinder"); /* * Determine feasability/values of rotational layout tables. * @@ -757,15 +751,16 @@ mkfs(pp, fsys, fi, fo) totalsbsize += postblsize; } if (totalsbsize > SBSIZE || - sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) { - printf("%s %s %ld %s %ld.%s", - "Warning: insufficient space in super block for\n", - "rotational layout tables with nsect", sblock.fs_nsect, - "and ntrak", sblock.fs_ntrak, - "\nFile system performance may be impaired.\n"); - sblock.fs_cpc = 0; - goto next; - } + sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) + { + deverr (0, 0, + "Warning: insufficient space in super block for " + "rotational layout tables with nsect %ld and ntrak %ld", + sblock.fs_nsect, sblock.fs_ntrak); + deverr (0, 0, "File system performance may be impaired"); + sblock.fs_cpc = 0; + goto next; + } sblock.fs_sbsize = fragroundup(&sblock, totalsbsize); /* * calculate the available blocks for each rotational position @@ -794,40 +789,45 @@ next: sblock.fs_ncg++; sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(&sblock); i = MIN(~sblock.fs_cgmask, sblock.fs_ncg - 1); - if (cgdmin(&sblock, i) - cgbase(&sblock, i) >= sblock.fs_fpg) { - printf("inode blocks/cyl group (%ld) >= data blocks (%ld)\n", - cgdmin(&sblock, i) - cgbase(&sblock, i) / sblock.fs_frag, - sblock.fs_fpg / sblock.fs_frag); - printf("number of cylinders per cylinder group (%ld) %s.\n", - sblock.fs_cpg, "must be increased"); - exit(29); - } + if (cgdmin(&sblock, i) - cgbase(&sblock, i) >= sblock.fs_fpg) + { + deverr (0, 0, + "Inode blocks/cyl group (%ld) >= data blocks (%ld)", + cgdmin(&sblock, i) - cgbase(&sblock, i) / sblock.fs_frag, + sblock.fs_fpg / sblock.fs_frag); + deverr (29, 0, + "number of cylinders per cylinder group (%ld)" + " must be increased", sblock.fs_cpg); + } j = sblock.fs_ncg - 1; if ((i = fssize - j * sblock.fs_fpg) < sblock.fs_fpg && cgdmin(&sblock, j) - cgbase(&sblock, j) > i) { - if (j == 0) { - printf("Filesystem must have at least %ld sectors\n", - NSPF(&sblock) * - (cgdmin(&sblock, 0) + 3 * sblock.fs_frag)); - exit(30); - } - printf("Warning: inode blocks/cyl group (%ld) >= data blocks (%ld) in last\n", - (cgdmin(&sblock, j) - cgbase(&sblock, j)) / sblock.fs_frag, - i / sblock.fs_frag); - printf(" cylinder group. This implies %ld sector(s) cannot be allocated.\n", - i * NSPF(&sblock)); + if (j == 0) + deverr (30, 0, + "Filesystem must have at least %ld sectors", + NSPF(&sblock) + * (cgdmin(&sblock, 0) + 3 * sblock.fs_frag)); + deverr (0, 0, + "Warning: inode blocks/cyl group (%ld) >=" + " data blocks (%ld) in last cylinder group.", + ((cgdmin(&sblock, j) - cgbase(&sblock, j)) + / sblock.fs_frag), + i / sblock.fs_frag); + deverr (0, 0, + "This implies %ld sector(s) cannot be allocated", + i * NSPF(&sblock)); sblock.fs_ncg--; sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; sblock.fs_size = fssize = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); warn = 0; } - if (warn) { - printf("Warning: %ld sector(s) in last cylinder unallocated\n", - sblock.fs_spc - - (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) + if (warn) + deverr (0, 0, + "Warning: %ld sector(s) in last cylinder unallocated", + sblock.fs_spc + - (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) * sblock.fs_spc)); - } /* * fill in remaining fields of the super block */ @@ -859,7 +859,7 @@ next: /* * Dump out summary information about file system. */ - printf("%s:\t%ld sectors in %ld %s of %ld tracks, %ld sectors\n", + printf("%s:\n\t%ld sectors in %ld %s of %ld tracks, %ld sectors\n", fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, "cylinders", sblock.fs_ntrak, sblock.fs_nsect); #define B2MBFACTOR (1 / (1024.0 * 1024.0)) @@ -874,11 +874,11 @@ next: * Now build the cylinders group blocks and * then print out indices of cylinder groups. */ - printf("super-block backups (for fsck -b #) at:"); + printf(" super-block backups (for fsck -b #) at:"); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); if (cylno % 8 == 0) - printf("\n"); + printf("\n\t"); printf(" %ld,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); } printf("\n"); @@ -971,10 +971,8 @@ initcg(cylno, utime) acg.cg_nextfreeoff = acg.cg_clusteroff + howmany (sblock.fs_cpg * sblock.fs_spc / NSPB(&sblock), NBBY); } - if (acg.cg_nextfreeoff - (long)(&acg.cg_link) > sblock.fs_cgsize) { - printf("Panic: cylinder group too big\n"); - exit(37); - } + if (acg.cg_nextfreeoff - (long)(&acg.cg_link) > sblock.fs_cgsize) + deverr (37, 0, "Panic: cylinder group too big"); acg.cg_cs.cs_nifree += sblock.fs_ipg; if (cylno == 0) for (i = 0; i < ROOTINO; i++) { @@ -1198,17 +1196,17 @@ alloc(size, mode) rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, (char *)&acg); if (acg.cg_magic != CG_MAGIC) { - printf("cg 0: bad magic number\n"); + deverr (0, 0, "cg 0: bad magic number"); return (0); } if (acg.cg_cs.cs_nbfree == 0) { - printf("first cylinder group ran out of space\n"); + deverr (0, 0, "first cylinder group ran out of space"); return (0); } for (d = 0; d < acg.cg_ndblk; d += sblock.fs_frag) if (isblock(&sblock, cg_blksfree(&acg), d / sblock.fs_frag)) goto goth; - printf("internal error: can't find block in cyl 0\n"); + deverr (0, 0, "internal error: can't find block in cyl 0"); return (0); goth: blkno = fragstoblks(&sblock, d); @@ -1254,20 +1252,16 @@ iput(ip, ino) c = ino_to_cg(&sblock, ino); rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, (char *)&acg); - if (acg.cg_magic != CG_MAGIC) { - printf("cg 0: bad magic number\n"); - exit(31); - } + if (acg.cg_magic != CG_MAGIC) + deverr (31, 0, "cg 0: bad magic number"); acg.cg_cs.cs_nifree--; setbit(cg_inosused(&acg), ino); wtfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, (char *)&acg); sblock.fs_cstotal.cs_nifree--; fscs[0].cs_nifree--; - if (ino >= sblock.fs_ipg * sblock.fs_ncg) { - printf("fsinit: inode value out of range (%d).\n", ino); - exit(32); - } + if (ino >= sblock.fs_ipg * sblock.fs_ncg) + deverr (32, 0, "fsinit: inode value out of range (%d)", ino); d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino)); rdfs(d, sblock.fs_bsize, buf); buf[ino_to_fsbo(&sblock, ino)] = *ip; @@ -1284,17 +1278,11 @@ rdfs(bno, size, bf) char *bf; { int n; - if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) { - printf("seek error: %ld\n", bno); - perror("rdfs"); - exit(33); - } + if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) + deverr (33, errno, "rdfs: %ld: seek error", bno); n = read(fsi, bf, size); - if (n != size) { - printf("read error: %ld\n", bno); - perror("rdfs"); - exit(34); - } + if (n != size) + deverr (34, errno, "rdfs: %ld: read error", bno); } /* @@ -1309,17 +1297,11 @@ wtfs(bno, size, bf) int n; if (Nflag) return; - if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) { - printf("seek error: %ld\n", bno); - perror("wtfs"); - exit(35); - } + if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) + deverr (35, errno, "wtfs: %ld: seek error", bno); n = write(fso, bf, size); - if (n != size) { - printf("write error: %ld\n", bno); - perror("wtfs"); - exit(36); - } + if (n != size) + deverr (36, errno, "wtfs: %ld: write error", bno); } /* @@ -1346,11 +1328,7 @@ isblock(fs, cp, h) mask = 0x01 << (h & 0x7); return ((cp[h >> 3] & mask) == mask); default: -#ifdef STANDALONE - printf("isblock bad fs_frag %ld\n", fs->fs_frag); -#else - fprintf(stderr, "isblock bad fs_frag %ld\n", fs->fs_frag); -#endif + deverr (0, 0, "isblock bad fs_frag %ld", fs->fs_frag); return (0); } } @@ -1378,11 +1356,7 @@ clrblock(fs, cp, h) cp[h >> 3] &= ~(0x01 << (h & 0x7)); return; default: -#ifdef STANDALONE - printf("clrblock bad fs_frag %ld\n", fs->fs_frag); -#else - fprintf(stderr, "clrblock bad fs_frag %ld\n", fs->fs_frag); -#endif + deverr (0, 0, "clrblock bad fs_frag %ld", fs->fs_frag); return; } } @@ -1410,11 +1384,7 @@ setblock(fs, cp, h) cp[h >> 3] |= (0x01 << (h & 0x7)); return; default: -#ifdef STANDALONE - printf("setblock bad fs_frag %ld\n", fs->fs_frag); -#else - fprintf(stderr, "setblock bad fs_frag %ld\n", fs->fs_frag); -#endif + deverr (0, 0, "setblock bad fs_frag %ld", fs->fs_frag); return; } } -- cgit v1.2.3 From fd6a62408f06410d2b54426fa70bd4356dfea20c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 29 Mar 1996 21:52:25 +0000 Subject: (diskfs_truncate): Cast DI->di_shortlink to correct type before adding a character count to it. --- ufs/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 0ecc7d31..249b0ff9 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -61,7 +61,7 @@ diskfs_truncate (struct node *np, err = diskfs_catch_exception (); if (err) return err; - bzero (di->di_shortlink + length, np->dn_stat.st_size - length); + bzero ((char *)di->di_shortlink + length, np->dn_stat.st_size - length); diskfs_end_catch_exception (); np->dn_stat.st_size = length; np->dn_set_ctime = np->dn_set_mtime = 1; -- cgit v1.2.3 From 8cf285ca92fcc5b5ad8909831fab5ab4a1c236fd Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 31 Mar 1996 19:34:53 +0000 Subject: (mode_rep): Prefix octal number with `0'. --- ufs-utils/stati.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-utils/stati.c b/ufs-utils/stati.c index bc3f2a14..699d8f5c 100644 --- a/ufs-utils/stati.c +++ b/ufs-utils/stati.c @@ -99,7 +99,7 @@ mode_rep (unsigned short mode) add_perms (3, S_ISGID); add_perms (6, 0); - snprintf (p, buf + sizeof buf - p, " [%0o]", mode); + snprintf (p, buf + sizeof buf - p, " [0%0o]", mode); return buf; } -- cgit v1.2.3 From 3838ef64d516ab5e90ce6f0f2348c7aadcfcba9c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 2 Apr 1996 14:00:49 +0000 Subject: (pass1): Recognize inode type IFSOCK too. --- ufs-fsck/pass1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index f9ad9047..de9cce09 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -1,5 +1,5 @@ /* Pass one of GNU fsck -- count blocks and verify inodes - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -229,6 +229,7 @@ pass1 () break; case IFIFO: + case IFSOCK: ndb = 0; break; -- cgit v1.2.3 From 45851fae7b2f90ede1f1a1a462f9a29e103aad4c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 2 Apr 1996 14:02:25 +0000 Subject: (pass1): Print mode correctly in unknown file type case. --- ufs-fsck/pass1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index de9cce09..47738eef 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -271,7 +271,7 @@ pass1 () break; default: - pfatal ("UNKNOWN FILE TYPE I=%d (MODE=%uo)\n", + pfatal ("UNKNOWN FILE TYPE I=%d (MODE=%ol)\n", number, mode); if (reply ("CLEAR")) { -- cgit v1.2.3 From 7fe42b6346b8ea3189470088c20448b09aa03a60 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:03:46 +0000 Subject: (iget): Initialize NP->cache_id. --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 81fc8f75..9c1e1c7e 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -66,7 +66,7 @@ iget (ino_t inum, struct node **npp) dn = malloc (sizeof (struct disknode)); - dn->number = inum; + np->cache_id = dn->number = inum; dn->dirents = 0; rwlock_init (&dn->allocptrlock); -- cgit v1.2.3 From 4cd22ece29676a8581764de37c9be07e4b68d87f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:07:50 +0000 Subject: (diskfs_lookup_hard): --- ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index e5c2e6e2..0a109c0c 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -182,7 +182,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, } else { - err = iget (inum, &np); + err = diskfs_cached_lookup (inum, &np); if (err) goto out; } -- cgit v1.2.3 From 10a64e4de4c86ddc50b1e7e48cd61acf3b09f386 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:08:48 +0000 Subject: (warp_root): --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 787cb749..2173be01 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -34,7 +34,7 @@ static void warp_root (void) { error_t err; - err = iget (2, &diskfs_root_node); + err = diskfs_cached_lookup (2, &diskfs_root_node); assert (!err); mutex_unlock (&diskfs_root_node->lock); } -- cgit v1.2.3 From 85ae67dbee7e957c859144a1e09cba5a38275568 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:08:58 +0000 Subject: (diskfs_lookup_hard): --- ufs/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 0a109c0c..136b470f 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -196,7 +196,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, goto out; } - /* We can't just do iget, because we would then deadlock. + /* We can't just do diskfs_cached_lookup, because we would then deadlock. So we do this. Ick. */ else if (retry_dotdot) { @@ -207,7 +207,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, try *again*. */ diskfs_nput (np); mutex_unlock (&dp->lock); - err = iget (inum, &np); + err = diskfs_cached_lookup (inum, &np); mutex_lock (&dp->lock); if (err) goto out; @@ -222,7 +222,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, repeat the directory scan to see if this is still right. */ mutex_unlock (&dp->lock); - err = iget (inum, &np); + err = diskfs_cached_lookup (inum, &np); mutex_lock (&dp->lock); if (err) goto out; @@ -237,7 +237,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, else if (type == LOOKUP) { diskfs_nput (dp); - err = iget (inum, &np); + err = diskfs_cached_lookup (inum, &np); if (err) goto out; } @@ -289,7 +289,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, no new references, so we don't have anything to do */ ; else if (type == LOOKUP) - /* We did iget */ + /* We did diskfs_cached_lookup */ diskfs_nput (np); } else -- cgit v1.2.3 From 500050260d63d846228e3cfc38d45f7ab13eb2f0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:09:33 +0000 Subject: (diskfs_cached_lookup): Renamed from `iget'. All callers changed. --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 9c1e1c7e..ef0d9241 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -45,7 +45,7 @@ inode_init () /* Fetch inode INUM, set *NPP to the node structure; gain one user reference and lock the node. */ error_t -iget (ino_t inum, struct node **npp) +diskfs_cached_lookup (int inum, struct node **npp) { struct disknode *dn; struct node *np; -- cgit v1.2.3 From d4f032eb68dae4f9883a93d3a734c235dcd7ab56 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Apr 1996 21:10:07 +0000 Subject: *** empty log message *** --- ufs/ufs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 0f310d1b..ca186434 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -183,7 +183,6 @@ void get_hypermetadata (void); void copy_sblock (void); /* From inode.c: */ -error_t iget (ino_t ino, struct node **NP); struct node *ifind (ino_t ino); void inode_init (void); void write_all_disknodes (void); -- cgit v1.2.3 From ab100791b595a0f7750362f1dd9c7eb62443fe88 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 3 Apr 1996 21:34:56 +0000 Subject: (main): In `Can't get disklabel' error message, specify which flag the user can use to supply the needed information. (mkfs): Fiddle with info message. --- ufs-utils/mkfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index f8668277..e585b598 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.9 1996/03/29 17:24:11 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.10 1996/04/03 21:34:56 miles Exp $"; #endif /* not lint */ #include @@ -333,7 +333,9 @@ main (int argc, char **argv) label = &label_buf; } if (label_err && param_name) - error (9, label_err, "%s: Can't get disklabel", device); + error (9, label_err, + "%s: Can't get disklabel; please specify --%s", + device, param_name); } return label; } @@ -874,7 +876,7 @@ next: * Now build the cylinders group blocks and * then print out indices of cylinder groups. */ - printf(" super-block backups (for fsck -b #) at:"); + printf("\tsuperblock backups at:"); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); if (cylno % 8 == 0) -- cgit v1.2.3 From 0bb6f48ecc0aa8a8136760706fd7bca235e10f2d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 4 Apr 1996 21:39:51 +0000 Subject: (diskfs_cached_lookup): Intialize NP->cache_id *after* NP exists. --- ufs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index ef0d9241..e4b26f81 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -66,7 +66,7 @@ diskfs_cached_lookup (int inum, struct node **npp) dn = malloc (sizeof (struct disknode)); - np->cache_id = dn->number = inum; + dn->number = inum; dn->dirents = 0; rwlock_init (&dn->allocptrlock); @@ -74,6 +74,8 @@ diskfs_cached_lookup (int inum, struct node **npp) dn->fileinfo = 0; np = diskfs_make_node (dn); + np->cache_id = inum; + mutex_lock (&np->lock); dn->hnext = nodehash[INOHASH(inum)]; if (dn->hnext) -- cgit v1.2.3 From b53468393263db592c0828ae1fbbd01796756a66 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 11 Apr 1996 20:05:38 +0000 Subject: Initial revision --- SETUP | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 SETUP diff --git a/SETUP b/SETUP new file mode 100644 index 00000000..f684396e --- /dev/null +++ b/SETUP @@ -0,0 +1,133 @@ +#!/bin/bash +# +# Setup initial hurd translators +# +# This script tries to setup a reasonable set of translators for a newly +# untarred hurd filesystem (since tar currently isn't able to do it). +# +# By passing in a value in the environment variable ROOT, an alternate root +# filesystem may be setup. +# + +# A list of likely mach devices to try +DISK_DEVS="`eval echo {s,h}d{0,1,2,3,4}{a,b,c,d,e,f,g,h}`" +NET_DEVS="`eval echo {eth,ne,wd,ul}{0,1,2,3,4}`" + +ROOT=${ROOT:-/} +case "$ROOT" in + /) PFX="";; + *) PFX="$ROOT";; +esac + +DEV=${DEV:-/dev} +SERVE=${SERVE:-$PFX/servers} + +PDEV=$PFX$DEV +SOCK=$SERVE/socket + +function st { + /bin/settrans -c "$@" +} +function gt { + /bin/showtrans 2>/dev/null "$@" +} + +# Test to see whether a node has a translator +function tp { + /bin/showtrans -s 2>/dev/null "$@" +} + +# Make a device (MAKEDEV uses $_CWD as the device directory) +function md { + (cd $PDEV && _CWD=$DEV $PDEV/MAKEDEV "$@") +} + +function devs { + /bin/devprobe "$@" +} + +PATH=/bin + +echo '(For most prompts, `none'\'' is also a valid input)' + +# Setup pflocal first, since the shell wants to use it +if tp $SOCK/1; then + echo "PFLOCAL translator present." +else + echo "Setting PFLOCAL translator..." + st $SOCK/1 /hurd/pflocal +fi + +if tp $PDEV/console && tp $PDEV/null && tp $PDEV/fd; then + echo "Standard devices already present." +else + echo "Making standard devices..." + md std +fi + +# See which disk devices might need creating +DISK_DEVS="`devs $DISK_DEVS`" +if test "$DISK_DEVS"; then + echo "Mach disk devices found: `echo $DISK_DEVS`" +else + echo "No mach disk devices found!" +fi + +ALREADY='' +MAYBE='' +for D in $DISK_DEVS; do + if tp $PDEV/r$D; then + ALREADY="${ALREADY:+$ALREADY }$D" + else + MAYBE="${MAYBE:+$MAYBE }$D" + fi +done +if test "$ALREADY"; then + echo "Disk devices with nodes in $PDEV: $ALREADY" +fi +if test "$MAYBE"; then + echo -n "Create device nodes in $PDEV for: [$MAYBE] "; read CREATE + if [ "$CREATE" != none ]; then + md ${CREATE:-$MAYBE} + fi +fi + +NET_DEVS="`devs $NET_DEVS`" +if test "$NET_DEVS"; then + echo "Mach network devices found: $NET_DEVS" +else + echo "No mach network devices found." +fi + +NET_TRANS="`gt $SOCK/2`" +if test "$NET_TRANS"; then + echo "PFINET translator present: $NET_TRANS" + echo -n "Change PFINET translator? [n] "; read yn + case "$yn" in + [Yy]*) + read dummy DEF_NET_ADDR DEF_NET_DEV < Date: Mon, 15 Apr 1996 16:51:37 +0000 Subject: (vpath tables.c): Find ufs directory in $(srcdir), not `..'. --- ufs-fsck/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 0b05bcbf..3adce958 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1994, 1995 Free Software Foundation +# Copyright (C) 1994, 1995, 1996 Free Software Foundation # Written by Michael I. Bushnell. # # This file is part of the GNU Hurd. @@ -28,7 +28,7 @@ LCLHDRS = fsck.h target = fsck.ufs installationdir = $(sbindir) -vpath tables.c ../ufs +vpath tables.c $(srcdir)/ufs $(target): ../libshouldbeinlibc/libshouldbeinlibc.a -- cgit v1.2.3 From 78cdd4ff9e055821032403c697b5fedbaf3ac9f3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 15 Apr 1996 17:20:21 +0000 Subject: (vpath tables.c): That's $(srcdir)/.. --- ufs-fsck/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 3adce958..2324f7d5 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -28,7 +28,7 @@ LCLHDRS = fsck.h target = fsck.ufs installationdir = $(sbindir) -vpath tables.c $(srcdir)/ufs +vpath tables.c $(srcdir)/../ufs $(target): ../libshouldbeinlibc/libshouldbeinlibc.a -- cgit v1.2.3 From f8b45ff0c982a14de34652314cfc4db07a2afb8f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 15 Apr 1996 19:11:36 +0000 Subject: (vpath tables.c): top_srcdir is better. --- ufs-fsck/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 2324f7d5..f68fe52a 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -28,7 +28,7 @@ LCLHDRS = fsck.h target = fsck.ufs installationdir = $(sbindir) -vpath tables.c $(srcdir)/../ufs +vpath tables.c $(top_srcdir)/ufs $(target): ../libshouldbeinlibc/libshouldbeinlibc.a -- cgit v1.2.3 From 1cfd3fd7e356a0a4a4374ddba5294f2791a50f2d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 16 Apr 1996 19:19:57 +0000 Subject: (diskfs_write_disknode): Only do sync if WAIT is set. --- ufs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index e4b26f81..88f89a37 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -479,7 +479,8 @@ void diskfs_write_disknode (struct node *np, int wait) { write_node (np); - sync_dinode (np->dn->number, wait); + if (wait) + sync_dinode (np->dn->number, 1); } /* Implement the diskfs_set_statfs callback from the diskfs library; -- cgit v1.2.3 From f8849fe3bc59296bee95db4a5b13a1275edaf2e5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 16 Apr 1996 19:35:27 +0000 Subject: (diskfs_lookup_hard): Set atime appropriately, and sync the new atime if we are running synchronously (!). (diskfs_dirempty): Likewise. (diskfs_direnter_hard): Set mtime appropriately. (diskfs_dirremove_hard): Likewise. (diskfs_dirrewrite_hard): Likewise. --- ufs/dir.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ufs/dir.c b/ufs/dir.c index 136b470f..67b3645e 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -153,6 +153,9 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, inum = 0; + if (!diskfs_readonly) + dp->dn_set_atime = 1; + for (blockaddr = buf, idx = 0; blockaddr - buf < dp->dn_stat.st_size; blockaddr += DIRBLKSIZ, idx++) @@ -167,6 +170,11 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, } } + if (!diskfs_readonly) + dp->dn_set_atime = 1; + if (diskfs_synchronous) + diskfs_node_update (dp, 1); + /* If err is set here, it's ENOENT, and we don't want to think about that as an error yet. */ err = 0; @@ -466,6 +474,8 @@ diskfs_direnter_hard(struct node *dp, assert (ds->type == CREATE); + dp->dn_set_mtime = 1; + switch (ds->stat) { case TAKE: @@ -568,6 +578,8 @@ diskfs_direnter_hard(struct node *dp, assert (0); } + dp->dn_set_mtime = 1; + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); if (ds->stat != EXTEND) @@ -614,6 +626,8 @@ diskfs_dirremove_hard(struct node *dp, assert (ds->type == REMOVE); assert (ds->stat == HERE_TIS); + dp->dn_set_mtime = 1; + if (ds->preventry == 0) ds->entry->d_ino = 0; else @@ -623,6 +637,8 @@ diskfs_dirremove_hard(struct node *dp, ds->preventry->d_reclen += ds->entry->d_reclen; } + dp->dn_set_mtime = 1; + vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); /* If we are keeping count of this block, then keep the count up @@ -650,9 +666,11 @@ diskfs_dirrewrite_hard(struct node *dp, assert (ds->type == RENAME); assert (ds->stat == HERE_TIS); + dp->dn_set_mtime = 1; ds->entry->d_ino = np->dn->number; if (direct_symlink_extension) ds->entry->d_type = IFTODT (np->dn_stat.st_mode); + dp->dn_set_mtime = 1; vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); @@ -681,6 +699,9 @@ diskfs_dirempty(struct node *dp, mach_port_deallocate (mach_task_self (), memobj); assert (!err); + if (!diskfs_readonly) + dp->dn_set_atime = 1; + for (curoff = buf; curoff < buf + dp->dn_stat.st_size; curoff += entry->d_reclen) @@ -694,9 +715,17 @@ diskfs_dirempty(struct node *dp, && entry->d_name[1] != '\0'))) { vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); + if (!diskfs_readonly) + dp->dn_set_atime = 1; + if (diskfs_synchronous) + node_update (dp, 1); return 0; } } + if (!diskfs_readonly) + dp->dn_set_atime = 1; + if (diskfs_synchronous) + node_update (dp, 1); vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); return 1; } -- cgit v1.2.3 From b69508c00daf432e4d21e72800ac58f950b967d4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Apr 1996 19:06:20 +0000 Subject: (ffs_realloccg): If we are allocating a new block, don't actually free the old one here. --- ufs/alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 8f6a5baf..4cbac331 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,5 +1,5 @@ /* Disk allocation routines - Copyright (C) 1993, 1994, 1995 Free Software Foundation + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation This file is part of the GNU Hurd. @@ -308,7 +308,10 @@ ffs_realloccg(register struct node *np, bp->b_blkno = fsbtodb(fs, bno); (void) vnode_pager_uncache(ITOV(ip)); #endif - ffs_blkfree(np, bprev, (long)osize); +/* Commented out here for Hurd; we don't want to free this until we've + saved the old contents. Callers are responsible for freeing the + block when they are done with it. */ +/* ffs_blkfree(np, bprev, (long)osize); */ if (nsize < request) ffs_blkfree(np, bno + numfrags(fs, nsize), (long)(request - nsize)); @@ -563,7 +566,7 @@ diskfs_alloc_node (struct node *dir, spin_unlock (&alloclock); if (ino == 0) goto noinodes; - error = iget (ino, &np); + error = diskfs_cached_lookup (ino, &np); assert ("duplicate allocation" && !np->dn_stat.st_mode); assert (!np->istranslated); if (np->dn_stat.st_blocks) { -- cgit v1.2.3 From f526bb2287fe7b8901a74aae0645701435026312 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Apr 1996 19:38:26 +0000 Subject: (diskfs_grow): New variable `pagerpt'. (offer_zeroes, block_extended): New functions. (diskfs_grow): In initializing newly allocated data disk blocks with zeroes, use less aggressive offer_zeroes instead of immediate synchronous writes. After ffs_realloccg succeeds, use block_extended to handle the magic. Get rid of old poke calls. --- ufs/sizes.c | 113 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 43 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 249b0ff9..87346175 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -65,6 +65,7 @@ diskfs_truncate (struct node *np, diskfs_end_catch_exception (); np->dn_stat.st_size = length; np->dn_set_ctime = np->dn_set_mtime = 1; + diskfs_node_update (np, 1); return 0; } @@ -343,9 +344,67 @@ indir_release (struct node *np, daddr_t bno, int level) return count; } + +/* Offer data at BUF from START of LEN bytes of file NP. */ +void +offer_data (struct node *np, + off_t start, + size_t len, + vm_address_t buf) +{ + vm_address_t addr; + + len = round_page (size); + + assert (start % vm_page_size == 0); + + assert (np->dn->fileinfo); + for (addr = start; addr < start + len; addr += vm_page_size) + pager_offer_page (np->dn->fileinfo->p, 1, 0, start, buf + (addr - start)); +} + +/* Logical block LBN of node NP has been extended with ffs_realloccg. + It used to be allocated at OLD_PBN and is now at NEW_PBN. The old + size was OLD_SIZE; it is now NEW_SIZE bytes long. Arrange for the data + on disk to be kept consistent, and free the old block if it has moved. */ +void +block_extended (struct node *np, + daddr_t lbn, + daddr_t old_pbn, + daddr_t new_pbn, + size_t old_size, + size_t new_size) +{ + vm_address_t buf; + daddr_t off; + + /* Make sure that any pages of this block which just became allocated + don't get paged in from disk. */ + if (round_page (old_size) < round_page (new_size)) + offer_data (np, lbn * sblock->fs_bsize + round_page (old_size), + round_page (new_size) - round_page (old_size), zeroblock); + + if (old_pbn != new_pbn) + { + /* Fetch the old data for the part that has moved and offer it + to the kernel, to make sure it's paged in before + we deallocate the old block. */ + for (off = 0; off < round_page (old_size); off += vm_page_size) + { + diskfs_device_read_sync (fsbtodb (old_pbn) + off / DEV_BSIZE, + (void *) &buf, vm_page_size); + /* If this page is the last one, then zero the excess first */ + if (off + vm_page_size > old_size) + bzero (buf + old_size - off, vm_page_size - (old_size - off)); + offer_data (np, lbn * sblock->fs_bsize + off, vm_page_size, buf); + } + + /* And deallocate the old block */ + ffs_blkfree (np, old_pbn, old_size); + } +} - /* Implement the diskfs_grow callback; see for the interface description. */ error_t @@ -357,8 +416,7 @@ diskfs_grow (struct node *np, int size, osize; error_t err; struct dinode *di = dino (np->dn->number); - off_t poke_off = 0; - size_t poke_len = 0; + mach_port_t pagerpt; /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect @@ -376,6 +434,9 @@ diskfs_grow (struct node *np, assert (!diskfs_readonly); + /* This reference will ensure that NP->dn->fileinfo stays allocated. */ + pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ); + /* The new last block of the file. */ lbn = lblkno (sblock, end - 1); @@ -411,16 +472,7 @@ diskfs_grow (struct node *np, record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), - zeroblock, sblock->fs_bsize - osize); - - if (bno != old_pbn) - { - /* Make sure the old contents get written out - to the new address by poking the pages. */ - poke_off = olbn * sblock->fs_bsize; - poke_len = osize; - } + block_extended (np, olbn, old_pbn, bno, osize, sblock->fs_bsize); } } @@ -446,18 +498,7 @@ diskfs_grow (struct node *np, record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - diskfs_device_write_sync (fsbtodb (sblock, bno) + btodb (osize), - zeroblock, size - osize); - - if (bno != old_pbn) - { - assert (!poke_len); - - /* Make sure the old contents get written out to - the new address by poking the pages. */ - poke_off = lbn * sblock->fs_bsize; - poke_len = osize; - } + block_extended (np, lbn, old_pbn, bno, osize, size); } else { @@ -471,8 +512,8 @@ diskfs_grow (struct node *np, di->di_db[lbn] = bno; record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - - diskfs_device_write_sync (fsbtodb (sblock, bno), zeroblock, size); + + offer_data (np, lbn * sblock->fs_bsize, size, zeroblock); } } else @@ -562,11 +603,11 @@ diskfs_grow (struct node *np, goto out; indirs[0].bno = siblock[indirs[0].offset] = bno; record_poke (siblock, sblock->fs_bsize); - diskfs_device_write_sync (fsbtodb (sblock, bno), - zeroblock, sblock->fs_bsize); + offer_data (np, lbn, sblock->fs_bsize, zeroblock); } out: + mach_port_deallocate (mach_task_self (), pagerpt); if (!err) { int newallocsize; @@ -580,20 +621,6 @@ diskfs_grow (struct node *np, rwlock_writer_unlock (&np->dn->allocptrlock); - /* If we expanded a fragment, then POKE_LEN will be set. - We need to poke the requested amount of the memory object - so that the kernel will write out the data to the new location - at a suitable time. */ - if (poke_len) - { - mach_port_t obj; - - obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); - poke_pages (obj, trunc_page (poke_off), - round_page (poke_off + poke_len)); - mach_port_deallocate (mach_task_self (), obj); - } - return err; } -- cgit v1.2.3 From 9b2babc70f9e77c4acc6d22d30c99913490f2d74 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 14:11:44 +0000 Subject: (pass5): Correctly track contig summaries even though they aren't used by the filesystem; we still need to preserve the format. --- ufs-fsck/pass5.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index a38ac426..c6ca29c7 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -1,5 +1,5 @@ /* Pass 5 of GNU fsck -- check allocation maps and summaries - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -115,13 +115,30 @@ pass5 () * sizeof (short)); newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock->fs_ipg, NBBY); - /* Only support sblock->fs_contigsumsize == 0 here */ - /* If we supported clustered filesystems, then we would set - clustersumoff and clusteroff and nextfree off would be past - them. */ - newcg->cg_nextfreeoff = - (newcg->cg_freeoff - + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY)); + if (sblock->fs_contigsumsize <= 0) + { + newcg->cg_nextfreeoff = + (newcg->cg_freeoff + + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), + NBBY)); + } + else + { + newcg->cg_clustersumoff = + (newcg->cg_freeoff + + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY) + - sizeof (long)); + newcg->cg_clustersumoff = + roundup (newcg->cg_clustersumoff, sizeof (long)); + newcg->cg_clusteroff = + (newcg->cg_clustersumoff + + (sblock->fs_contigsumsize + 1) * sizeof (long)); + newcg->cg_nextfreeoff = + (newcg->cg_clusteroff + + howmany (sblock->fs_cpg * sblock->fs_spc / NSPB (sblock), + NBBY)); + } + newcg->cg_magic = CG_MAGIC; /* Set map sizes */ @@ -168,8 +185,8 @@ pass5 () else newcg->cg_ncyl = sblock->fs_cpg; newcg->cg_ndblk = dmax - dbase; - /* Don't set nclusterblks; we don't support that */ - + if (sblock->fs_contigsumsize > 0) + newcg->cg_nclusterblks = newcg->cg_ndblk / sblock->fs_frag; newcg->cg_cs.cs_ndir = 0; newcg->cg_cs.cs_nffree = 0; newcg->cg_cs.cs_nbfree = 0; @@ -279,8 +296,8 @@ pass5 () j = cbtocylno (sblock, i); cg_blktot(newcg)[j]++; cg_blks(sblock, newcg, j)[cbtorpos(sblock, i)]++; - /* If we support clustering, then we'd account for this - in the cluster map too. */ + if (sblock->fs_contigsumsize > 0) + setbit (cg_clustersfree (newcg), i / sblock->fs_frag); } else if (frags) { @@ -292,6 +309,42 @@ pass5 () } } + if (sblock->fs_contigsumsize > 0) + { + long *sump = cg_clustersum (newcg); + u_char *mapp = cg_clustersfree (newcg); + int map = *mapp++; + int bit = 1; + int run = 0; + + for (i = 0; i < newcg->cg_nclusterblks; i++) + { + if ((map & bit) != 0) + run++; + else if (run) + { + if (run > sblock->fs_contigsumsize) + run = sblock->fs_contigsumsize; + sump[run]++; + run = 0; + } + + if ((i & (NBBY - 1)) 1= (NBBY - 1)) + bit <<= 1; + else + { + map = *mapp++; + bit = 1; + } + } + if (run != 0) + { + if (run > sblock->fs_contigsumsize) + run = sblock->fs_contigsumsize; + sump[run]++; + } + } + /* Add this cylinder group's totals into the superblock's totals. */ cstotal.cs_nffree += newcg->cg_cs.cs_nffree; -- cgit v1.2.3 From 3003ecec8c44251f02d39d8233b2103a0cc7426b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 15:28:35 +0000 Subject: (swab_disk): New variable. (swab_short, swab_long): New functions. --- ufs/ufs.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index ca186434..68a5dece 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -112,6 +112,9 @@ enum compat_mode of the dinode. */ int direct_symlink_extension; +/* If this is set, then the disk is byteswapped from native order. */ +int swab_disk; + /* Handy macros */ #define DEV_BSIZE 512 @@ -165,6 +168,26 @@ sync_dinode (int inum, int wait) { sync_disk_blocks (ino_to_fsba (sblock, inum), sblock->fs_fsize, wait); } + + +/* Functions for byte swapping */ +extern inline short +swab_short (short arg) +{ + return (((arg & 0xff) << 8) + | ((arg & 0xff00) >> 8)); +} + +extern inline long +swab_long (long arg) +{ + return (((arg & 0xff) << 24) + | ((arg & 0xff00) << 8) + | ((arg & 0xff0000) >> 8) + | ((arg & 0xff000000) >> 24)); +} + + /* From alloc.c: */ error_t ffs_alloc (struct node *, daddr_t, daddr_t, int, daddr_t *, -- cgit v1.2.3 From ce8b74e2cfc6ec5a1512058fd48569193dfafc87 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 15:57:05 +0000 Subject: (swab_sblock, swab_csums): New functions. (get_hypermetadata): If this is a swapped filesystem, set swab_disk. Also swap csum and sblock after reading them. (diskfs_set_hypermetadata): If swab_disk, swap the csums back before writing them. (copy_sblock): If swab_disk, swap the sblock before writing it. --- ufs/hyper.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index be51b360..283a7e14 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -29,6 +29,106 @@ vm_address_t zeroblock; struct fs *sblock; struct csum *csum; +void +swab_sblock (struct fs *sblock) +{ + int i, j; + + sblock->fs_sblkno = swab_long (sblock->fs_sblkno); + sblock->fs_cblkno = swab_long (sblock->fs_cblkno); + sblock->fs_iblkno = swab_long (sblock->fs_iblkno); + sblock->fs_dblkno = swab_long (sblock->fs_dblkno); + sblock->fs_cgoffset = swab_long (sblock->fs_cgoffset); + sblock->fs_cgmask = swab_long (sblock->fs_cgmask); + sblock->fs_time = swab_long (sblock->fs_time); + sblock->fs_size = swab_long (sblock->fs_size); + sblock->fs_dsize = swab_long (sblock->fs_dsize); + sblock->fs_ncg = swab_long (sblock->fs_ncg); + sblock->fs_bsize = swab_long (sblock->fs_bsize); + sblock->fs_fsize = swab_long (sblock->fs_fsize); + sblock->fs_frag = swab_long (sblock->fs_frag); + sblock->fs_minfree = swab_long (sblock->fs_minfree); + sblock->fs_rotdelay = swab_long (sblock->fs_rotdelay); + sblock->fs_rps = swab_long (sblock->fs_rps); + sblock->fs_bmask = swab_long (sblock->fs_bmask); + sblock->fs_fmask = swab_long (sblock->fs_fmask); + sblock->fs_bshift = swab_long (sblock->fs_bshift); + sblock->fs_fshift = swab_long (sblock->fs_fshift); + sblock->fs_maxcontig = swab_long (sblock->fs_maxcontig); + sblock->fs_maxbpg = swab_long (sblock->fs_maxbpg); + sblock->fs_fragshift = swab_long (sblock->fs_fragshift); + sblock->fs_fsbtodb = swab_long (sblock->fs_fsbtodb); + sblock->fs_sbsize = swab_long (sblock->fs_sbsize); + sblock->fs_csmask = swab_long (sblock->fs_csmask); + sblock->fs_csshift = swab_long (sblock->fs_csshift); + sblock->fs_nindir = swab_long (sblock->fs_nindir); + sblock->fs_inopb = swab_long (sblock->fs_inopb); + sblock->fs_nspf = swab_long (sblock->fs_nspf); + sblock->fs_optim = swab_long (sblock->fs_optim); + sblock->fs_npsect = swab_long (sblock->fs_npsect); + sblock->fs_interleave = swab_long (sblock->fs_interleave); + sblock->fs_trackskew = swab_long (sblock->fs_trackskew); + sblock->fs_headswitch = swab_long (sblock->fs_headswitch); + sblock->fs_trkseek = swab_long (sblock->fs_trkseek); + sblock->fs_csaddr = swab_long (sblock->fs_csaddr); + sblock->fs_cssize = swab_long (sblock->fs_cssize); + sblock->fs_cgsize = swab_long (sblock->fs_cgsize); + sblock->fs_ntrak = swab_long (sblock->fs_ntrak); + sblock->fs_nsect = swab_long (sblock->fs_nsect); + sblock->fs_spc = swab_long (sblock->fs_spc); + sblock->fs_ncyl = swab_long (sblock->fs_ncyl); + sblock->fs_cpg = swab_long (sblock->fs_cpg); + sblock->fs_ipg = swab_long (sblock->fs_ipg); + sblock->fs_fpg = swab_long (sblock->fs_fpg); + sblock->fs_cstotal.cs_ndir = swab_long (sblock->fs_cstotal.cs_ndir); + sblock->fs_cstotal.cs_nbfree = swab_long (sblock->fs_cstotal.cs_nbfree); + sblock->fs_cstotal.cs_nifree = swab_long (sblock->fs_cstotal.cs_nifree); + sblock->fs_cstotal.cs_nffree = swab_long (sblock->fs_cstotal.cs_nffree); + /* fs_fmod, fs_clean, fs_ronly, fs_flags, fs_fsmnt are all char */ + sblock->fs_cgrotor = swab_long (sblock->fs_cgrotor); + sblock->fs_cpc = swab_long (sblock->fs_cpc); + sblock->fs_contigsumsize = swab_long (sblock->fs_contigsumsize); + sblock->fs_maysymlinksen = swab_long (sblock->fs_maysymlinksen); + sblock->fs_inodefmt = swab_long (sblock->fs_inodefmt); + sblock->fs_maxfilesize.val[0] = swab_long (sblock->fs_maxfilesize.val[0]); + sblock->fs_maxfilesize.val[1] = swab_long (sblock->fs_maxfilesize.val[1]); + sblock->fs_qbmask.val[0] = swab_long (sblock->fs_qbmask.val[0]); + sblock->fs_qbmask.val[1] = swab_long (sblock->fs_qbmask.val[1]); + sblock->fs_state = swab_long (sblock->fs_state); + sblock->fs_postblformat = swab_long (sblock->fs_postblformat); + sblock->fs_nrpos = swab_long (sblock->fs_nrpos); + sblock->fs_postbloff = swab_long (sblock->fs_postbloff); + sblock->fs_rotbloff = swab_long (sblock->fs_rotbloff); + sblock->fs_magic = swab_long (sblock->fs_magic); + + /* Tables */ + if (sblock->fs_postblformat == FS_42POSTBLFMT) + for (i = 0; i < 16; i++) + for (j = 0; j < 8; j++) + sblock->fs_opostbl[i][j] = swab_short (sblock->fs_opostbl[i][j]); + else + for (i = 0; i < sblock->fs_cpc; i++) + for (j = 0; j < sblock->fs_nrpos; j++) + fs_postbl(sblock, j)[i] + = swab_short (sblock->fs_postbl (sblock, j)[i]); + + /* The rot table is all chars */ +} + +void +swab_csums (struct csum *csum) +{ + int i; + + for (i = 0; i < fs_ncg; i++) + { + csum[i].cs_ndir = swab_long (csum[i].cs_ndir); + csum[i].cs_nbfree = swab_long (csum[i].cs_nbfree); + csum[i].cs_nifree = swab_long (csum[i].cs_nifree); + csum[i].cs_nffree = swab_long (csum[i].cs_nffree); + } +} + void get_hypermetadata (void) { @@ -48,6 +148,14 @@ get_hypermetadata (void) bcopy (disk_image + SBOFF, sblock, SBSIZE); diskfs_end_catch_exception (); + if ((swab_long (sblock->fs_magic)) == FS_MAGIC) + { + swab_disk = 1; + swab_sblock (sblock); + } + else + swab_disk = 0; + if (sblock->fs_magic != FS_MAGIC) { fprintf (stderr, "Bad magic number %#lx (should be %#x)\n", @@ -138,6 +246,9 @@ get_hypermetadata (void) fsaddr (sblock, howmany (sblock->fs_cssize, sblock->fs_fsize))); diskfs_end_catch_exception (); + if (swab_disk) + swab_csums (csum); + if ((diskfs_device_size << diskfs_log2_device_block_size) < sblock->fs_size * sblock->fs_fsize) { @@ -188,6 +299,8 @@ diskfs_set_hypermetadata (int wait, int clean) if (!err) { bcopy (csum, (void *) buf, sblock->fs_cssize); + if (swab_disk) + swab_csums ((struct csum *)buf); diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize); csum_dirty = 0; @@ -224,7 +337,8 @@ copy_sblock () assert (! diskfs_readonly); if (sblock->fs_postblformat == FS_42POSTBLFMT - || oldformat) + || oldformat + || swab_disk) { char sblockcopy[SBSIZE]; struct fs *sbcopy = (struct fs *)sblockcopy; @@ -237,6 +351,8 @@ copy_sblock () sbcopy->fs_qbmask = -1; sbcopy->fs_qfmask = -1; } + if (swab_disk) + swab_sblock (sbcopy); bcopy (sbcopy, disk_image + SBOFF, SBSIZE); } else -- cgit v1.2.3 From 61f4a11558fc9436b48307fb9ca5c3bc3bb26182 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 16:02:54 +0000 Subject: (read_disk_entry): New macro. --- ufs/ufs.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index 68a5dece..ba778e1d 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -186,6 +186,21 @@ swab_long (long arg) | ((arg & 0xff0000) >> 8) | ((arg & 0xff000000) >> 24)); } + +/* Return *ENTRYP, after byteswapping it if necessary */ +#define read_disk_entry(entryp) \ +({ \ + if (!swab_disk || sizeof (*entryp) == 1) \ + *entryp; \ + else if (sizeof (*entryp) == 2) \ + swab_short (*entryp); \ + else if (sizeof (*entry) == 4) \ + swab_long (*entryp); \ + else \ + abort; \ +}) + + -- cgit v1.2.3 From 5f9cfa422098196ff6b98656fe192193d4f699bb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 17:59:46 +0000 Subject: (ffs_realloccg): Use read/write_disk_entry when reading/writing on-disk inode fields. (ffs_blkpref): Use read_disk_entry when reading from BAP array. (swab_cg, read_cg, release_cg): New functions. (ffs_fragextend, ffs_alloccg, ffs_nodealloccg, ffs_blkfree, diskfs_free_node): Use new cg access functions. --- ufs/alloc.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 158 insertions(+), 10 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 4cbac331..fdd0aa59 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -89,6 +89,117 @@ alloc_sync (struct node *np) } } +/* Byteswap everything in CGP. */ +void +swab_cg (struct cg *cgp) +{ + int i, j; + + if (swab_long (cg->cg_magic) == CG_MAGIC + || cg->cg_magic == CG_MAGIC) + { + cg->cg_magic = swab_long (cg->cg_magic); + cg->cg_time = swab_long (cg->cg_time); + cg->cg_cgx = swab_long (cg->cg_cgx); + cg->cg_ncyl = swab_short (cg->cg_ncyl); + cg->cg_niblk = swab_short (cg->cg_niblk); + cg->cg_cs.cs_ndir = swab_long (cg->cg_cs.cs_ndir); + cg->cg_cs.cs_nbfree = swab_long (cg->cg_cs.cs_nbfree); + cg->cg_cs.cs_nifree = swab_long (cg->cg_cs.cs_nifree); + cg->cg_cs.cs_nffree = swab_long (cg->cg_cs.cs_nffree); + cg->cg_rotor = swab_long (cg->cg_rotor); + cg->cg_irotor = swab_long (cg->cg_irotor); + for (i = 0; i < MAXFRAG; i++) + cg->cg_frsum[i] = swab_long (cg->cg_frsum[i]); + cg->cg_btotoff = swab_long (cg->cg_btotoff); + cg->cg_boff = swab_long (cg->cg_boff); + cg->cg_iusedoff = swab_long (cg->cg_iusedoff); + cg->cg_freeoff = swab_long (cg->cg_freeoff); + cg->cg_nextfreeoff = swab_long (cg->cg_nextfreeoff); + cg->cg_clustersumoff = swab_long (cg->cg_clustersumoff); + cg->cg_clusteroff = swab_long (cg->cg_clusteroff); + cg->cg_nclusterblks = swab_long (cg->cg_nclusterblks); + + /* blktot map */ + for (i = 0; i < cg->cg_ncyl; i++) + cg_blktot(cg)[i] = swab_long (cg_blktot(cg)[i]); + + /* blks map */ + for (i = 0; i < cg->cg_ncyl; i++) + for (j = 0; j < sblock->fs_nrpos; j++) + cg_blks(sblock, cg, i)[j] = swab_short (cg_blks (sblock, cg, i)[j]); + + for (i = 0; i < sblock->fs_contigsumsize; i++) + cg_clustersum(cg)[i] = swab_long (cg_clustersum(cg)[i]); + + /* inosused, blksfree, and cg_clustersfree are char arrays */ + } + else + { + /* Old format cylinder group... */ + struct ocg *ocg = cg; + + if (swab_long (ocg->cg_magic) != CG_MAGIC + && ocg->cg_magic != CG_MAGIC) + return; + + ocg->cg_time = swab_long (ocg->cg_time); + ocg->cg_cgx = swab_long (ocg->cg_cgx); + ocg->cg_ncyl = swab_short (ocg->cg_ncyl); + ocg->cg_niblk = swab_short (ocg->cg_niblk); + ocg->cg_ndblk = swab_long (ocg->cg_ndblk); + ocg->cg_cs.cs_ndir = swab_long (ocg->cg_cs.cs_ndir); + ocg->cg_cs.cs_nbfree = swab_long (ocg->cg_cs.cs_nbfree); + ocg->cg_cs.cs_nifree = swab_long (ocg->cg_cs.cs_nifree); + ocg->cg_cs.cs_nffree = swab_long (ocg->cg_cs.cs_nffree); + ocg->cg_rotor = swab_long (ocg->cg_rotor); + ocg->cg_frotor = swab_long (ocg->cg_frotor); + ocg->cg_irotor = swab_long (ocg->cg_irotor); + for (i = 0; i < 8; i++) + ocg->cg_frsum[i] = swab_long (ocg->cg_frsum[i]); + for (i = 0; i < 32; i++) + ocg->cg_btot[i] = swab_long (ocg->cg_btot[i]); + for (i = 0; i < 32; i++) + for (j = 0; j < 8; j++) + ocg->cg_b[i][j] = swab_short (ocg->cg_b[i][j]); + ocg->cg_magic = swab_long (ocg->cg_magic); + } +} + + +/* Read cylinder group indexed CG. Set *CGPP to point at it. + Return 1 if caller should call release_cgp when we're done with it; + otherwise zero. */ +int +read_cg (int cg, struct cg **cgpp) +{ + struct cg *diskcg = cg_locate (cg); + + if (swab_disk) + { + *cgp = malloc (sblock->fs_cgsize); + bcopy (diskcg, *cgp, sblock->fs_cgsize); + swab_cg (*cgp); + return 1; + } + else + { + *cgp = diskcg; + return 0; + } +} + +/* Caller of read_cg is done with cg; write it back to disk (swapping it + along the way) and free the memory allocated in read_cg. */ +void +release_cgp (struct cg *cgp) +{ + swab_cg (cgp); + bcopy (cgp, cg_locate (cg), sblock->fs_cgsize); + free (cgp); +} + + /* * Allocate a block in the file system. * @@ -214,7 +325,7 @@ ffs_realloccg(register struct node *np, error = diskfs_catch_exception (); if (error) return error; - bprev = (dino (np->dn->number))->di_db[lbprev]; + bprev = read_disk_entry ((dino (np->dn->number))->di_db[lbprev]); diskfs_end_catch_exception (); assert ("old block not allocated" && bprev); @@ -674,7 +785,8 @@ ffs_blkpref(struct node *np, (ino_to_cg(fs, np->dn->number) + lbn / fs->fs_maxbpg); else - startcg = dtog(fs, bap[indx - 1]) + 1; + startcg = dtog(fs, + read_disk_entry (bap[indx - 1])) + 1; startcg %= fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; for (cg = startcg; cg < fs->fs_ncg; cg++) @@ -699,9 +811,10 @@ ffs_blkpref(struct node *np, * next block is requested contiguously, otherwise it is * requested rotationally delayed by fs_rotdelay milliseconds. */ - nextblk = bap[indx - 1] + fs->fs_frag; - if (indx < fs->fs_maxcontig || bap[indx - fs->fs_maxcontig] + - blkstofrags(fs, fs->fs_maxcontig) != nextblk) + nextblk = read_disk_entry (bap[indx - 1]) + fs->fs_frag; + if (indx < fs->fs_maxcontig + || (read_disk_entry (bap[indx - fs->fs_maxcontig]) + + blkstofrags(fs, fs->fs_maxcontig) != nextblk)) { return (nextblk); } @@ -790,6 +903,7 @@ ffs_fragextend(struct node *np, long bno; int frags, bbase; int i; + int releasecg; fs = sblock; if (csum[cg].cs_nffree < numfrags(fs, nsize - osize)) @@ -809,10 +923,12 @@ ffs_fragextend(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = cg_locate (cg); + releasecg = read_cg (cg, &cgp); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return 0; } cgp->cg_time = diskfs_mtime->seconds; @@ -820,6 +936,8 @@ ffs_fragextend(struct node *np, for (i = numfrags(fs, osize); i < frags; i++) if (isclr(cg_blksfree(cgp), bno + i)) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return 0; } /* @@ -840,6 +958,8 @@ ffs_fragextend(struct node *np, fs->fs_cstotal.cs_nffree--; csum[cg].cs_nffree--; } + if (releasecg) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -864,6 +984,7 @@ ffs_alloccg(struct node *np, register struct cg *cgp; register int i; int bno, frags, allocsiz; + int releasecg; fs = sblock; if (csum[cg].cs_nbfree == 0 && size == fs->fs_bsize) @@ -877,17 +998,21 @@ ffs_alloccg(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = cg_locate (cg); + releasecg = read_cg (cg, &cgp); #endif if (!cg_chkmagic(cgp) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return 0; } cgp->cg_time = diskfs_mtime->seconds; if (size == fs->fs_bsize) { bno = ffs_alloccgblk(fs, cgp, bpref); /* bdwrite(bp); */ + if (releasecg) + release_cg (cgp); return (bno); } /* @@ -906,6 +1031,8 @@ ffs_alloccg(struct node *np, */ if (cgp->cg_cs.cs_nbfree == 0) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return 0; } bno = ffs_alloccgblk(fs, cgp, bpref); @@ -919,6 +1046,8 @@ ffs_alloccg(struct node *np, fs->fs_fmod = 1; cgp->cg_frsum[i]++; + if (releasecg) + release_cg (cgp) record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -928,6 +1057,8 @@ ffs_alloccg(struct node *np, bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); if (bno < 0) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return 0; } for (i = 0; i < frags; i++) @@ -939,6 +1070,8 @@ ffs_alloccg(struct node *np, cgp->cg_frsum[allocsiz]--; if (frags != allocsiz) cgp->cg_frsum[allocsiz - frags]++; + if (releasecg) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -1168,6 +1301,7 @@ ffs_nodealloccg(struct node *np, register struct fs *fs; register struct cg *cgp; int start, len, loc, map, i; + int releasecg; fs = sblock; if (csum[cg].cs_nifree == 0) @@ -1181,10 +1315,12 @@ ffs_nodealloccg(struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = cg_locate (cg); + releasecg = read_cg (cg, &cgp); #endif if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { /* brelse(bp); */ + if (releasecg) + release_cg (cg); return 0; } cgp->cg_time = diskfs_mtime->seconds; @@ -1224,6 +1360,8 @@ gotit: fs->fs_cstotal.cs_ndir++; csum[cg].cs_ndir++; } + if (releasecg) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -1247,6 +1385,7 @@ ffs_blkfree(register struct node *np, register struct cg *cgp; daddr_t blkno; int i, cg, blk, frags, bbase; + int releasecg; fs = sblock; assert ((u_int)size <= fs->fs_bsize && !fragoff (fs, size)); @@ -1265,10 +1404,12 @@ ffs_blkfree(register struct node *np, } cgp = (struct cg *)bp->b_data; #else - cgp = cg_locate (cg); + releasecg = cg_read (cg, &cgp); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return; } cgp->cg_time = diskfs_mtime->seconds; @@ -1324,6 +1465,8 @@ ffs_blkfree(register struct node *np, cg_blktot(cgp)[i]++; } } + if (releasecg) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -1346,6 +1489,7 @@ diskfs_free_node (struct node *np, mode_t mode) register struct cg *cgp; ino_t ino = np->dn->number; int cg; + int releasecg; fs = sblock; assert (ino < fs->fs_ipg * fs->fs_ncg); @@ -1359,10 +1503,12 @@ diskfs_free_node (struct node *np, mode_t mode) } cgp = (struct cg *)bp->b_data; #else - cgp = cg_locate (cg); + releasecg = read_cg (cg, &cgp); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ + if (releasecg) + release_cg (cgp); return; } cgp->cg_time = diskfs_mtime->seconds; @@ -1383,6 +1529,8 @@ diskfs_free_node (struct node *np, mode_t mode) fs->fs_cstotal.cs_ndir--; csum[cg].cs_ndir--; } + if (releasecg) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; -- cgit v1.2.3 From 86bfb36dd0eacd54abe136718bd666e7459105fb Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:00:25 +0000 Subject: (swab_disk): New variable. (swab_short, swab_long): New functions. (read_disk_entry, write_disk_entry): New macros. --- ufs/ufs.h | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index ba778e1d..dba7acd9 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -187,19 +187,32 @@ swab_long (long arg) | ((arg & 0xff000000) >> 24)); } -/* Return *ENTRYP, after byteswapping it if necessary */ -#define read_disk_entry(entryp) \ +/* Return ENTRY, after byteswapping it if necessary */ +#define read_disk_entry(entry) \ ({ \ - if (!swab_disk || sizeof (*entryp) == 1) \ - *entryp; \ - else if (sizeof (*entryp) == 2) \ - swab_short (*entryp); \ - else if (sizeof (*entry) == 4) \ - swab_long (*entryp); \ + if (!swab_disk || sizeof (entry) == 1) \ + (entry); \ + else if (sizeof (entry) == 2) \ + swab_short (entry); \ + else if (sizeof (entry) == 4) \ + swab_long (entry); \ else \ - abort; \ + abort (); \ }) +/* Execute A = B, but byteswap it along the way if necessary */ +#define write_disk_entry(a,b) \ +({ \ + if (!swab_disk || sizeof (a) == 1) \ + ((a) = (b)); \ + else if (sizeof (a) == 2) \ + ((a) = (swab_short (b))); \ + else if (sizeof (a) == 4) \ + ((a) = (swab_long (b))); \ + else \ + abort (); \ +}) + -- cgit v1.2.3 From cd6391ab4b5ebb5e053f9cd00d34f2328ced41d0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:01:49 +0000 Subject: (diskfs_truncate): Use read/write_disk_entry when reading/writing on-disk indirect blocks. (diskfs_grow): Likewise. (indir_release): Likewise. (diskfs_truncate): Use read/write_disk_entry when reading/writing on-disk inode fields. (diskfs_grow): Likewise. --- ufs/sizes.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 87346175..a5be68ea 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -142,7 +142,7 @@ diskfs_truncate (struct node *np, if (di->di_db[i]) { long bsize = blksize (sblock, np, i); - ffs_blkfree (np, di->di_db[i], bsize); + ffs_blkfree (np, read_disk_entry (di->di_db[i]), bsize); di->di_db[i] = 0; blocksfreed += btodb (bsize); } @@ -156,7 +156,8 @@ diskfs_truncate (struct node *np, for (i = indirs[0].offset + 1; i < NINDIR (sblock); i++) if (sindir[i]) { - ffs_blkfree (np, sindir[i], sblock->fs_bsize); + ffs_blkfree (np, read_disk_entry (sindir[i]), + sblock->fs_bsize); sindir[i] = 0; blocksfreed += btodb (sblock->fs_bsize); } @@ -170,7 +171,9 @@ diskfs_truncate (struct node *np, /* ...mapped from the inode */ if (di->di_ib[INDIR_SINGLE] && indirs[1].offset == -2) { - blocksfreed += indir_release (np, di->di_ib[INDIR_SINGLE], + blocksfreed += indir_release (np, + read_disk_entry (di->di_ib + [INDIR_SINGLE]), INDIR_SINGLE); di->di_ib[INDIR_SINGLE] = 0; } @@ -184,7 +187,9 @@ diskfs_truncate (struct node *np, for (i = indirs[1].offset + 1; i < NINDIR (sblock); i++) if (dindir[i]) { - blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); + blocksfreed += indir_release (np, + read_disk_entry (dindir[i]), + INDIR_SINGLE); dindir[i] = 0; } record_poke (dindir, sblock->fs_bsize); @@ -197,7 +202,9 @@ diskfs_truncate (struct node *np, { if (di->di_ib[INDIR_DOUBLE]) { - blocksfreed += indir_release (np, di->di_ib[INDIR_DOUBLE], + blocksfreed += indir_release (np, + read_disk_entry (di->di_ib + [INDIR_DOUBLE]), INDIR_DOUBLE); di->di_ib[INDIR_DOUBLE] = 0; } @@ -210,7 +217,7 @@ diskfs_truncate (struct node *np, long oldspace, newspace; daddr_t bn; - bn = di->di_db[lbn]; + bn = read_disk_entry (di->di_db[lbn]); oldspace = blksize (sblock, np, lbn); np->allocsize = fragroundup (sblock, length); newspace = blksize (sblock, np, lbn); @@ -297,11 +304,11 @@ indir_release (struct node *np, daddr_t bno, int level) { if (level == INDIR_SINGLE) { - ffs_blkfree (np, addrs[i], sblock->fs_bsize); + ffs_blkfree (np, read_disk_entry (addrs[i]), sblock->fs_bsize); count += btodb (sblock->fs_bsize); } else - count += indir_release (np, addrs[i], level - 1); + count += indir_release (np, read_disk_entry (addrs[i]), level - 1); } /* Subtlety: this block is no longer necessary; the information @@ -391,7 +398,7 @@ block_extended (struct node *np, we deallocate the old block. */ for (off = 0; off < round_page (old_size); off += vm_page_size) { - diskfs_device_read_sync (fsbtodb (old_pbn) + off / DEV_BSIZE, + diskfs_device_read_sync (fsbtodb (sblock, old_pbn) + off / DEV_BSIZE, (void *) &buf, vm_page_size); /* If this page is the last one, then zero the excess first */ if (off + vm_page_size > old_size) @@ -467,8 +474,8 @@ diskfs_grow (struct node *np, osize, sblock->fs_bsize, &bno, cred); if (err) goto out; - old_pbn = di->di_db[olbn]; - di->di_db[olbn] = bno; + old_pbn = read_disk_entry (di->di_db[olbn]); + write_disk_entry (di->di_db[olbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; @@ -478,7 +485,7 @@ diskfs_grow (struct node *np, if (lbn < NDADDR) { - daddr_t bno, old_pbn = di->di_db[lbn]; + daddr_t bno, old_pbn = read_disk_entry (di->di_db[lbn]); if (old_pbn != 0) { @@ -494,7 +501,7 @@ diskfs_grow (struct node *np, if (err) goto out; - di->di_db[lbn] = bno; + write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; @@ -509,7 +516,7 @@ diskfs_grow (struct node *np, if (err) goto out; - di->di_db[lbn] = bno; + write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; @@ -551,7 +558,8 @@ diskfs_grow (struct node *np, if (err) goto out; zero_disk_block (bno); - indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; + indirs[1].bno = bno; + write_disk_entry (di->di_ib[INDIR_SINGLE], bno); record_poke (di, sizeof (struct dinode)); } else @@ -572,7 +580,8 @@ diskfs_grow (struct node *np, if (err) goto out; zero_disk_block (bno); - indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + indirs[2].bno = bno; + write_disk_entry (di->di_ib[INDIR_DOUBLE], bno); record_poke (di, sizeof (struct dinode)); } @@ -587,7 +596,8 @@ diskfs_grow (struct node *np, if (err) goto out; zero_disk_block (bno); - indirs[1].bno = diblock[indirs[1].offset] = bno; + indirs[1].bno = bno; + write_disk_entry (diblock[indirs[1].offset], bno); record_poke (diblock, sblock->fs_bsize); } } @@ -601,7 +611,8 @@ diskfs_grow (struct node *np, sblock->fs_bsize, &bno, 0); if (err) goto out; - indirs[0].bno = siblock[indirs[0].offset] = bno; + indirs[0].bno = bno; + write_disk_entry (siblock[indirs[0].offset], bno); record_poke (siblock, sblock->fs_bsize); offer_data (np, lbn, sblock->fs_bsize, zeroblock); } -- cgit v1.2.3 From 4056e0b628cbdbf394876ca9ebdde453f460ea4c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:08:24 +0000 Subject: (pager_unlock_page): Use read/write_disk_entry when reading/writing on-disk inode fields and indirect blocks. --- ufs/pager.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 8834f911..d4bc87c5 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -246,7 +246,8 @@ pager_unlock_page (struct user_pager_info *pager, assert (lblkno (sblock, address) < NDADDR); diskfs_device_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); - indirs[0].bno = di->di_db[lblkno (sblock, address)] = bno; + indirs[0].bno = bno; + write_disk_entry (di->di_db[lblkno (sblock, address)], bno); record_poke (di, sizeof (struct dinode)); } else @@ -266,7 +267,8 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; zero_disk_block (bno); - indirs[1].bno = di->di_ib[INDIR_SINGLE] = bno; + indirs[1].bno = bno; + write_disk_entry (di->di_ib[INDIR_SINGLE], bno); record_poke (di, sizeof (struct dinode)); } else @@ -290,7 +292,8 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; zero_disk_block (bno); - indirs[2].bno = di->di_ib[INDIR_DOUBLE] = bno; + indirs[2].bno = bno; + write_disk_entry (di->di_ib[INDIR_DOUBLE], bno); record_poke (di, sizeof (struct dinode)); } @@ -306,7 +309,8 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; zero_disk_block (bno); - indirs[1].bno = diblock[indirs[1].offset] = bno; + indirs[1].bno = bno; + write_disk_entry (diblock[indirs[1].offset], bno); record_poke (diblock, sblock->fs_bsize); } } @@ -326,7 +330,8 @@ pager_unlock_page (struct user_pager_info *pager, diskfs_device_write_sync (fsbtodb (sblock, bno), zeroblock, sblock->fs_bsize); - indirs[0].bno = siblock[indirs[0].offset] = bno; + indirs[0].bno = bno; + write_disk_entry (siblock[indirs[0].offset], bno); record_poke (siblock, sblock->fs_bsize); } } -- cgit v1.2.3 From 1b51f9842dd2ab2cc5c8366e443c39c2f8417234 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:09:23 +0000 Subject: (fetch_indir_spec): Use read/write_disk_entry when reading/writing on-disk inode fields and indirect blocks. --- ufs/bmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs/bmap.c b/ufs/bmap.c index 11756a66..1a138f39 100644 --- a/ufs/bmap.c +++ b/ufs/bmap.c @@ -1,5 +1,5 @@ /* Interpretation of indirect block structure - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -45,7 +45,7 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, { if (lbn >= 0) { - indirs[0].bno = di->di_db[lbn]; + indirs[0].bno = read_disk_entry (di->di_db[lbn]); indirs[0].offset = -1; } @@ -72,12 +72,12 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, assert (!(ibn / NINDIR (sblock))); indirs[2].offset = -1; - indirs[2].bno = di->di_ib[INDIR_DOUBLE]; + indirs[2].bno = read_disk_entry (di->di_ib[INDIR_DOUBLE]); if (indirs[2].bno) { diblock = indir_block (indirs[2].bno); - indirs[1].bno = diblock[indirs[1].offset]; + indirs[1].bno = read_disk_entry (diblock[indirs[1].offset]); } else indirs[1].bno = 0; @@ -85,13 +85,13 @@ fetch_indir_spec (struct node *np, volatile daddr_t lbn, else { indirs[1].offset = -1; - indirs[1].bno = di->di_ib[INDIR_SINGLE]; + indirs[1].bno = read_disk_entry (di->di_ib[INDIR_SINGLE]); } if (indirs[1].bno) { siblock = indir_block (indirs[1].bno); - indirs[0].bno = siblock[indirs[0].offset]; + indirs[0].bno = read_disk_entry (siblock[indirs[0].offset]); } else indirs[0].bno = 0; -- cgit v1.2.3 From 675192bc5f687f4956da875ef1c54a5e61bf5d54 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:11:37 +0000 Subject: (read_disknode): Use read/write_disk_entry when reading/writing on-disk inode fields. (write_node): Likewise. (diskfs_set_translator): Likewise. (diskfs_get_translator): Likewise. (diskfs_S_file_get_storage_info): Likewise. --- ufs/inode.c | 86 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 88f89a37..b34c2f07 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -229,38 +229,39 @@ read_disknode (struct node *np) st->st_fstype = FSTYPE_UFS; st->st_fsid = fsid; st->st_ino = np->dn->number; - st->st_gen = di->di_gen; - st->st_rdev = di->di_rdev; - st->st_mode = di->di_model | (di->di_modeh << 16); - st->st_nlink = di->di_nlink; - st->st_size = di->di_size; + st->st_gen = read_disk_entry (di->di_gen); + st->st_rdev = read_disk_entry(di->di_rdev); + st->st_mode = (read_disk_entry (di->di_model) + | (read_disk_entry (di->di_modeh) << 16); + st->st_nlink = read_disk_entry (di->di_nlink); + st->st_size = read_disk_entry (di->di_size); #ifdef notyet st->st_atimespec = di->di_atime; st->st_mtimespec = di->di_mtime; st->st_ctimespec = di->di_ctime; #else - st->st_atime = di->di_atime.ts_sec; - st->st_atime_usec = di->di_atime.ts_nsec / 1000; - st->st_mtime = di->di_mtime.ts_sec; - st->st_mtime_usec = di->di_mtime.ts_nsec / 1000; - st->st_ctime = di->di_ctime.ts_sec; - st->st_ctime_usec = di->di_ctime.ts_nsec / 1000; + st->st_atime = read_disk_entry (di->di_atime.ts_sec); + st->st_atime_usec = read_disk_entry (di->di_atime.ts_nsec) / 1000; + st->st_mtime = read_disk_entry (di->di_mtime.ts_sec); + st->st_mtime_usec = read_disk_entry (di->di_mtime.ts_nsec) / 1000; + st->st_ctime = read_disk_entry (di->di_ctime.ts_sec); + st->st_ctime_usec = read_disk_entry (di->di_ctime.ts_nsec) / 1000; #endif st->st_blksize = sblock->fs_bsize; - st->st_blocks = di->di_blocks; - st->st_flags = di->di_flags; + st->st_blocks = read_disk_entry (di->di_blocks); + st->st_flags = read_disk_entry (di->di_flags); if (sblock->fs_inodefmt < FS_44INODEFMT) { - st->st_uid = di->di_ouid; - st->st_gid = di->di_ogid; + st->st_uid = read_disk_entry (di->di_ouid); + st->st_gid = read_disk_entry (di->di_ogid); st->st_author = 0; } else { - st->st_uid = di->di_uid; - st->st_gid = di->di_gid; - st->st_author = di->di_author; + st->st_uid = read_disk_entry (di->di_uid); + st->st_gid = read_disk_entry (di->di_gid); + st->st_author = read_disk_entry (di->di_author); if (st->st_author == -1) st->st_author = st->st_uid; } @@ -305,55 +306,55 @@ write_node (struct node *np) if (err) return; - di->di_gen = st->st_gen; + write_disk_entry (di->di_gen, st->st_gen); if (S_ISBLK (st->st_mode) || S_ISCHR (st->st_mode)) - di->di_rdev = st->st_rdev; + write_disk_entry (di->di_rdev, st->st_rdev); /* We happen to know that the stat mode bits are the same as the ufs mode bits. */ if (compat_mode == COMPAT_GNU) { - di->di_model = st->st_mode & 0xffff; - di->di_modeh = (st->st_mode >> 16) & 0xffff; + write_disk_entry (di->di_model, st->st_mode & 0xffff); + write_disk_entry (di->di_modeh, (st->st_mode >> 16) & 0xffff); } else { - di->di_model = st->st_mode & 0xffff; + write_disk_entry (di->di_model, st->st_mode & 0xffff); di->di_modeh = 0; } if (compat_mode != COMPAT_BSD42) { - di->di_uid = st->st_uid; - di->di_gid = st->st_gid; + write_disk_entry (di->di_uid, st->st_uid); + write_disk_entry (di->di_gid, st->st_gid); } if (sblock->fs_inodefmt < FS_44INODEFMT) { - di->di_ouid = st->st_uid & 0xffff; - di->di_ogid = st->st_gid & 0xffff; + write_disk_entry (di->di_ouid, st->st_uid & 0xffff); + write_disk_entry (di->di_ogid, st->st_gid & 0xffff); } else if (compat_mode == COMPAT_GNU) - di->di_author = st->st_author; + write_disk_entry (di->di_author, st->st_author); - di->di_nlink = st->st_nlink; - di->di_size = st->st_size; + write_disk_entry (di->di_nlink, st->st_nlink); + write_disk_entry (di->di_size, st->st_size); #ifdef notyet di->di_atime = st->st_atimespec; di->di_mtime = st->st_mtimespec; di->di_ctime = st->st_ctimespec; #else - di->di_atime.ts_sec = st->st_atime; - di->di_atime.ts_nsec = st->st_atime_usec * 1000; - di->di_mtime.ts_sec = st->st_mtime; - di->di_mtime.ts_nsec = st->st_mtime_usec * 1000; - di->di_ctime.ts_sec = st->st_ctime; - di->di_ctime.ts_nsec = st->st_ctime_usec * 1000; + write_disk_entry (di->di_atime.ts_sec, st->st_atime); + write_disk_entry (di->di_atime.ts_nsec, st->st_atime_usec * 1000); + write_disk_entry (di->di_mtime.ts_sec, st->st_mtime); + write_disk_entry (di->di_mtime.ts_nsec, st->st_mtime_usec * 1000); + write_disk_entry (di->di_ctime.ts_sec, st->st_ctime); + write_disk_entry (di->di_ctime.ts_nsec, st->st_ctime_usec * 1000); #endif - di->di_blocks = st->st_blocks; - di->di_flags = st->st_flags; + write_disk_entry (di->di_blocks, st->st_blocks); + write_disk_entry (di->di_flags, st->st_flags); diskfs_end_catch_exception (); np->dn_stat_dirty = 0; @@ -524,7 +525,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, return err; di = dino (np->dn->number); - blkno = di->di_trans; + blkno = read_disk_entry (di->di_trans); if (namelen && !blkno) { @@ -535,7 +536,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, diskfs_end_catch_exception (); return err; } - di->di_trans = blkno; + write_disk_entry (di->di_trans, blkno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; } @@ -580,7 +581,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) if (err) return err; - blkno = (dino (np->dn->number))->di_trans; + blkno = read_disk_entry ((dino (np->dn->number))->di_trans); assert (blkno); transloc = disk_image + fsaddr (sblock, blkno); @@ -670,7 +671,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, { for (i = 0; i < NDADDR; i++) { - (*addresses)[2 * i] = fsbtodb (sblock, di->di_db[i]); + (*addresses)[2 * i] = fsbtodb (sblock, + read_disk_entry (di->di_db[i])); if ((i + 1) * sblock->fs_bsize > np->allocsize) (*addresses)[2 * i + 1] = np->allocsize - i * sblock->fs_bsize; else -- cgit v1.2.3 From 4e2aa139eaca196f8479e52bb73a30029d534a8e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:17:36 +0000 Subject: Include . Fixup. --- ufs/alloc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index fdd0aa59..9efd2eb3 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -55,6 +55,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" #include +#include + /* These don't work *at all* here; don't even try setting them. */ #undef DIAGNOSTIC @@ -91,7 +93,7 @@ alloc_sync (struct node *np) /* Byteswap everything in CGP. */ void -swab_cg (struct cg *cgp) +swab_cg (struct cg *cg) { int i, j; @@ -177,14 +179,14 @@ read_cg (int cg, struct cg **cgpp) if (swab_disk) { - *cgp = malloc (sblock->fs_cgsize); - bcopy (diskcg, *cgp, sblock->fs_cgsize); - swab_cg (*cgp); + *cgpp = malloc (sblock->fs_cgsize); + bcopy (diskcg, *cgpp, sblock->fs_cgsize); + swab_cg (*cgpp); return 1; } else { - *cgp = diskcg; + *cgpp = diskcg; return 0; } } @@ -194,8 +196,9 @@ read_cg (int cg, struct cg **cgpp) void release_cgp (struct cg *cgp) { + int cgx = cgp->cg_cgx; swab_cg (cgp); - bcopy (cgp, cg_locate (cg), sblock->fs_cgsize); + bcopy (cgp, cg_locate (cgx), sblock->fs_cgsize); free (cgp); } -- cgit v1.2.3 From dbfeebc5456f832d8b6daf0b563587b5e4ca4f91 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:20:26 +0000 Subject: (read_disk_entry): Proper syntax. --- ufs/ufs.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index dba7acd9..2c1a3fde 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -190,14 +190,16 @@ swab_long (long arg) /* Return ENTRY, after byteswapping it if necessary */ #define read_disk_entry(entry) \ ({ \ + typeof (entry) ret; \ if (!swab_disk || sizeof (entry) == 1) \ - (entry); \ + ret = (entry); \ else if (sizeof (entry) == 2) \ - swab_short (entry); \ + ret = swab_short (entry); \ else if (sizeof (entry) == 4) \ - swab_long (entry); \ + ret = swab_long (entry); \ else \ abort (); \ + ret; \ }) /* Execute A = B, but byteswap it along the way if necessary */ -- cgit v1.2.3 From 15ec6058ff8a845747c1f59e815806304b7c7e57 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:32:36 +0000 Subject: (ffs_blkfree): final fixup. --- ufs/alloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 9efd2eb3..90ce68f5 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -139,7 +139,7 @@ swab_cg (struct cg *cg) else { /* Old format cylinder group... */ - struct ocg *ocg = cg; + struct ocg *ocg = (struct ocg *) cg; if (swab_long (ocg->cg_magic) != CG_MAGIC && ocg->cg_magic != CG_MAGIC) @@ -194,7 +194,7 @@ read_cg (int cg, struct cg **cgpp) /* Caller of read_cg is done with cg; write it back to disk (swapping it along the way) and free the memory allocated in read_cg. */ void -release_cgp (struct cg *cgp) +release_cg (struct cg *cgp) { int cgx = cgp->cg_cgx; swab_cg (cgp); @@ -902,7 +902,7 @@ ffs_fragextend(struct node *np, int nsize) { register struct fs *fs; - register struct cg *cgp; + struct cg *cgp; long bno; int frags, bbase; int i; @@ -984,7 +984,7 @@ ffs_alloccg(struct node *np, int size) { register struct fs *fs; - register struct cg *cgp; + struct cg *cgp; register int i; int bno, frags, allocsiz; int releasecg; @@ -1050,7 +1050,7 @@ ffs_alloccg(struct node *np, cgp->cg_frsum[i]++; if (releasecg) - release_cg (cgp) + release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); csum_dirty = 1; sblock_dirty = 1; @@ -1302,7 +1302,7 @@ ffs_nodealloccg(struct node *np, int mode) { register struct fs *fs; - register struct cg *cgp; + struct cg *cgp; int start, len, loc, map, i; int releasecg; @@ -1323,7 +1323,7 @@ ffs_nodealloccg(struct node *np, if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { /* brelse(bp); */ if (releasecg) - release_cg (cg); + release_cg (cgp); return 0; } cgp->cg_time = diskfs_mtime->seconds; @@ -1385,7 +1385,7 @@ ffs_blkfree(register struct node *np, long size) { register struct fs *fs; - register struct cg *cgp; + struct cg *cgp; daddr_t blkno; int i, cg, blk, frags, bbase; int releasecg; @@ -1407,7 +1407,7 @@ ffs_blkfree(register struct node *np, } cgp = (struct cg *)bp->b_data; #else - releasecg = cg_read (cg, &cgp); + releasecg = read_cg (cg, &cgp); #endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ @@ -1489,7 +1489,7 @@ void diskfs_free_node (struct node *np, mode_t mode) { register struct fs *fs; - register struct cg *cgp; + struct cg *cgp; ino_t ino = np->dn->number; int cg; int releasecg; -- cgit v1.2.3 From 1f5db073a1c103fc54f9568c53d3d0c17fd32767 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:35:14 +0000 Subject: (diskfs_dirempty): node_update -> diskfs_node_update. --- ufs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 67b3645e..ed7ac212 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -718,14 +718,14 @@ diskfs_dirempty(struct node *dp, if (!diskfs_readonly) dp->dn_set_atime = 1; if (diskfs_synchronous) - node_update (dp, 1); + diskfs_node_update (dp, 1); return 0; } } if (!diskfs_readonly) dp->dn_set_atime = 1; if (diskfs_synchronous) - node_update (dp, 1); + diskfs_node_update (dp, 1); vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); return 1; } -- cgit v1.2.3 From 6aa169da3b5c81865dd35e7e19db0b29ba446f5b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:40:42 +0000 Subject: fixup. --- ufs/hyper.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 283a7e14..f198ff43 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -88,12 +88,10 @@ swab_sblock (struct fs *sblock) sblock->fs_cgrotor = swab_long (sblock->fs_cgrotor); sblock->fs_cpc = swab_long (sblock->fs_cpc); sblock->fs_contigsumsize = swab_long (sblock->fs_contigsumsize); - sblock->fs_maysymlinksen = swab_long (sblock->fs_maysymlinksen); + sblock->fs_maxsymlinklen = swab_long (sblock->fs_maxsymlinklen); sblock->fs_inodefmt = swab_long (sblock->fs_inodefmt); - sblock->fs_maxfilesize.val[0] = swab_long (sblock->fs_maxfilesize.val[0]); - sblock->fs_maxfilesize.val[1] = swab_long (sblock->fs_maxfilesize.val[1]); - sblock->fs_qbmask.val[0] = swab_long (sblock->fs_qbmask.val[0]); - sblock->fs_qbmask.val[1] = swab_long (sblock->fs_qbmask.val[1]); + sblock->fs_maxfilesize = swab_long_long (sblock->fs_maxfilesize); + sblock->fs_qbmask = swab_long_long (sblock->fs_qbmask); sblock->fs_state = swab_long (sblock->fs_state); sblock->fs_postblformat = swab_long (sblock->fs_postblformat); sblock->fs_nrpos = swab_long (sblock->fs_nrpos); @@ -110,7 +108,7 @@ swab_sblock (struct fs *sblock) for (i = 0; i < sblock->fs_cpc; i++) for (j = 0; j < sblock->fs_nrpos; j++) fs_postbl(sblock, j)[i] - = swab_short (sblock->fs_postbl (sblock, j)[i]); + = swab_short (fs_postbl (sblock, j)[i]); /* The rot table is all chars */ } @@ -120,7 +118,7 @@ swab_csums (struct csum *csum) { int i; - for (i = 0; i < fs_ncg; i++) + for (i = 0; i < sblock->fs_ncg; i++) { csum[i].cs_ndir = swab_long (csum[i].cs_ndir); csum[i].cs_nbfree = swab_long (csum[i].cs_nbfree); -- cgit v1.2.3 From b9050c0aaed61138e1df38d094e1c3bbf8d91e6a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:43:36 +0000 Subject: (read_disknode): typo --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index b34c2f07..ab19668f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -232,7 +232,7 @@ read_disknode (struct node *np) st->st_gen = read_disk_entry (di->di_gen); st->st_rdev = read_disk_entry(di->di_rdev); st->st_mode = (read_disk_entry (di->di_model) - | (read_disk_entry (di->di_modeh) << 16); + | (read_disk_entry (di->di_modeh) << 16)); st->st_nlink = read_disk_entry (di->di_nlink); st->st_size = read_disk_entry (di->di_size); #ifdef notyet -- cgit v1.2.3 From eb186a7fc9ce5b4c35986128e52372142af8fc37 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:46:41 +0000 Subject: (swab_long): Cleaner now. (swab_long_long): New function. --- ufs/ufs.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 2c1a3fde..c09ddeeb 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -181,10 +181,15 @@ swab_short (short arg) extern inline long swab_long (long arg) { - return (((arg & 0xff) << 24) - | ((arg & 0xff00) << 8) - | ((arg & 0xff0000) >> 8) - | ((arg & 0xff000000) >> 24)); + return ((swab_short (arg & 0xffff) << 16) + | swab_short ((arg & 0xffff0000) >> 16)); +} + +extern inline long long +swab_long_long (long long arg) +{ + return ((swab_long (arg & 0xffffffff) << 32) + | swab_long ((arg & 0xffffffff00000000) >> 32)); } /* Return ENTRY, after byteswapping it if necessary */ -- cgit v1.2.3 From 8d744ba53bed7d40baab38f390df7b60a00fd9fc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:47:47 +0000 Subject: fixup --- ufs/sizes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index a5be68ea..8e4a85e9 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -361,7 +361,7 @@ offer_data (struct node *np, { vm_address_t addr; - len = round_page (size); + len = round_page (len); assert (start % vm_page_size == 0); @@ -402,7 +402,8 @@ block_extended (struct node *np, (void *) &buf, vm_page_size); /* If this page is the last one, then zero the excess first */ if (off + vm_page_size > old_size) - bzero (buf + old_size - off, vm_page_size - (old_size - off)); + bzero ((vod *)(buf + old_size - off), + vm_page_size - (old_size - off)); offer_data (np, lbn * sblock->fs_bsize + off, vm_page_size, buf); } -- cgit v1.2.3 From f2acd811f5a476bfbf37a4bbbfcf45ca96bde450 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:50:13 +0000 Subject: (swab_long_long, swab_long): better now. --- ufs/ufs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index c09ddeeb..19ea89c3 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -181,14 +181,14 @@ swab_short (short arg) extern inline long swab_long (long arg) { - return ((swab_short (arg & 0xffff) << 16) + return ((long) (swab_short (arg & 0xffff) << 16) | swab_short ((arg & 0xffff0000) >> 16)); } extern inline long long swab_long_long (long long arg) { - return ((swab_long (arg & 0xffffffff) << 32) + return ((long long)(swab_long (arg & 0xffffffff) << 32) | swab_long ((arg & 0xffffffff00000000) >> 32)); } -- cgit v1.2.3 From 2805a17914524c003abc82c42ca2abdd98235518 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:51:31 +0000 Subject: and even better --- ufs/ufs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 19ea89c3..9fa312e6 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -181,14 +181,14 @@ swab_short (short arg) extern inline long swab_long (long arg) { - return ((long) (swab_short (arg & 0xffff) << 16) + return (((long) swab_short (arg & 0xffff) << 16) | swab_short ((arg & 0xffff0000) >> 16)); } extern inline long long swab_long_long (long long arg) { - return ((long long)(swab_long (arg & 0xffffffff) << 32) + return (((long long) swab_long (arg & 0xffffffff) << 32) | swab_long ((arg & 0xffffffff00000000) >> 32)); } -- cgit v1.2.3 From c6edef3af846eae6e278a2930eb139a306f98108 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:53:41 +0000 Subject: (swab_long_long): one more time --- ufs/ufs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 9fa312e6..06255960 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -189,7 +189,7 @@ extern inline long long swab_long_long (long long arg) { return (((long long) swab_long (arg & 0xffffffff) << 32) - | swab_long ((arg & 0xffffffff00000000) >> 32)); + | swab_long ((arg & 0xffffffff00000000lL) >> 32)); } /* Return ENTRY, after byteswapping it if necessary */ -- cgit v1.2.3 From 8ac35134d6621e4753547c3ff201a653327f3b5f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 19:00:00 +0000 Subject: (block_extended): --- ufs/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 8e4a85e9..98ec49d1 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -402,7 +402,7 @@ block_extended (struct node *np, (void *) &buf, vm_page_size); /* If this page is the last one, then zero the excess first */ if (off + vm_page_size > old_size) - bzero ((vod *)(buf + old_size - off), + bzero ((void *)(buf + old_size - off), vm_page_size - (old_size - off)); offer_data (np, lbn * sblock->fs_bsize + off, vm_page_size, buf); } -- cgit v1.2.3 From 1e4e34806c125a892fc7dc6d143ae60fec90070d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 24 Apr 1996 17:32:35 +0000 Subject: (pass1): Don't print block numbers as we go anymore. --- ufs-fsck/pass1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 47738eef..752b1131 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -164,8 +164,8 @@ pass1 () direct/indirect blocks. */ int dbwarn = 0, ibwarn = 0; - if (!preen && !(number % 10000)) - printf ("I=%d\n", number); +/* if (!preen && !(number % 10000)) + printf ("I=%d\n", number); */ if (number < ROOTINO) continue; -- cgit v1.2.3 From 71d8cb41e179e2359cf178493f34bbbb8f8c78d1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 24 Apr 1996 18:24:17 +0000 Subject: (DIRECT_NAMLEN) [LITTLE_ENDIAN]: Deal with case correctly where it was written without the extension on a big endian machine. --- ufs/dir.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/dir.h b/ufs/dir.h index 193e167b..1c35768a 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -90,8 +90,9 @@ struct directory_entry { /* Return the namlen from a struct direct, paying attention to whether this filesystem supports the type extension */ #if (BYTE_ORDER == LITTLE_ENDIAN) -#define DIRECT_NAMLEN(dp) (direct_symlink_extension ? (dp)->d_namlen : \ - (dp)->d_type) +#define DIRECT_NAMLEN(dp) (direct_symlink_extension || swab_disk \ + ? (dp)->d_namlen \ + : (dp)->(dp)->d_type) #else #define DIRECT_NAMLEN(dp) ((dp)->d_namlen) #endif -- cgit v1.2.3 From 39a70332f87c9b83c6c18a4a4d8c23b4aaad69e0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 24 Apr 1996 18:26:16 +0000 Subject: (DIRECT_NAMLEN) [! LITTLE_ENDIAN]: Deal correctly with the case where it was written on a little endian machine without the extension. --- ufs/dir.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs/dir.h b/ufs/dir.h index 1c35768a..2b1e3469 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -92,9 +92,11 @@ struct directory_entry { #if (BYTE_ORDER == LITTLE_ENDIAN) #define DIRECT_NAMLEN(dp) (direct_symlink_extension || swab_disk \ ? (dp)->d_namlen \ - : (dp)->(dp)->d_type) + : (dp)->d_type) #else -#define DIRECT_NAMLEN(dp) ((dp)->d_namlen) +#define DIRECT_NAMLEN(dp) (!direct_symlink_extension && swab_disk \ + ? (dp)->d_type \ + : (dp)->d_namlen) #endif /* -- cgit v1.2.3 From 3d3e9226d2a674801babedc7b439faeef8c68f1f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Apr 1996 20:09:04 +0000 Subject: (makemode): Now `servers'. (targets): Renamed from `target'; now include ufs.static. (ufs.static-LDFLAGS): Renamed from `LDFLAGS'. (ufs.static): Depend on same things as `ufs'. (include ../Makeconf): Must come before dependency information. --- ufs/Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index a4601cce..280e155c 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,5 +1,5 @@ -# Copyright (C) 1994, 1995 Free Software Foundation +# Copyright (C) 1994, 1995, 1996 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 @@ -16,17 +16,18 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dir := ufs -makemode := server +makemode := servers -target = ufs +targets = ufs ufs.static 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 LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) -LDFLAGS += -static - -ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a +ufs.static-LDFLAGS += -static include ../Makeconf + +ufs.static ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a + -- cgit v1.2.3 From bed56e5a62ff6f9822532a4aff99550d42a4f303 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Apr 1996 20:20:32 +0000 Subject: (fix_denied): New variable. --- ufs-fsck/fsck.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 6dbd0886..437b1737 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -113,6 +113,8 @@ int preen; int readfd, writefd; +int fix_denied; + int fsmodified; int lfdir; -- cgit v1.2.3 From ecb321ae72c4e515a5e7b978e343b5b39ae0b03c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Apr 1996 20:21:55 +0000 Subject: (reply): Set fix_denied anytime we return 0. --- ufs-fsck/utilities.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 32ce52d7..e83cb2f5 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -1,5 +1,5 @@ /* Miscellaneous functions for fsck - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -235,6 +235,7 @@ reply (char *question) putchar ('\n'); if (!persevere && (nowrite || writefd < 0)) { + fix_denied = 1; printf ("%s? no\n\n", question); return 0; } @@ -252,11 +253,20 @@ reply (char *question) c = getchar (); while (c != '\n' && getchar () != '\n') if (feof (stdin)) - return 0; + { + fix_denied = 1; + return 0; + } } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N'); putchar ('\n'); - return c == 'y' || c == 'Y'; + if (c == 'y' || c == 'Y') + return 1; + else + { + fix_denied = 1; + return 0; + } } } -- cgit v1.2.3 From da5fab82478cd6186284467a92caed154f7d625d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Apr 1996 20:23:41 +0000 Subject: (pass5): If not marked clean, but now it is, then offer to mark it clean. --- ufs-fsck/pass5.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index c6ca29c7..5559d37c 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -329,7 +329,7 @@ pass5 () run = 0; } - if ((i & (NBBY - 1)) 1= (NBBY - 1)) + if ((i & (NBBY - 1)) != (NBBY - 1)) bit <<= 1; else { @@ -420,6 +420,16 @@ pass5 () } } + if (sblock->fs_clean == 0 && !fix_denied) + { + if (preen || reply ("MARK FILESYSTEM CLEAN")) + { + pfix ("FILESYSTEM MARKED CLEAN"); + sblock->fs_clean = 1; + writesb = 1; + } + } + if (writesb) writeblock (SBLOCK, sblock, SBSIZE); -- cgit v1.2.3 From da923ad8fdb77b2eb6ee1753ba312ed61ddd86a0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 26 Apr 1996 20:29:05 +0000 Subject: (allocino): Parenthesize test correctly. --- ufs-fsck/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index afb8b1a4..b2973c9d 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -1,5 +1,5 @@ /* Inode allocation, deallocation, etc. - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -138,7 +138,7 @@ allocino (ino_t request, mode_t mode) return 0; } - if (mode & IFMT == IFDIR) + if ((mode & IFMT) == IFDIR) inodestate[ino] = DIRECTORY | DIR_REF; else inodestate[ino] = REG; -- cgit v1.2.3 From 34b6f4f789decdf2db075ed519c159ddf13c3465 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 30 Apr 1996 14:03:40 +0000 Subject: (include ../Makeconf): BEFORE dependencies. ($(prefix)/dev/MAKEDEV): Find MAKEDEV in $(srcdir). --- devio/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devio/Makefile b/devio/Makefile index 08f9e4a1..a1494a55 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -1,6 +1,6 @@ # Makefile for devio # -# Copyright (C) 1995 Free Software Foundation, Inc. +# Copyright (C) 1995, 1996 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 @@ -26,11 +26,11 @@ DIST_FILES = MAKEDEV OBJS = $(SRCS:.c=.o) -devio: $(OBJS) ../libtrivfs/libtrivfs.a ../libpager/libpager.a ../libports/libports.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a - include ../Makeconf +devio: $(OBJS) ../libtrivfs/libtrivfs.a ../libpager/libpager.a ../libports/libports.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a + install: $(prefix)/dev/MAKEDEV $(prefix)/dev/MAKEDEV: MAKEDEV - $(INSTALL_PROGRAM) MAKEDEV $(prefix)/dev/MAKEDEV + $(INSTALL_PROGRAM) $(srcdir)/MAKEDEV $(prefix)/dev/MAKEDEV -- cgit v1.2.3 From 87c86bfb2e48c45807ce51ef67643ab08ec1b56e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 30 Apr 1996 14:06:13 +0000 Subject: (include ../Makeconf): BEFORE dependencies. (all): Delete target. ($(targets)): Each target depends on its associated .o. --- ufs-utils/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index 01845450..9e8a68ab 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -28,9 +28,10 @@ installationdir = $(sbindir) OBJS = $(SRCS:.c=.o) -all: $(targets) +include ../Makeconf mkfs.ufs: mkfs.o dlabel.o ../libshouldbeinlibc/libshouldbeinlibc.a -include ../Makeconf +$(targets): %: %.o + -- cgit v1.2.3 From cf0e1234317a81251e24f08948a649769c259fc9 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 30 Apr 1996 14:15:46 +0000 Subject: ($(targets)): do it right... --- ufs-utils/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index 9e8a68ab..23e437ee 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -32,6 +32,6 @@ include ../Makeconf mkfs.ufs: mkfs.o dlabel.o ../libshouldbeinlibc/libshouldbeinlibc.a -$(targets): %: %.o +$(targets): %.ufs: %.o -- cgit v1.2.3 From 2817245407b6cf0cfcb6864ebe3e3cd4506db61c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 30 Apr 1996 17:38:37 +0000 Subject: (diskfs_grow): In last offer_data, don't offer a block number as an address. --- ufs/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 98ec49d1..5694c0b5 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -615,7 +615,7 @@ diskfs_grow (struct node *np, indirs[0].bno = bno; write_disk_entry (siblock[indirs[0].offset], bno); record_poke (siblock, sblock->fs_bsize); - offer_data (np, lbn, sblock->fs_bsize, zeroblock); + offer_data (np, lbn * sblock->fs_bsize, sblock->fs_bsize, zeroblock); } out: -- cgit v1.2.3 From 38549befba788a8e99eca5bebe16856154e3460a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 1 May 1996 00:57:15 +0000 Subject: (main): Don't print large obnoxious banner if PREEN. --- ufs-fsck/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 869ad258..f2f323cf 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -98,7 +98,7 @@ main (int argc, char **argv) printf ("** Phase 5 -- Check Cyl Groups\n"); pass5 (); - if (fsmodified) + if (fsmodified && !preen) printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n"); exit (fsmodified ? 2 : 0); -- cgit v1.2.3 From 09199ee723e06c8cfe29952cb1390d0029d0b572 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 1 May 1996 00:57:41 +0000 Subject: (pass5): Be sure to call pwarn before pfix. --- ufs-fsck/pass5.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 5559d37c..b91341cf 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -168,7 +168,7 @@ pass5 () writecg = 0; if (!cg_chkmagic (cg)) - pfatal ("CG %d: BAD MAGIC NUMBER\n", c); + pfatal ("CG %d: BAD MAGIC NUMBER", c); /* Compute first and last data block addresses in this group */ dbase = cgbase (sblock, c); @@ -422,9 +422,10 @@ pass5 () if (sblock->fs_clean == 0 && !fix_denied) { - if (preen || reply ("MARK FILESYSTEM CLEAN")) + pwarn ("FILESYSTEM MODIFIED"); + if (preen || reply ("MARK CLEAN")) { - pfix ("FILESYSTEM MARKED CLEAN"); + pfix ("MARKED CLEAN"); sblock->fs_clean = 1; writesb = 1; } -- cgit v1.2.3 From f2d1a3bc989502346668c3a8b6ad8512deff75de Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 1 May 1996 02:14:08 +0000 Subject: (AC_OUTPUT): If not in $srcdir, create Makeconf does includes real one. --- configure.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index dc5039d4..07d75219 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.3 1996/03/25 08:09:03 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.4 1996/05/01 02:14:08 roland Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -42,7 +42,11 @@ else echo ${file}:build.mk.in; done`" fi -AC_OUTPUT(config.make ${makefiles}) +AC_OUTPUT(config.make ${makefiles}, + [if test `cd $srcdir; /bin/pwd` != `/bin/pwd`; then + rm -f Makeconf + echo 'include $(top_srcdir)/Makeconf' >Makeconf + fi]) dnl Local Variables: dnl comment-start: "dnl " -- cgit v1.2.3 From a6d48fb60ac54871a9df91788235104478bf2bd4 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 1 May 1996 02:19:03 +0000 Subject: (makefiles): Add Makeconf:build.mkcf.in. --- configure.in | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/configure.in b/configure.in index 07d75219..01c41005 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.4 1996/05/01 02:14:08 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.5 1996/05/01 02:19:03 roland Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -38,15 +38,12 @@ else # We are configuring in a separate build tree. # Create a Makefile in the top-level build directory and # one for each subdirectory Makefile in the source. - makefiles="`cd $srcdir; for file in Makefile */Makefile; do \ + makefiles="Makeconf:build.mkcf.in \ + `cd $srcdir; for file in Makefile */Makefile; do \ echo ${file}:build.mk.in; done`" fi -AC_OUTPUT(config.make ${makefiles}, - [if test `cd $srcdir; /bin/pwd` != `/bin/pwd`; then - rm -f Makeconf - echo 'include $(top_srcdir)/Makeconf' >Makeconf - fi]) +AC_OUTPUT(config.make ${makefiles}) dnl Local Variables: dnl comment-start: "dnl " -- cgit v1.2.3 From 9ab02f1c0b5e4b9e0478021c6de486ca6f072f2f Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 00:56:41 +0000 Subject: (pass5): Vary clean msg depending on whether FSMODIFIED. Use new printing functions. --- ufs-fsck/pass5.c | 58 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index b91341cf..2ec68b68 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -168,7 +168,7 @@ pass5 () writecg = 0; if (!cg_chkmagic (cg)) - pfatal ("CG %d: BAD MAGIC NUMBER", c); + warning (1, "CG %d: BAD MAGIC NUMBER", c); /* Compute first and last data block addresses in this group */ dbase = cgbase (sblock, c); @@ -199,36 +199,42 @@ pass5 () newcg->cg_irotor = cg->cg_irotor; if (newcg->cg_rotor > newcg->cg_ndblk) { - pwarn ("ILLEGAL ROTOR VALUE IN CG %d", c); + problem (0, "ILLEGAL ROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); newcg->cg_rotor = 0; cg->cg_rotor = 0; writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } if (newcg->cg_frotor > newcg->cg_ndblk) { - pwarn ("ILLEGAL FROTOR VALUE IN CG %d", c); + problem (0, "ILLEGAL FROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); newcg->cg_frotor = 0; cg->cg_frotor = 0; writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } if (newcg->cg_irotor > newcg->cg_niblk) { - pwarn ("ILLEGAL IROTOR VALUE IN CG %d", c); + problem (0, "ILLEGAL IROTOR VALUE IN CG %d", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); newcg->cg_irotor = 0; cg->cg_irotor = 0; writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } /* Zero the block maps and summary areas */ @@ -355,47 +361,55 @@ pass5 () /* Check counts in superblock */ if (bcmp (&newcg->cg_cs, &sbcsums[c], sizeof (struct csum))) { - pwarn ("FREE BLK COUNTS FOR CG %d WRONG IN SUPERBLOCK", c); + problem (0, "FREE BLK COUNTS FOR CG %d WRONG IN SUPERBLOCK", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); bcopy (&newcg->cg_cs, &sbcsums[c], sizeof (struct csum)); writecsum = 1; + pfix ("FIXED"); } + else + pfail (0); } /* Check inode and block maps */ if (bcmp (cg_inosused (newcg), cg_inosused (cg), mapsize)) { - pwarn ("BLKS OR INOS MISSING IN CG %d BIT MAPS", c); + problem (0, "BLKS OR INOS MISSING IN CG %d BIT MAPS", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); bcopy (cg_inosused (newcg), cg_inosused (cg), mapsize); writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } if (bcmp (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize)) { - pwarn ("SUMMARY INFORMATION FOR CG %d BAD", c); + problem (0, "SUMMARY INFORMATION FOR CG %d BAD", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); bcopy (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize); writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } if (bcmp (newcg, cg, basesize)) { - pwarn ("CYLINDER GROUP %d BAD", c); + problem (0, "CYLINDER GROUP %d BAD", c); if (preen || reply ("FIX")) { - pfix ("FIXED"); bcopy (newcg, cg, basesize); writecg = 1; + pfix ("FIXED"); } + else + pfail (0); } if (writecg) @@ -409,26 +423,30 @@ pass5 () if (bcmp (&cstotal, &sblock->fs_cstotal, sizeof (struct csum))) { - pwarn ("TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK"); + problem (0, "TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK"); if (preen || reply ("FIX")) { - pfix ("FIXED"); bcopy (&cstotal, &sblock->fs_cstotal, sizeof (struct csum)); sblock->fs_ronly = 0; sblock->fs_fmod = 0; writesb = 1; + pfix ("FIXED"); } + else + pfail (0); } if (sblock->fs_clean == 0 && !fix_denied) { - pwarn ("FILESYSTEM MODIFIED"); + problem (0, fsmodified ? "FILESYSTEM MODIFIED" : "FILESYSTEM UNCLEAN"); if (preen || reply ("MARK CLEAN")) { - pfix ("MARKED CLEAN"); sblock->fs_clean = 1; writesb = 1; + pfix ("MARKED CLEAN"); } + else + pfail ("LEFT UNCLEAN"); } if (writesb) @@ -445,6 +463,6 @@ pass5 () readblock (fsbtodb (sblock, sblock->fs_csaddr), test, fragroundup (sblock, sblock->fs_cssize)); if (bcmp (test, sbcsums, fragroundup (sblock, sblock->fs_cssize))) - printf ("CSUM write inconsistent"); + warning (0, "CSUM WRITE INCONSISTENT"); } } -- cgit v1.2.3 From 8ce477cec831e25e2705fe5ebf290e5e2c895369 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 00:58:03 +0000 Subject: (main): Implement clean-bit checking in preen mode; print summary statistics. (main, options): Add --force & --silent options. (preen, num_files): New variables. --- ufs-fsck/main.c | 79 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index f2f323cf..2bf12fbf 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -26,13 +26,22 @@ char *lfname = "lost+found"; mode_t lfmode = 0755; +/* Terse automatic mode for noninteractive use; punts on severe problems. */ +int preen = 0; + +/* Total number of files found on the partition. */ +long num_files = 0; + static struct argp_option options[] = { - {"preen", 'p', 0, 0, "Terse automatic mode"}, + {"preen", 'p', 0, 0, "Terse automatic mode", 1}, {"yes", 'y', 0, 0, "Automatically answer yes to all questions"}, {"no", 'n', 0, 0, "Automatically answer no to all questions"}, {"lost+found", 'l', "NAME", 0, "The name of the lost+found directory in /"}, {"lf-mode", 'm', "MODE", 0, "The mode of the lost+found directory in /"}, + {0, 0, 0, 0, "In --preen mode, the following also apply:", 2}, + {"force", 'f', 0, 0, "Check even if clean"}, + {"silent", 's', 0, 0, "Only print diagostic messages"}, {0, 0} }; char *args_doc = "DEVICE"; @@ -40,6 +49,7 @@ char *args_doc = "DEVICE"; int main (int argc, char **argv) { + int silent = 0, force = 0; char *device = 0; error_t parse_opt (int key, char *arg, struct argp_state *state) { @@ -50,6 +60,8 @@ main (int argc, char **argv) case 'n': nowrite = 1; break; case 'l': lfname = arg; break; case 'm': lfmode = strtol (arg, 0, 8); break; + case 'f': force = 1; break; + case 's': silent = 1; break; case ARGP_KEY_ARG: if (!device) { @@ -71,33 +83,58 @@ main (int argc, char **argv) if (!setup (device)) exit (1); - if (!preen) - printf ("** Phase 1 -- Check Blocks and Sizes\n"); - pass1 (); - - if (duplist) + if (preen && sblock->fs_clean && !force) { - if (!preen) - printf ("** Phase 1b -- Rescan for More Duplicates\n"); - pass1b (); + if (! silent) + warning (0, "FILESYSTEM CLEAN"); } + else + { + if (!preen) + printf ("** Phase 1 -- Check Blocks and Sizes\n"); + pass1 (); - if (!preen) - printf ("** Phase 2 -- Check Pathnames\n"); - pass2 (); + if (duplist) + { + if (!preen) + printf ("** Phase 1b -- Rescan for More Duplicates\n"); + pass1b (); + } - if (!preen) - printf ("** Phase 3 -- Check Connectivity\n"); - pass3 (); + if (!preen) + printf ("** Phase 2 -- Check Pathnames\n"); + pass2 (); - if (!preen) - printf ("** Phase 4 -- Check Reference Counts\n"); - pass4 (); + if (!preen) + printf ("** Phase 3 -- Check Connectivity\n"); + pass3 (); - if (!preen) - printf ("** Phase 5 -- Check Cyl Groups\n"); - pass5 (); + if (!preen) + printf ("** Phase 4 -- Check Reference Counts\n"); + pass4 (); + if (!preen) + printf ("** Phase 5 -- Check Cyl Groups\n"); + pass5 (); + + if (! silent) + /* Print summary statistics. */ + { + long num_ffree = sblock->fs_cstotal.cs_nffree; + long num_bfree = sblock->fs_cstotal.cs_nbfree; + long tot_ffree = num_ffree + sblock->fs_frag * num_bfree; + warning (0, + "%ld files, %ld used, %ld free" + " (%ld frags, %ld blocks, %ld.%ld%% fragmentation)", + num_files, sblock->fs_dsize - tot_ffree, tot_ffree, + num_ffree, num_bfree, + (num_ffree * 100) / sblock->fs_dsize, + (((num_ffree * 1000 + sblock->fs_dsize / 2) + / sblock->fs_dsize) + % 10)); + } + } + if (fsmodified && !preen) printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n"); -- cgit v1.2.3 From 933ebdadbb2062acd28148c9a65e96e8b3360048 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 00:58:50 +0000 Subject: (pass1): Increment NUM_FILES. When clearing inode due to bad blocks, continue. Use new printing functions. --- ufs-fsck/pass1.c | 75 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 752b1131..0b9a04cf 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -69,22 +69,24 @@ pass1 () blkerror = 1; wasbad = 1; if (nblkrngerrors == 0) - pwarn ("I=%d HAS BAD BLOCKS\n", number); + warning (0, "I=%d HAS BAD BLOCKS", number); if (nblkrngerrors++ > MAXBAD) { - pwarn ("EXCESSIVE BAD BLKS I=%d", number); + problem (0, "EXCESSIVE BAD BLKS I=%d", number); if (preen || reply ("SKIP")) { - pfix ("SKIPPING"); + pfail ("SKIPPING"); return RET_STOP; } + else + pfix ("CONTINUING"); } } for (; nfrags > 0; bno++, nfrags--) { if (outofrange && check_range (bno, 1)) - pwarn ("BAD BLOCK %lu\n", bno); + warning (0, "BAD BLOCK %lu", bno); else { if (!testbmap (bno)) @@ -93,17 +95,19 @@ pass1 () { blkerror = 1; if (nblkduperrors == 0) - pwarn ("I=%d HAS DUPLICATE BLOCKS\n", number); - pwarn ("DUPLICATE BLOCK %ld\n", bno); + warning (0, "I=%d HAS DUPLICATE BLOCKS", number); + warning (0, "DUPLICATE BLOCK %ld", bno); wasbad = 1; if (nblkduperrors++ > MAXBAD) { - pwarn ("EXCESSIVE DUP BLKS I=%d", number); + problem (0, "EXCESSIVE DUP BLKS I=%d", number); if (preen || reply ("SKIP")) { - pfix ("SKIPPING"); + pfail ("SKIPPING"); return RET_STOP; } + else + pfix ("CONTINUING"); } new = malloc (sizeof (struct dups)); new->dup = bno; @@ -184,12 +188,14 @@ pass1 () || DI_MODE (dp) || dp->di_size) { - pwarn ("PARTIALLY ALLOCATED INODE I=%d", number); + problem (0, "PARTIALLY ALLOCATED INODE I=%d", number); if (preen || reply ("CLEAR")) { - pfix ("CLEARED"); clear_inode (number, dp); + pfix ("CLEARED"); } + else + pfail (0); } inodestate[number] = UNALLOC; } @@ -204,7 +210,7 @@ pass1 () if (dp->di_size + sblock->fs_bsize - 1 < dp->di_size) { - pfatal ("OVERFLOW IN FILE SIZE I=%d (SIZE == %lld)", number, + problem (1, "OVERFLOW IN FILE SIZE I=%d (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -213,7 +219,7 @@ pass1 () continue; } inodestate[number] = UNALLOC; - pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED", number); holdallblocks = 1; } @@ -271,8 +277,7 @@ pass1 () break; default: - pfatal ("UNKNOWN FILE TYPE I=%d (MODE=%ol)\n", - number, mode); + problem (1, "UNKNOWN FILE TYPE I=%d (MODE=%ol)", number, mode); if (reply ("CLEAR")) { clear_inode (number, dp); @@ -281,14 +286,14 @@ pass1 () } inodestate[number] = UNALLOC; holdallblocks = 1; - pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d " - "AS ALLOCATED\n", number); + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d " + "AS ALLOCATED", number); ndb = 0; } if (ndb < 0) { - pfatal ("BAD FILE SIZE I= %d (SIZE == %lld)", number, + problem (1, "BAD FILE SIZE I= %d (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -297,8 +302,8 @@ pass1 () continue; } inodestate[number] = UNALLOC; - pwarn ("WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED\n", - number); + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED", + number); holdallblocks = 1; } @@ -312,7 +317,7 @@ pass1 () && (type == IFBLK || type == IFCHR || type == IFSOCK || type == IFIFO)) { - pfatal ("SPECIAL NODE I=%d (MODE=%ol) HAS SIZE %lld\n", + problem (1, "SPECIAL NODE I=%d (MODE=%ol) HAS SIZE %lld", number, mode, dp->di_size); if (reply ("TRUNCATE")) { @@ -333,14 +338,16 @@ pass1 () if (!dbwarn) { dbwarn = 1; - pwarn ("INODE I=%d HAS EXTRA DIRECT BLOCKS", + problem (0, "INODE I=%d HAS EXTRA DIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { - pfix ("DEALLOCATED"); dp->di_db[lbn] = 0; dbwarn = 2; + pfix ("DEALLOCATED"); } + else + pfail (0); } else if (dbwarn == 2) dp->di_db[lbn] = 0; @@ -358,14 +365,16 @@ pass1 () if (ibwarn) { ibwarn = 1; - pwarn ("INODE I=%d HAS EXTRA INDIRECT BLOCKS", + problem (0, "INODE I=%d HAS EXTRA INDIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { - pfix ("DEALLOCATED"); dp->di_ib[lbn] = 0; ibwarn = 2; + pfix ("DEALLOCATED"); } + else + pfail (0); } else if (ibwarn == 2) dp->di_ib[lbn] = 0; @@ -395,23 +404,23 @@ pass1 () if (blkerror) { if (preen) - pfatal ("DUPLICATE or BAD BLOCKS"); + warning (1, "DUPLICATE or BAD BLOCKS"); else { - pwarn ("I=%d has ", number); + problem (0, "I=%d has ", number); if (nblkduperrors) { - printf ("%d DUPLICATE BLOCKS", nblkduperrors); + pextend ("%d DUPLICATE BLOCKS", nblkduperrors); if (nblkrngerrors) - printf (" and "); + pextend (" and "); } if (nblkrngerrors) - printf ("%d BAD BLOCKS", nblkrngerrors); - printf ("\n"); + pextend ("%d BAD BLOCKS", nblkrngerrors); if (reply ("CLEAR")) { clear_inode (number, dp); inodestate[number] = UNALLOC; + continue; } else if (inodestate[number] == DIRECTORY) inodestate[number] = BADDIR; @@ -419,7 +428,7 @@ pass1 () } else if (dp->di_blocks != nblocks) { - pwarn ("INCORRECT BLOCK COUNT I=%d (%ld should be %d)", + problem (0, "INCORRECT BLOCK COUNT I=%d (%ld should be %d)", number, dp->di_blocks, nblocks); if (preen || reply ("CORRECT")) { @@ -427,8 +436,12 @@ pass1 () write_inode (number, dp); pfix ("CORRECTED"); } + else + pfail (0); } + num_files++; + if (type == IFDIR) record_directory (dp, number); } -- cgit v1.2.3 From 67bc3298ce3574dd53b084ad0c4776f9f4a7555c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 00:59:04 +0000 Subject: (allocino, freeino): Frob NUM_FILES. --- ufs-fsck/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index b2973c9d..7c81f39a 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -152,6 +152,7 @@ allocino (ino_t request, mode_t mode) dino.di_mtime = dino.di_ctime = dino.di_atime; dino.di_size = 0; dino.di_blocks = 0; + num_files++; write_inode (ino, &dino); typemap[ino] = IFTODT (mode); return ino; @@ -197,7 +198,6 @@ freeino (ino_t inum) clear_inode (inum, &dino); inodestate[inum] = UNALLOC; -} - - + num_files--; +} -- cgit v1.2.3 From 661dcbc1e978bb49ff9a0eea77696afffe1e99ea Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:00:58 +0000 Subject: (problem, warning, pextend, pfail, force): New declarations. (pinode): Update declaration. --- ufs-fsck/fsck.h | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 437b1737..7d55bea6 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -24,6 +24,9 @@ #include #include #include + +#define swab_disk 0 + #include "../ufs/fs.h" #include "../ufs/dinode.h" #include "../ufs/dir.h" @@ -101,25 +104,29 @@ struct dups *duplist; /* head of dup list */ struct dups *muldup; /* end of unique duplicate dup block numbers */ -struct fs *sblock; +extern struct fs *sblock; + +extern daddr_t maxfsblock; +extern int maxino; +extern int direct_symlink_extension; -daddr_t maxfsblock; -int maxino; -int direct_symlink_extension; +extern int newinofmt; -int newinofmt; +/* Terse automatic mode for noninteractive use; punts on severe problems. */ +extern int preen; -int preen; +extern int readfd, writefd; -int readfd, writefd; +extern int fix_denied; -int fix_denied; +extern int fsmodified; -int fsmodified; +extern int lfdir; -int lfdir; +/* Total number of files found on the partition. */ +extern daddr_t num_files; -mode_t lfmode; +extern mode_t lfmode; extern char *lfname; #define NBBY 8 @@ -167,10 +174,10 @@ void allblock_iterate (struct dinode *, int (*)(daddr_t, int, off_t)); void record_directory (struct dinode *, ino_t); struct dirinfo *lookup_directory (ino_t); +void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), noreturn)); +void warning (int, char *, ...) __attribute__ ((format (printf, 2, 3))); +void problem (int, char *, ...) __attribute__ ((format (printf, 2, 3))); +void pinode (int, ino_t, char *fmt, ...) __attribute__ ((format (printf, 3, 4))); +void pextend (char *, ...) __attribute__ ((format (printf, 1, 2))); +void pfix (char *fix), pfail (char *reason); int reply (char *); -void pfix (char *fix); -void pinode (ino_t, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -int pwarn (char *, ...) __attribute__ ((format (printf, 1, 2))); -int pfatal (char *, ...) __attribute__ ((format (printf, 1, 2))); -void errexit (char *, ...) __attribute__ ((format (printf, 1, 2), - noreturn)); -- cgit v1.2.3 From 4880f7020a76b8135586e5d1262ddf69de8a1bbe Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:01:29 +0000 Subject: (problem, warning, pextend, pfail): New functions. (pinode, pfix, reply): Use new problem recording stuff. (push_problem, resolve_problem, flush_problems): New functions. (struct problem): New type. (problems, free_problems): New variables. (retch, punt): New functions. --- ufs-fsck/utilities.c | 277 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 206 insertions(+), 71 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index e83cb2f5..d886e780 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -24,6 +24,9 @@ #include #include #include +#include + +static void retch (char *reason); /* Read disk block ADDR into BUF of SIZE bytes. */ void @@ -126,7 +129,7 @@ allocblk (int nfrags) /* Mark the frags allocated in our map */ for (k = 0; k < nfrags; k++) setbmap (i + j + k); - + return (i + j); } } @@ -157,33 +160,93 @@ check_range (daddr_t blk, int cnt) return 0; } + +struct problem { + char *desc; + struct problem *prev; +}; + +/* A queue of problems found by fsck that are waiting resolution. The front + of the list is the most recent problem found (and presumably since + previous problems haven't been resolved yet, they depend on this one being + solved for their resolution). */ +static struct problem *problems = 0; + +static struct problem *free_problems = 0; + +static void +push_problem (char *fmt, va_list args) +{ + struct problem *prob = free_problems; -/* Like printf, but exit if we are preening. */ -int -pfatal (char *fmt, ...) + if (! prob) + prob = malloc (sizeof (struct problem)); + else + problems = prob->prev; + if (! prob) + retch ("malloc failed"); + + if (vasprintf (&prob->desc, fmt, args) < 0) + retch ("vasprintf failed"); + + prob->prev = problems; + problems = prob; +} + +/* Print the most recent problem, and perhaps how it was resolved. */ +static void +resolve_problem (char *fix) { - va_list args; - int ret; + struct problem *prob = problems; + + if (! prob) + retch ("no more problems"); + + problems = prob->prev; + prob->prev = free_problems; if (preen && device_name) - printf ("%s: ", device_name); - - va_start (args, fmt); - ret = vprintf (fmt, args); - va_end (args); - putchar ('\n'); - if (preen) - exit (1); - - return ret; + printf ("%s: %s", device_name, prob->desc); + else + printf ("%s", prob->desc); + if (fix) + printf (" (%s)\n", fix); + else + putchar ('\n'); + free (prob->desc); } - + +/* Retire all problems as if they failed. We print them in chronological + order rather than lifo order, as this is a bit clearer, and we can do it + when we know they're all going to fail. */ +static void +flush_problems () +{ + struct problem *fail (struct problem *prob) + { + struct problem *last = prob->prev ? fail (prob->prev) : prob; + if (preen && device_name) + printf ("%s: %s\n", device_name, prob->desc); + else + puts (prob->desc); + free (prob->desc); + return last; + } + if (problems) + { + fail (problems)->prev = free_problems; + free_problems = problems; + } +} + /* Like printf, but exit after printing. */ void errexit (char *fmt, ...) { va_list args; + flush_problems (); + if (preen && device_name) printf ("%s: ", device_name); @@ -191,37 +254,146 @@ errexit (char *fmt, ...) vprintf (fmt, args); va_end (args); putchar ('\n'); + exit (1); } -/* Like printf, but give more information (when we fully support it) - when preening. */ -int -pwarn (char *fmt, ...) +static void +retch (char *reason) +{ + flush_problems (); + error (99, 0, "(internal error) %s!", reason); +} + +static void +punt () +{ + problem (0, "PLEASE RUN fsck MANUALLY"); + flush_problems (); + exit (1); +} + +/* Store away the given message about a problem found. A call to problem must + be matched later with a call to pfix, pfail, or reply; to print more + in the same message, intervening calls to pextend can be used. If SEVERE is + true, and we're in preen mode, then the program is terminated. */ +void +problem (int severe, char *fmt, ...) { va_list args; - int ret; - if (preen && device_name) - printf ("%s: ", device_name); + va_start (args, fmt); + push_problem (fmt, args); + va_end (args); + + if (severe && preen) + punt (); +} + +/* Following a call to problem (with perhaps intervening calls to + pmore), appends the given message to that message. */ +void +pextend (char *fmt, ...) +{ + va_list args; + char *more, *concat; + struct problem *prob = problems; + + if (! prob) + retch ("No pending problem to add to"); va_start (args, fmt); - ret = vprintf (fmt, args); + if (vasprintf (&more, fmt, args) < 0) + retch ("vasprintf failed"); va_end (args); - return ret; + concat = realloc (prob->desc, strlen (prob->desc) + 1 + strlen (more) + 1); + if (! concat) + retch ("realloc failed"); + + strcpy (concat + strlen (concat), more); + prob->desc = concat; } + +/* Like problem, but as if immediately followed by pfail. */ +void +warning (int severe, char *fmt, ...) +{ + va_list args; -/* Print how a problem was fixed in preen mode. */ + va_start (args, fmt); + push_problem (fmt, args); + va_end (args); + + flush_problems (); + + if (severe && preen) + punt (); +} + +/* Like problem, but appends a helpful description of the given inode number to + the message. */ +void +pinode (int severe, ino_t ino, char *fmt, ...) +{ + if (fmt) + { + va_list args; + va_start (args, fmt); + push_problem (fmt, args); + va_end (args); + } + + if (ino < ROOTINO || ino > maxino) + pextend ("(BOGUS INODE) I=%d", ino); + else + { + char *p; + struct dinode dino; + struct passwd *pw; + + getinode (ino, &dino); + + pextend (" %s I=%d", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE", + ino); + + pw = getpwuid (dino.di_uid); + if (pw) + pextend (" O=%s", pw->pw_name); + else + pextend (" O=%lu", dino.di_uid); + + pextend (" M=0%o", DI_MODE (&dino)); + pextend (" SZ=%llu", dino.di_size); + p = ctime (&dino.di_mtime.ts_sec); + pextend (" MT=%12.12s %4.4s", &p[4], &p[20]); + } + + if (severe && preen) + punt (); +} + +/* Print a successful resolution to a pending problem. Must follow a call to + problem or pextend. */ void pfix (char *fix) { if (preen) - printf (" (%s)\n", fix); + resolve_problem (fix ?: "FIXED"); } +/* Print an unsuccessful resolution to a pending problem. Must follow a call + to problem or pextend. */ +void +pfail (char *failure) +{ + if (preen) + resolve_problem (failure); +} + /* Ask the user a question; return 1 if the user says yes, and 0 - if the user says no. */ + if the user says no. This call must follow a call to problem or pextend, + which it completes. */ int reply (char *question) { @@ -229,10 +401,13 @@ reply (char *question) char c; if (preen) - pfatal ("INTERNAL ERROR: GOT TO reply ()"); + retch ("Got to reply() in preen mode"); + + /* Emit the problem to which the question pertains. */ + resolve_problem (0); persevere = !strcmp (question, "CONTINUE"); - putchar ('\n'); + if (!persevere && (nowrite || writefd < 0)) { fix_denied = 1; @@ -269,43 +444,3 @@ reply (char *question) } } } - -/* Print a helpful description of the given inode number. */ -void -pinode (ino_t ino, char *fmt, ...) -{ - if (fmt) - { - va_list args; - va_start (args, fmt); - vprintf (fmt, args); - va_end (args); - putchar (' '); - } - - if (ino < ROOTINO || ino > maxino) - printf (" NODE I=%d", ino); - else - { - char *p; - struct dinode dino; - struct passwd *pw; - - getinode (ino, &dino); - - printf ("%s I=%d", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE", - ino); - - pw = getpwuid (dino.di_uid); - if (pw) - printf (" OWNER=%s", pw->pw_name); - else - printf (" OWNER=%lu", dino.di_uid); - - printf (" MODE=%o", DI_MODE (&dino)); - printf (" SIZE=%llu ", dino.di_size); - p = ctime (&dino.di_mtime.ts_sec); - printf (" MTIME=%12.12s %4.4s", &p[4], &p[20]); - } -} - -- cgit v1.2.3 From a43cac3929ad4c536faf23ead915c650f012a236 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:02:42 +0000 Subject: (validdir, makeentry, linkup): Use new printing functions. --- ufs-fsck/dir.c | 63 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 8d32aee4..18fcd699 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -1,5 +1,5 @@ /* Directory management subroutines - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -89,15 +89,15 @@ validdir (ino_t dir, char *action) return 1; case UNALLOC: - pfatal ("CANNOT %s I=%d; NOT ALLOCATED", action, dir); + warning (1, "CANNOT %s I=%d; NOT ALLOCATED", action, dir); return 0; case BADDIR: - pfatal ("CANNOT %s I=%d; BAD BLOCKS", action, dir); + warning (1, "CANNOT %s I=%d; BAD BLOCKS", action, dir); return 0; case REG: - pfatal ("CANNOT %s I=%d; NOT DIRECTORY", action, dir); + warning (1, "CANNOT %s I=%d; NOT DIRECTORY", action, dir); return 0; default: @@ -379,17 +379,19 @@ makeentry (ino_t dir, ino_t ino, char *name) if (!madeentry) { /* Attempt to expand the directory. */ - pwarn ("NO SPACE LEFT IN DIR INO=%d", dir); + problem (0, "NO SPACE LEFT IN DIR INO=%d", dir); if (preen || reply ("EXPAND")) { if (expanddir (&dino)) { - if (preen) - printf (" (EXPANDED)"); datablocks_iterate (&dino, checkdirblock); + pfix ("EXPANDED"); } else - pfatal ("CANNOT EXPAND DIRECTORY"); + { + pfail (0); + warning (1, "CANNOT EXPAND DIRECTORY"); + } } } return madeentry; @@ -439,35 +441,31 @@ linkup (ino_t ino, ino_t parent) { if (!searchdir (ROOTINO, lfname, &lfdir)) { - pfatal ("FAILURE SEARCHING FOR %s\n", lfname); + warning (1, "FAILURE SEARCHING FOR %s", lfname); return 0; } if (lfdir == 0) { - pwarn ("NO %s DIRECTORY", lfname); + problem (0, "NO %s DIRECTORY", lfname); if (preen || reply ("CREATE")) { lfdir = allocdir (ROOTINO, 0, lfmode); if (lfdir != 0) { - if (makeentry (ROOTINO, lfdir, lfname)) - { - if (preen) - printf (" (CREATED)"); - } - else + if (! makeentry (ROOTINO, lfdir, lfname)) { freeino (lfdir); linkfound[ROOTINO]--; lfdir = 0; - if (preen) - printf ("\n"); } } } - if (!lfdir) + if (lfdir) + pfix ("CREATED"); + else { - pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); + pfail (0); + warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); return 0; } } @@ -478,8 +476,8 @@ linkup (ino_t ino, ino_t parent) { ino_t oldlfdir; - pfatal ("%s IS NOT A DIRECTORY", lfname); - if (!reply ("REALLOCATE")) + problem (1, "%s IS NOT A DIRECTORY", lfname); + if (! reply ("REALLOCATE")) return 0; oldlfdir = lfdir; @@ -487,12 +485,12 @@ linkup (ino_t ino, ino_t parent) lfdir = allocdir (ROOTINO, 0, lfmode); if (!lfdir) { - pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); + warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); return 0; } if (!changeino (ROOTINO, lfname, lfdir)) { - pfatal ("SORRY, CANNOT CREATE %s DIRECTORY\n", lfname); + warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); return 0; } @@ -504,7 +502,7 @@ linkup (ino_t ino, ino_t parent) if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF)) { - pfatal ("SORRY. %s DIRECTORY NOT ALLOCATED\n", lfname); + warning (1, "SORRY. %s DIRECTORY NOT ALLOCATED", lfname); return 0; } @@ -521,13 +519,13 @@ linkup (ino_t ino, ino_t parent) if (search_failed) { free (tempname); - pfatal ("FAILURE SEARCHING FOR %s in %s\n", tempname, lfname); + warning (1, "FAILURE SEARCHING FOR %s in %s", tempname, lfname); return 0; } if (!makeentry (lfdir, ino, tempname)) { free (tempname); - pfatal("SORRY, NO SPACE IN %s DIRECTORY\n", lfname); + warning (1, "SORRY, NO SPACE IN %s DIRECTORY", lfname); return 0; } free (tempname); @@ -540,7 +538,7 @@ linkup (ino_t ino, ino_t parent) { if (!changeino (ino, "..", lfdir)) { - pfatal ("CANNOT ADJUST .. link I=%u\n", ino); + warning (1, "CANNOT ADJUST .. LINK I=%u", ino); return 0; } /* Forget about link to old parent */ @@ -548,7 +546,7 @@ linkup (ino_t ino, ino_t parent) } else if (!makeentry (ino, lfdir, "..")) { - pfatal ("CANNOT CREAT .. link I=%u\n", ino); + warning (1, "CANNOT CREAT .. LINK I=%u", ino); return 0; } @@ -559,11 +557,10 @@ linkup (ino_t ino, ino_t parent) lfdino.di_nlink++; write_inode (lfdir, &lfdino); - pwarn ("DIR I=%u CONNECTED. ", ino); if (parent) - printf ("PARENT WAS I=%u\n", parent); - if (!preen) - printf ("\n"); + warning (0, "DIR I=%u CONNECTED; PARENT WAS I=%u", ino, parent); + else + warning (0, "DIR I=%u CONNECTED", ino); } return 1; } -- cgit v1.2.3 From e33204cfd54c211071b1c89c698439a4c4d18322 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:03:18 +0000 Subject: (pass1b): Use new printing functions. --- ufs-fsck/pass1b.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index 50973eae..190ae9dc 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -1,5 +1,5 @@ /* Pass 1b of fsck -- scan inodes for references to duplicate blocks - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -48,10 +48,8 @@ pass1b () { if (dlp->dup == bno) { - if (!dupblk) - printf ("I=%d HAD DUPLICATE BLOCKS\n", number); dupblk++; - printf ("DUPLICATE BLOCK %ld\n", bno); + warning (0, "DUPLICATE BLOCK %ld\n", bno); dlp->dup = duphead->dup; duphead->dup = bno; duphead = duphead->next; @@ -78,7 +76,7 @@ pass1b () allblock_iterate (dp, checkblock); if (dupblk) { - printf ("I=%d has %d DUPLICATE BLOCKS\n", number, dupblk); + problem (1, "I=%d HAS %d DUPLICATE BLOCKS", number, dupblk); if (reply ("CLEAR")) { clear_inode (number, dp); -- cgit v1.2.3 From 42f9c20aaaa33550c2fcd5576fa1f1381b8709a9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:03:39 +0000 Subject: (pass2): Use new printing functions. --- ufs-fsck/pass2.c | 92 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 28982384..426ba2b3 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -1,5 +1,5 @@ /* Pass 2 of GNU fsck -- examine all directories for validity - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -60,7 +60,7 @@ pass2 () if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) { - pfatal ("BAD RECLEN IN DIRECTORY"); + problem (1, "BAD RECLEN IN DIRECTORY"); if (reply ("SALVAGE")) { /* Skip over everything else in this dirblock; @@ -77,7 +77,7 @@ pass2 () /* Check INO */ if (dp->d_ino > maxino) { - pfatal ("BAD INODE NUMBER IN DIRECTORY"); + problem (1, "BAD INODE NUMBER IN DIRECTORY"); if (reply ("SALVAGE")) { /* Mark this entry clear */ @@ -92,7 +92,7 @@ pass2 () /* Check INO */ if (inodestate[dp->d_ino] == UNALLOC) { - pinode (dnp->i_number, "REF TO UNALLOCATED NODE IN"); + pinode (0, dnp->i_number, "REF TO UNALLOCATED NODE IN"); if (reply ("REMOVE")) { dp->d_ino = 0; @@ -105,7 +105,7 @@ pass2 () namlen = DIRECT_NAMLEN (dp); if (namlen > MAXNAMLEN) { - pfatal ("BAD NAMLEN IN DIRECTORY"); + problem (1, "BAD NAMLEN IN DIRECTORY"); if (reply ("SALVAGE")) { /* Mark this entry clear */ @@ -119,7 +119,7 @@ pass2 () for (i = 0; i < DIRECT_NAMLEN (dp); i++) if (dp->d_name[i] == '\0' || dp->d_name[i] == '/') { - pfatal ("ILLEGAL CHARACTER IN FILE NAME"); + problem (1, "ILLEGAL CHARACTER IN FILE NAME"); if (reply ("SALVAGE")) { /* Mark this entry clear */ @@ -130,7 +130,7 @@ pass2 () } if (dp->d_name[DIRECT_NAMLEN (dp)]) { - pfatal ("DIRECTORY NAME NOT TERMINATED"); + problem (1, "DIRECTORY NAME NOT TERMINATED"); if (reply ("SALVAGE")) { /* Mark this entry clear */ @@ -147,7 +147,7 @@ pass2 () type = DIRECT_TYPE (dp); if (type != DT_UNKNOWN && type != typemap[dp->d_ino]) { - pfatal ("INCORRECT NODE TYPE IN DIRECTORY"); + problem (1, "INCORRECT NODE TYPE IN DIRECTORY"); if (reply ("FIX")) { errexit ("NODE TYPE FOUND WHEN NOT SUPPORTED"); @@ -177,15 +177,17 @@ pass2 () targetdir = lookup_directory (dp->d_ino); if (targetdir->i_parent) { - printf ("EXTRANEOUS LINK %s TO DIR I=%ld", dp->d_name, - dp->d_ino); - pwarn ("FOUND IN DIR I=%d", dnp->i_number); + problem (0, "EXTRANEOUS LINK `%s' TO DIR I=%ld", + dp->d_name, dp->d_ino); + pextend (" FOUND IN DIR I=%d", dnp->i_number); if (preen || reply ("REMOVE")) { - pfix ("REMOVED"); dp->d_ino = 0; mod = 1; + pfix ("REMOVED"); } + else + pfail (0); } else targetdir->i_parent = dnp->i_number; @@ -230,31 +232,31 @@ pass2 () break; case UNALLOC: - pfatal ("ROOT INODE UNALLOCATED"); + problem (1, "ROOT INODE UNALLOCATED"); if (!reply ("ALLOCATE")) - errexit ("\n"); + errexit ("ABORTING"); if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) - errexit ("CANNOT ALLOCATE ROOT INODE\n"); + errexit ("CANNOT ALLOCATE ROOT INODE"); break; case REG: - pfatal ("ROOT INODE NOT DIRECTORY"); + problem (1, "ROOT INODE NOT DIRECTORY"); if (reply ("REALLOCATE")) freeino (ROOTINO); if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) - errexit ("CANNOT ALLOCATE ROOT INODE\n"); + errexit ("CANNOT ALLOCATE ROOT INODE"); break; case BADDIR: - pfatal ("DUPLICATE or BAD BLOCKS IN ROOT INODE"); + problem (1, "DUPLICATE or BAD BLOCKS IN ROOT INODE"); if (reply ("REALLOCATE")) { freeino (ROOTINO); if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) - errexit ("CANNOT ALLOCATE ROOT INODE\n"); + errexit ("CANNOT ALLOCATE ROOT INODE"); } if (reply ("CONTINUE") == 0) - errexit ("\n"); + errexit ("ABORTING"); break; } @@ -270,8 +272,8 @@ pass2 () continue; if (dnp->i_isize % DIRBLKSIZ) { - pwarn ("DIRECTORY INO=%d: LENGTH %d NOT MULTIPLE OF %d", - dnp->i_number, dnp->i_isize, DIRBLKSIZ); + problem (0, "DIRECTORY INO=%d: LENGTH %d NOT MULTIPLE OF %d", + dnp->i_number, dnp->i_isize, DIRBLKSIZ); if (preen || reply ("ADJUST")) { getinode (dnp->i_number, &dino); @@ -279,6 +281,8 @@ pass2 () write_inode (dnp->i_number, &dino); pfix ("ADJUSTED"); } + else + pfail (0); } bzero (&dino, sizeof (struct dinode)); dino.di_size = dnp->i_isize; @@ -308,17 +312,20 @@ pass2 () if (dnp->i_parent && dnp->i_dotdot == 0) { dnp->i_dotdot = dnp->i_parent; - pinode (dnp->i_number, "MISSING `..' IN"); - if (reply ("FIX")) - if (makeentry (dnp->i_number, dnp->i_parent, "..")) + pinode (0, dnp->i_number, "MISSING `..' IN"); + if ((preen || reply ("FIX")) + && makeentry (dnp->i_number, dnp->i_parent, "..")) + { linkfound[dnp->i_parent]++; - else - pfatal ("COULDN'T ADD `..'\n"); + pfix ("FIXED"); + } + else + pfail (0); } else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) { - pinode (dnp->i_number, "BAD INODE NUMBER FOR `..' IN"); - if (reply ("FIX")) + pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `..' IN"); + if (preen || reply ("FIX")) { ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot; dnp->i_dotdot = parent; @@ -329,27 +336,33 @@ pass2 () linkfound[parent]++; if (inodestate[old_dotdot] != UNALLOC) linkfound[old_dotdot]--; + pfix ("FIXED"); } else - pfatal ("COULDN'T CHANGE `..'\n"); + pfail (0); } + else + pfail (0); } /* Check `.' to make sure it exists and is correct */ if (dnp->i_dot == 0) { dnp->i_dot = dnp->i_number; - pinode (dnp->i_number, "MISSING `.' IN"); - if (reply ("FIX")) - if (makeentry (dnp->i_number, dnp->i_number, ".")) + pinode (0, dnp->i_number, "MISSING `.' IN"); + if ((preen || reply ("FIX")) + && makeentry (dnp->i_number, dnp->i_number, ".")) + { linkfound[dnp->i_number]++; - else - pfatal ("COULDN'T ADD `.'\n"); + pfix ("FIXED"); + } + else + pfail (0); } else if (dnp->i_dot != dnp->i_number) { - pinode (dnp->i_number, "BAD INODE NUMBER FOR `.' IN"); - if (reply ("FIX")) + pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `.' IN"); + if (preen || reply ("FIX")) { ino_t old_dot = dnp->i_dot; dnp->i_dot = dnp->i_number; @@ -358,10 +371,13 @@ pass2 () linkfound[dnp->i_number]++; if (inodestate[old_dot] != UNALLOC) linkfound[old_dot]--; + pfix ("FIXED"); } else - pfatal ("COULDN'T CHANGE `.'\n"); + pfail (0); } + else + pfail (0); } } } -- cgit v1.2.3 From 537bd01195f5bb1c550a089a021cd9b2ea1cc90b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:03:59 +0000 Subject: (pass3): Use new printing functions. --- ufs-fsck/pass3.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ufs-fsck/pass3.c b/ufs-fsck/pass3.c index 7353c9f2..fd5ad1b0 100644 --- a/ufs-fsck/pass3.c +++ b/ufs-fsck/pass3.c @@ -1,5 +1,5 @@ /* Pass 3 of GNU fsck -- Look for disconnected directories - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -57,18 +57,15 @@ pass3 () { if (inodestate[dnp->i_number] & DIR_REF) errexit ("ORPHANED DIR MARKED WITH CONNECT"); - pinode (dnp->i_number, "UNREF"); - if (preen || reply ("RECONNECT")) + pinode (0, dnp->i_number, "UNREF"); + if ((preen || reply ("RECONNECT")) + && linkup (dnp->i_number, dnp->i_dotdot)) { - if (linkup (dnp->i_number, dnp->i_dotdot)) - dnp->i_parent = dnp->i_dotdot = lfdir; + dnp->i_parent = dnp->i_dotdot = lfdir; pfix ("RECONNECTED"); } + else + pfail (0); } } } - - - - - -- cgit v1.2.3 From cc258b15076b5f18aae0bf1a633e1c9c2cb318b7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 01:04:10 +0000 Subject: (pass4): Use new printing functions. --- ufs-fsck/pass4.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index bd1c7541..3f5c26cc 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -1,5 +1,5 @@ /* Pass 4 of GNU fsck -- Check reference counts - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -33,7 +33,8 @@ pass4() { if (linkcount[number] != linkfound[number]) { - pinode (number, "LINK COUNT %d SHOULD BE %d IN", + pinode (0, number, + "LINK COUNT %d SHOULD BE %d IN", linkcount[number], linkfound[number]); if (preen || reply ("ADJUST")) { @@ -43,6 +44,8 @@ pass4() write_inode (number, &dino); pfix ("ADJUSTED"); } + else + pfail (0); } } else if (linkfound[number] && inodestate[number] == UNALLOC) @@ -58,7 +61,7 @@ pass4() want to reattach in. */ struct dinode dino; - pinode (number, "UNREF"); + pinode (0, number, "UNREF"); getinode (number, &dino); if (dino.di_size && !reconn_failed) @@ -72,6 +75,8 @@ pass4() reconn_failed = !linkup (number, -1); if (!reconn_failed) pfix ("RECONNECTED"); + else + pfail ("FAILED"); } if (dino.di_size == 0 || reconn_failed) { @@ -79,8 +84,10 @@ pass4() { inodestate[number] = UNALLOC; clear_inode (number, &dino); + pfix ("CLEARED"); } - pfix ("CLEARED"); + else + pfail (0); } } } -- cgit v1.2.3 From 2616f2c0ee4b68116f75f3701f17b530a33e25f2 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 02:32:34 +0000 Subject: (setup): Use new printing functions; use error to print error msgs. , : New includes. --- ufs-fsck/setup.c | 62 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index 9d5d3d24..c0f047a2 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -21,6 +21,8 @@ #include "fsck.h" #include #include +#include +#include static char sblockbuf[SBSIZE]; struct fs *sblock = (struct fs *)sblockbuf; @@ -28,6 +30,20 @@ struct fs *sblock = (struct fs *)sblockbuf; /* A string identifying what we're trying to check. */ char *device_name = 0; +daddr_t maxfsblock; +int maxino; +int direct_symlink_extension; + +int newinofmt; + +int readfd, writefd; + +int fix_denied = 0; + +int fsmodified = 0; + +int lfdir; + /* Get ready to run on device with pathname DEV. */ int setup (char *dev) @@ -40,13 +56,13 @@ setup (char *dev) if (stat (dev, &st) == -1) { - perror (dev); + error (0, errno, "%s", dev); return 0; } if (!S_ISCHR (st.st_mode)) { - pfatal ("%s is not a character device", dev); - if (!reply ("CONTINUE")) + problem (1, "%s is not a character device", dev); + if (! reply ("CONTINUE")) return 0; } if (preen == 0) @@ -58,13 +74,13 @@ setup (char *dev) readfd = open (dev, O_RDONLY); if (readfd == -1) { - perror (dev); + error (0, errno, "%s", dev); return 0; } writefd = -1; nowrite = 1; if (preen) - pfatal ("NO WRITE ACCESS"); + warning (1, "NO WRITE ACCESS"); printf (" (NO WRITE)"); } else @@ -81,33 +97,33 @@ setup (char *dev) if (sblock->fs_magic != FS_MAGIC) { - pfatal ("BAD MAGIC NUMBER"); + warning (1, "BAD MAGIC NUMBER"); return 0; } if (sblock->fs_ncg < 1) { - pfatal ("NCG OUT OF RANGE"); + warning (1, "NCG OUT OF RANGE"); return 0; } if (sblock->fs_cpg < 1) { - pfatal ("CPG OUT OF RANGE"); + warning (1, "CPG OUT OF RANGE"); return 0; } if (sblock->fs_ncg * sblock->fs_cpg < sblock->fs_ncyl || (sblock->fs_ncg - 1) * sblock->fs_cpg >= sblock->fs_ncyl) { - pfatal ("NCYL INCONSISTENT WITH NCG AND CPG"); + warning (1, "NCYL INCONSISTENT WITH NCG AND CPG"); return 0; } if (sblock->fs_sbsize > SBSIZE) { - pfatal ("SBLOCK SIZE PREPONTEROUSLY LARGE"); + warning (1, "SBLOCK SIZE PREPONTEROUSLY LARGE"); return 0; } if (sblock->fs_optim != FS_OPTTIME && sblock->fs_optim != FS_OPTSPACE) { - pfatal ("UNDEFINED OPTIMIZATION IN SUPERBLOCK"); + problem (1, "UNDEFINED OPTIMIZATION IN SUPERBLOCK"); if (reply ("SET TO DEFAULT")) { sblock->fs_optim = FS_OPTTIME; @@ -116,36 +132,42 @@ setup (char *dev) } if (sblock->fs_minfree < 0 || sblock->fs_minfree > 99) { - pfatal ("IMPOSSIBLE MINFREE=%ld IN SUPERBLOCK", sblock->fs_minfree); - if (reply ("SET TO DEFAULT")) + problem (0, "IMPOSSIBLE MINFREE=%ld IN SUPERBLOCK", sblock->fs_minfree); + if (preen || reply ("SET TO DEFAULT")) { sblock->fs_minfree = 10; changedsb = 1; + pfix ("SET TO DEFAULT"); } + else + pfail (0); } if (sblock->fs_interleave < 1 || sblock->fs_interleave > sblock->fs_nsect) { - pwarn ("IMPOSSIBLE INTERLEAVE=%ld IN SUPERBLOCK", sblock->fs_interleave); + problem (0, "IMPOSSIBLE INTERLEAVE=%ld IN SUPERBLOCK", + sblock->fs_interleave); if (preen || reply ("SET TO DEFAULT")) { - if (preen) - printf (" (SET TO DEFAULT)"); sblock->fs_interleave = 1; changedsb = 1; + pfix ("SET TO DEFAULT"); } + else + pfail (0); } if (sblock->fs_npsect < sblock->fs_nsect || sblock->fs_npsect > sblock->fs_nsect * 2) { - pwarn ("IMPOSSIBLE NPSECT=%ld IN SUPERBLOCK", sblock->fs_npsect); + problem (0, "IMPOSSIBLE NPSECT=%ld IN SUPERBLOCK", sblock->fs_npsect); if (preen || reply ("SET TO DEFAULT")) { - if (preen) - printf (" (SET TO DEFAULT)"); sblock->fs_npsect = sblock->fs_nsect; changedsb = 1; + pfix ("SET TO DEFAULT"); } + else + pfail (0); } if (sblock->fs_inodefmt >= FS_44INODEFMT) newinofmt = 1; -- cgit v1.2.3 From 525391d59e39afa3769522aacbe5373ca8494308 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 03:18:14 +0000 Subject: (warning): Don't flush all pending problems, just our own. (no_preen): New function. (problem, warning, pinode): Use it. --- ufs-fsck/utilities.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index d886e780..65857ac9 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -265,13 +265,23 @@ retch (char *reason) error (99, 0, "(internal error) %s!", reason); } +/* Prints all unresolved problems and exits, printing MSG as well. */ static void -punt () +punt (char *msg) { - problem (0, "PLEASE RUN fsck MANUALLY"); + problem (0, msg); flush_problems (); exit (1); } + +/* If SEVERE is true, and we're in preen mode, then things are too hair to + fix automatically, so tell the user to do it himself and punt. */ +static void +no_preen (int severe) +{ + if (severe && preen) + punt ("PLEASE RUN fsck MANUALLY"); +} /* Store away the given message about a problem found. A call to problem must be matched later with a call to pfix, pfail, or reply; to print more @@ -286,8 +296,7 @@ problem (int severe, char *fmt, ...) push_problem (fmt, args); va_end (args); - if (severe && preen) - punt (); + no_preen (severe); } /* Following a call to problem (with perhaps intervening calls to @@ -325,10 +334,9 @@ warning (int severe, char *fmt, ...) push_problem (fmt, args); va_end (args); - flush_problems (); + no_preen (severe); - if (severe && preen) - punt (); + resolve_problem (0); } /* Like problem, but appends a helpful description of the given inode number to @@ -345,7 +353,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) } if (ino < ROOTINO || ino > maxino) - pextend ("(BOGUS INODE) I=%d", ino); + pextend (" (BOGUS INODE) I=%d", ino); else { char *p; @@ -369,8 +377,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) pextend (" MT=%12.12s %4.4s", &p[4], &p[20]); } - if (severe && preen) - punt (); + no_preen (severe); } /* Print a successful resolution to a pending problem. Must follow a call to -- cgit v1.2.3 From 4d62f69cd0bf612d3d1a6f7439f0a03e35de9bfb Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 03:19:38 +0000 Subject: (linkup): Consistently put quotes around filenames. --- ufs-fsck/dir.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 18fcd699..1a693c42 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -441,12 +441,12 @@ linkup (ino_t ino, ino_t parent) { if (!searchdir (ROOTINO, lfname, &lfdir)) { - warning (1, "FAILURE SEARCHING FOR %s", lfname); + warning (1, "FAILURE SEARCHING FOR `%s'", lfname); return 0; } if (lfdir == 0) { - problem (0, "NO %s DIRECTORY", lfname); + problem (0, "NO `%s' DIRECTORY", lfname); if (preen || reply ("CREATE")) { lfdir = allocdir (ROOTINO, 0, lfmode); @@ -465,7 +465,7 @@ linkup (ino_t ino, ino_t parent) else { pfail (0); - warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); + warning (1, "SORRY, CANNOT CREATE `%s' DIRECTORY", lfname); return 0; } } @@ -476,7 +476,7 @@ linkup (ino_t ino, ino_t parent) { ino_t oldlfdir; - problem (1, "%s IS NOT A DIRECTORY", lfname); + problem (1, "`%s' IS NOT A DIRECTORY", lfname); if (! reply ("REALLOCATE")) return 0; @@ -485,12 +485,12 @@ linkup (ino_t ino, ino_t parent) lfdir = allocdir (ROOTINO, 0, lfmode); if (!lfdir) { - warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); + warning (1, "SORRY, CANNOT CREATE `%s' DIRECTORY", lfname); return 0; } if (!changeino (ROOTINO, lfname, lfdir)) { - warning (1, "SORRY, CANNOT CREATE %s DIRECTORY", lfname); + warning (1, "SORRY, CANNOT CREATE `%s' DIRECTORY", lfname); return 0; } @@ -502,7 +502,7 @@ linkup (ino_t ino, ino_t parent) if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF)) { - warning (1, "SORRY. %s DIRECTORY NOT ALLOCATED", lfname); + warning (1, "SORRY. `%s' DIRECTORY NOT ALLOCATED", lfname); return 0; } @@ -519,13 +519,13 @@ linkup (ino_t ino, ino_t parent) if (search_failed) { free (tempname); - warning (1, "FAILURE SEARCHING FOR %s in %s", tempname, lfname); + warning (1, "FAILURE SEARCHING FOR `%s' IN `%s'", tempname, lfname); return 0; } if (!makeentry (lfdir, ino, tempname)) { free (tempname); - warning (1, "SORRY, NO SPACE IN %s DIRECTORY", lfname); + warning (1, "SORRY, NO SPACE IN `%s' DIRECTORY", lfname); return 0; } free (tempname); @@ -538,7 +538,7 @@ linkup (ino_t ino, ino_t parent) { if (!changeino (ino, "..", lfdir)) { - warning (1, "CANNOT ADJUST .. LINK I=%u", ino); + warning (1, "CANNOT ADJUST `..' LINK I=%u", ino); return 0; } /* Forget about link to old parent */ @@ -546,7 +546,7 @@ linkup (ino_t ino, ino_t parent) } else if (!makeentry (ino, lfdir, "..")) { - warning (1, "CANNOT CREAT .. LINK I=%u", ino); + warning (1, "CANNOT CREAT `..' LINK I=%u", ino); return 0; } -- cgit v1.2.3 From 2ee141406464171e746bb202bc846f40e6694f21 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 03:22:57 +0000 Subject: Fix up recovery logic for when reconnecting an inode fails. Get rid of extraneous calls to pfail. --- ufs-fsck/pass4.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 3f5c26cc..17c0b307 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -44,8 +44,6 @@ pass4() write_inode (number, &dino); pfix ("ADJUSTED"); } - else - pfail (0); } } else if (linkfound[number] && inodestate[number] == UNALLOC) @@ -73,21 +71,21 @@ pass4() if (preen || reply ("RECONNECT")) reconn_failed = !linkup (number, -1); - if (!reconn_failed) + if (! reconn_failed) pfix ("RECONNECTED"); - else - pfail ("FAILED"); } if (dino.di_size == 0 || reconn_failed) { + if (reconn_failed && !preen) + /* If preening, the previous call to problem is still active + (more likely the failure was too severe, and exited). */ + problem (0, "RECONNECT FAILED"); if (preen || reply ("CLEAR")) { inodestate[number] = UNALLOC; clear_inode (number, &dino); pfix ("CLEARED"); } - else - pfail (0); } } } -- cgit v1.2.3 From 58184d1189cf46fa61d4a2b82ed4cd3b9c9b32e2 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 03:23:29 +0000 Subject: Get rid of extraneous calls to pfail. --- ufs-fsck/pass1.c | 14 +------------- ufs-fsck/pass2.c | 8 -------- ufs-fsck/pass5.c | 18 ------------------ ufs-fsck/setup.c | 6 ------ 4 files changed, 1 insertion(+), 45 deletions(-) diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 0b9a04cf..066f4649 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -78,8 +78,6 @@ pass1 () pfail ("SKIPPING"); return RET_STOP; } - else - pfix ("CONTINUING"); } } @@ -106,8 +104,6 @@ pass1 () pfail ("SKIPPING"); return RET_STOP; } - else - pfix ("CONTINUING"); } new = malloc (sizeof (struct dups)); new->dup = bno; @@ -194,8 +190,6 @@ pass1 () clear_inode (number, dp); pfix ("CLEARED"); } - else - pfail (0); } inodestate[number] = UNALLOC; } @@ -346,8 +340,6 @@ pass1 () dbwarn = 2; pfix ("DEALLOCATED"); } - else - pfail (0); } else if (dbwarn == 2) dp->di_db[lbn] = 0; @@ -373,8 +365,6 @@ pass1 () ibwarn = 2; pfix ("DEALLOCATED"); } - else - pfail (0); } else if (ibwarn == 2) dp->di_ib[lbn] = 0; @@ -429,15 +419,13 @@ pass1 () else if (dp->di_blocks != nblocks) { problem (0, "INCORRECT BLOCK COUNT I=%d (%ld should be %d)", - number, dp->di_blocks, nblocks); + number, dp->di_blocks, nblocks); if (preen || reply ("CORRECT")) { dp->di_blocks = nblocks; write_inode (number, dp); pfix ("CORRECTED"); } - else - pfail (0); } num_files++; diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 426ba2b3..3c70170e 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -186,8 +186,6 @@ pass2 () mod = 1; pfix ("REMOVED"); } - else - pfail (0); } else targetdir->i_parent = dnp->i_number; @@ -281,8 +279,6 @@ pass2 () write_inode (dnp->i_number, &dino); pfix ("ADJUSTED"); } - else - pfail (0); } bzero (&dino, sizeof (struct dinode)); dino.di_size = dnp->i_isize; @@ -341,8 +337,6 @@ pass2 () else pfail (0); } - else - pfail (0); } /* Check `.' to make sure it exists and is correct */ @@ -376,8 +370,6 @@ pass2 () else pfail (0); } - else - pfail (0); } } } diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 2ec68b68..7ea7aeed 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -207,8 +207,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } if (newcg->cg_frotor > newcg->cg_ndblk) { @@ -220,8 +218,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } if (newcg->cg_irotor > newcg->cg_niblk) { @@ -233,8 +229,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } /* Zero the block maps and summary areas */ @@ -368,8 +362,6 @@ pass5 () writecsum = 1; pfix ("FIXED"); } - else - pfail (0); } /* Check inode and block maps */ @@ -382,8 +374,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } if (bcmp (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize)) @@ -395,8 +385,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } if (bcmp (newcg, cg, basesize)) @@ -408,8 +396,6 @@ pass5 () writecg = 1; pfix ("FIXED"); } - else - pfail (0); } if (writecg) @@ -432,8 +418,6 @@ pass5 () writesb = 1; pfix ("FIXED"); } - else - pfail (0); } if (sblock->fs_clean == 0 && !fix_denied) @@ -445,8 +429,6 @@ pass5 () writesb = 1; pfix ("MARKED CLEAN"); } - else - pfail ("LEFT UNCLEAN"); } if (writesb) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index c0f047a2..d40cf70b 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -139,8 +139,6 @@ setup (char *dev) changedsb = 1; pfix ("SET TO DEFAULT"); } - else - pfail (0); } if (sblock->fs_interleave < 1 || sblock->fs_interleave > sblock->fs_nsect) @@ -153,8 +151,6 @@ setup (char *dev) changedsb = 1; pfix ("SET TO DEFAULT"); } - else - pfail (0); } if (sblock->fs_npsect < sblock->fs_nsect || sblock->fs_npsect > sblock->fs_nsect * 2) @@ -166,8 +162,6 @@ setup (char *dev) changedsb = 1; pfix ("SET TO DEFAULT"); } - else - pfail (0); } if (sblock->fs_inodefmt >= FS_44INODEFMT) newinofmt = 1; -- cgit v1.2.3 From 90b39d103f3320eece0d1bfd12649144739be2de Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 2 May 1996 03:32:09 +0000 Subject: (main): Shorten summary message so that it fits on one line. --- ufs-fsck/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 2bf12fbf..c03cb14e 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -124,10 +124,8 @@ main (int argc, char **argv) long num_bfree = sblock->fs_cstotal.cs_nbfree; long tot_ffree = num_ffree + sblock->fs_frag * num_bfree; warning (0, - "%ld files, %ld used, %ld free" - " (%ld frags, %ld blocks, %ld.%ld%% fragmentation)", + "%ld files, %ld used, %ld free (%ld.%ld%% fragmentation)", num_files, sblock->fs_dsize - tot_ffree, tot_ffree, - num_ffree, num_bfree, (num_ffree * 100) / sblock->fs_dsize, (((num_ffree * 1000 + sblock->fs_dsize / 2) / sblock->fs_dsize) -- cgit v1.2.3 From 865f3d52f7513d33b680a3396dbc98674eb107d1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 2 May 1996 14:56:04 +0000 Subject: (offer_data): Offer pages at ADDR each time through the loop, not the same page over and over. --- ufs/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 5694c0b5..8bacb590 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -367,7 +367,7 @@ offer_data (struct node *np, assert (np->dn->fileinfo); for (addr = start; addr < start + len; addr += vm_page_size) - pager_offer_page (np->dn->fileinfo->p, 1, 0, start, buf + (addr - start)); + pager_offer_page (np->dn->fileinfo->p, 1, 0, addr, buf + (addr - start)); } /* Logical block LBN of node NP has been extended with ffs_realloccg. -- cgit v1.2.3 From 5b224569367f605c7c1bbf19f01f3a1e323205cc Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 2 May 1996 16:25:49 +0000 Subject: (block_extended): When moving data, sync in-core pager both before reading from disk and after providing data to kernel. (diskfs_grow): Always call block_extended or offer_data before adjusting block pointer. --- ufs/sizes.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 8bacb590..ee69c566 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -398,13 +398,31 @@ block_extended (struct node *np, we deallocate the old block. */ for (off = 0; off < round_page (old_size); off += vm_page_size) { + + /* There's *got* to be a better way to do this... */ + + /* Force it out to disk */ + assert (np->fileinfo); + pager_sync_some (np->fileinfo->p, lbn * sblock->fs_bsize + off, + vm_page_size, 1); + + /* Read it back in */ diskfs_device_read_sync (fsbtodb (sblock, old_pbn) + off / DEV_BSIZE, (void *) &buf, vm_page_size); /* If this page is the last one, then zero the excess first */ if (off + vm_page_size > old_size) bzero ((void *)(buf + old_size - off), vm_page_size - (old_size - off)); + + /* And make sure it's in core. */ offer_data (np, lbn * sblock->fs_bsize + off, vm_page_size, buf); + + /* And now, make sure it's on disk. (Why? Because a previous + write of this file, maybe even one from before we started + running may have been fsynced. We can't cause data already + on disk to be lossy at any time in the future while we move it. */ + pager_sync_some (np->fileinfo->p, lbn * sblock->fs_bsize + off, + vm_page_size, 1); } /* And deallocate the old block */ @@ -475,12 +493,13 @@ diskfs_grow (struct node *np, osize, sblock->fs_bsize, &bno, cred); if (err) goto out; + + block_extended (np, olbn, old_pbn, bno, osize, sblock->fs_bsize); + old_pbn = read_disk_entry (di->di_db[olbn]); write_disk_entry (di->di_db[olbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - - block_extended (np, olbn, old_pbn, bno, osize, sblock->fs_bsize); } } @@ -502,11 +521,11 @@ diskfs_grow (struct node *np, if (err) goto out; + block_extended (np, lbn, old_pbn, bno, osize, size); + write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - - block_extended (np, lbn, old_pbn, bno, osize, size); } else { @@ -517,11 +536,11 @@ diskfs_grow (struct node *np, if (err) goto out; + + offer_data (np, lbn * sblock->fs_bsize, size, zeroblock); write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; - - offer_data (np, lbn * sblock->fs_bsize, size, zeroblock); } } else @@ -612,10 +631,10 @@ diskfs_grow (struct node *np, sblock->fs_bsize, &bno, 0); if (err) goto out; + offer_data (np, lbn * sblock->fs_bsize, sblock->fs_bsize, zeroblock); indirs[0].bno = bno; write_disk_entry (siblock[indirs[0].offset], bno); record_poke (siblock, sblock->fs_bsize); - offer_data (np, lbn * sblock->fs_bsize, sblock->fs_bsize, zeroblock); } out: -- cgit v1.2.3 From 40db0923390045daf72e04f332ecb3017be2df1c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 2 May 1996 16:28:10 +0000 Subject: fixup --- ufs/sizes.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index ee69c566..4237ea56 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -402,8 +402,8 @@ block_extended (struct node *np, /* There's *got* to be a better way to do this... */ /* Force it out to disk */ - assert (np->fileinfo); - pager_sync_some (np->fileinfo->p, lbn * sblock->fs_bsize + off, + assert (np->dn->fileinfo); + pager_sync_some (np->dn->fileinfo->p, lbn * sblock->fs_bsize + off, vm_page_size, 1); /* Read it back in */ @@ -421,7 +421,7 @@ block_extended (struct node *np, write of this file, maybe even one from before we started running may have been fsynced. We can't cause data already on disk to be lossy at any time in the future while we move it. */ - pager_sync_some (np->fileinfo->p, lbn * sblock->fs_bsize + off, + pager_sync_some (np->dn->fileinfo->p, lbn * sblock->fs_bsize + off, vm_page_size, 1); } @@ -494,9 +494,10 @@ diskfs_grow (struct node *np, if (err) goto out; + old_pbn = read_disk_entry (di->di_db[olbn]); + block_extended (np, olbn, old_pbn, bno, osize, sblock->fs_bsize); - old_pbn = read_disk_entry (di->di_db[olbn]); write_disk_entry (di->di_db[olbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; -- cgit v1.2.3 From 3ecb154e5a98d6a60c66a8591ab80d4f30c52822 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 3 May 1996 05:04:08 +0000 Subject: (nice_size, show_stats): New functions. (main): Use show_stats. --- ufs-fsck/main.c | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index c03cb14e..c2656d07 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -46,6 +46,43 @@ static struct argp_option options[] = }; char *args_doc = "DEVICE"; +/* Returns a malloced buffer containing a nice printable size for FRAGS. */ +static char * +nice_size (long frags) +{ + char *rep; + char *units = "KMGT", *u = units; + float num = ((float)frags * sblock->fs_fsize) / 1024; + + while (num > 1024) + { + num /= 1024; + u++; + } + + asprintf (&rep, "%#.4g%c", num, *u); + + return rep; +} + +/* Print summary statistics. */ +static void +show_stats () +{ + long num_ffree = sblock->fs_cstotal.cs_nffree; + long num_bfree = sblock->fs_cstotal.cs_nbfree; + long tot_ffree = num_ffree + sblock->fs_frag * num_bfree; + char *urep = nice_size (sblock->fs_dsize - tot_ffree); + char *frep = nice_size (tot_ffree); + warning (0, "%ld files, %s used, %s free (%ld.%ld%% fragmentation)", + num_files, urep, frep, + (num_ffree * 100) / sblock->fs_dsize, + (((num_ffree * 1000 + sblock->fs_dsize / 2) / sblock->fs_dsize) + % 10)); + free (urep); + free (frep); +} + int main (int argc, char **argv) { @@ -118,19 +155,7 @@ main (int argc, char **argv) pass5 (); if (! silent) - /* Print summary statistics. */ - { - long num_ffree = sblock->fs_cstotal.cs_nffree; - long num_bfree = sblock->fs_cstotal.cs_nbfree; - long tot_ffree = num_ffree + sblock->fs_frag * num_bfree; - warning (0, - "%ld files, %ld used, %ld free (%ld.%ld%% fragmentation)", - num_files, sblock->fs_dsize - tot_ffree, tot_ffree, - (num_ffree * 100) / sblock->fs_dsize, - (((num_ffree * 1000 + sblock->fs_dsize / 2) - / sblock->fs_dsize) - % 10)); - } + show_stats (sblock); } if (fsmodified && !preen) -- cgit v1.2.3 From 663bd31c43b788156c193b8d79895fb7af58aa70 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 3 May 1996 05:30:56 +0000 Subject: (show_stats): Fiddle with formatting. --- ufs-fsck/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index c2656d07..f9a7bd7e 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -60,7 +60,7 @@ nice_size (long frags) u++; } - asprintf (&rep, "%#.4g%c", num, *u); + asprintf (&rep, num >= 1000 ? "%.0f%c" : "%.3g%c", num, *u); return rep; } -- cgit v1.2.3 From 31da7bd62ef8f315db44ad47ee423c55fc46cf27 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 3 May 1996 13:15:27 +0000 Subject: (struct user_pager_info): New members `allow_unlocked_pagein' and `unlocked_pagein_length'. (unlocked_pagein_lock): New variable. --- ufs/ufs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ufs.h b/ufs/ufs.h index 06255960..ddf7283b 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -79,6 +79,9 @@ struct user_pager_info } type; struct pager *p; vm_prot_t max_prot; + + vm_offset_t allow_unlocked_pagein; + vm_size_t unlocked_pagein_length; }; #include @@ -97,6 +100,8 @@ spin_lock_t alloclock; spin_lock_t gennumberlock; u_long nextgennumber; +spin_lock_t unlocked_pagein_lock; + /* The compat_mode specifies whether or not we write extensions onto the disk. */ enum compat_mode -- cgit v1.2.3 From 5163242b569179a9d875c9aefcc3ee5c317e1c55 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 3 May 1996 13:31:52 +0000 Subject: (diskfs_get_filemap): Initialize UPI->allow_unlocked_pagein and UPI->unlocked_pagein_length. (unlocked_pagein_lock): New variable. (find_address): New parameter `isread'; all callers changed. If ISREAD and we are in the unlocked pagein region, don't attempt to acquire NP->dn->allocptrlock. --- ufs/pager.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index d4bc87c5..0da2609e 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -22,6 +22,8 @@ spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; +spin_lock_t unlocked_pagein_lock = SPIN_LOCK_INITIALIZER; + #ifdef DONT_CACHE_MEMORY_OBJECTS #define MAY_CACHE 0 #else @@ -34,15 +36,18 @@ struct port_bucket *pager_bucket; disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has completed. Set DISKSIZE to be the amount of valid data on disk. - (If this is an unallocated block, then set *ADDR to zero.) */ + (If this is an unallocated block, then set *ADDR to zero.) + ISREAD is non-zero iff this is for a pagein. */ static error_t find_address (struct user_pager_info *upi, vm_address_t offset, daddr_t *addr, int *disksize, - struct rwlock **nplock) + struct rwlock **nplock, + int isread) { error_t err; + struct rwlock *lock; assert (upi->type == DISK || upi->type == FILE_DATA); @@ -60,12 +65,58 @@ find_address (struct user_pager_info *upi, np = upi->np; - rwlock_reader_lock (&np->dn->allocptrlock); - *nplock = &np->dn->allocptrlock; + if (isread) + { + try_again: + + /* If we should allow an unlocked pagein, do so. (This + still has a slight race; there could be a pageout in progress + which is blocked on NP->np->allocptrlock itself. In that + case the pagein that should proceed unimpeded is blocked + in the pager library waiting for the pageout to complete. + I think this is sufficiently rare to put it off for the time + being.) */ + + spin_lock (&unlocked_pagein_lock); + if (offset >= upi->allow_unlocked_pagein + && (offset + vm_page_size + <= upi->allow_unlocked_pagein + upi->unlocked_pagein_length)) + { + spin_unlock (&unlocked_pagein_lock); + *nplock = 0; + goto have_lock; + } + spin_unlock (&unlocked_pagein_lock); + + /* Block on the rwlock if necessary; but when we wake up, + don't acquire it; check again from the top. + This is mutated inline from rwlock.h. */ + lock = &np->dn->allocptrlock; + mutex_lock (&lock->master); + if (lock->readers == -1 || lock->writers_waiting) + { + lock->readers_waiting++; + condition_wait (&lock->wakeup, &lock->master); + lock->readers_waiting--; + mutex_unlock (&lock->master); + goto try_again; + } + lock->readers++; + mutex_unlock (&lock->master); + *nplock = lock; + } + else + { + rwlock_reader_lock (&np->dn->allocptrlock); + *nplock = &np->dn->allocptrlock; + } + have_lock: + if (offset >= np->allocsize) { - rwlock_reader_unlock (&np->dn->allocptrlock); + if (*nplock) + rwlock_reader_unlock (*nplock); return EIO; } @@ -75,8 +126,8 @@ find_address (struct user_pager_info *upi, *disksize = __vm_page_size; err = fetch_indir_spec (np, lblkno (sblock, offset), indirs); - if (err) - rwlock_reader_unlock (&np->dn->allocptrlock); + if (err && *nplock) + rwlock_reader_unlock (*nplock); else { if (indirs[0].bno) @@ -104,7 +155,7 @@ pager_read_page (struct user_pager_info *pager, daddr_t addr; int disksize; - err = find_address (pager, page, &addr, &disksize, &nplock); + err = find_address (pager, page, &addr, &disksize, &nplock, 1); if (err) return err; @@ -143,7 +194,7 @@ pager_write_page (struct user_pager_info *pager, struct rwlock *nplock; error_t err; - err = find_address (pager, page, &addr, &disksize, &nplock); + err = find_address (pager, page, &addr, &disksize, &nplock, 0); if (err) return err; @@ -490,6 +541,8 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) upi->type = FILE_DATA; upi->np = np; upi->max_prot = prot; + upi->allow_unlocked_pagein = 0; + upi->unlocked_pagein_length = 0; diskfs_nref_light (np); upi->p = pager_create (upi, pager_bucket, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); -- cgit v1.2.3 From 4f244438de694a265f0714b7f490eac190472cb4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 3 May 1996 17:49:14 +0000 Subject: (block_extended): Rewrite code that moves pages to be more efficient, and not deadlock too, using unlocked pagein permission feature (read "hack"). Return value now indicates whether we expect a sync. (diskfs_grow): If a call to block_extended returns nonzero, then sync the file before returning. --- ufs/sizes.c | 92 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index 4237ea56..ad14f5cc 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -373,8 +373,9 @@ offer_data (struct node *np, /* Logical block LBN of node NP has been extended with ffs_realloccg. It used to be allocated at OLD_PBN and is now at NEW_PBN. The old size was OLD_SIZE; it is now NEW_SIZE bytes long. Arrange for the data - on disk to be kept consistent, and free the old block if it has moved. */ -void + on disk to be kept consistent, and free the old block if it has moved. + Return one iff we've actually moved data around on disk. */ +int block_extended (struct node *np, daddr_t lbn, daddr_t old_pbn, @@ -393,42 +394,54 @@ block_extended (struct node *np, if (old_pbn != new_pbn) { - /* Fetch the old data for the part that has moved and offer it - to the kernel, to make sure it's paged in before - we deallocate the old block. */ - for (off = 0; off < round_page (old_size); off += vm_page_size) - { - - /* There's *got* to be a better way to do this... */ - - /* Force it out to disk */ - assert (np->dn->fileinfo); - pager_sync_some (np->dn->fileinfo->p, lbn * sblock->fs_bsize + off, - vm_page_size, 1); - - /* Read it back in */ - diskfs_device_read_sync (fsbtodb (sblock, old_pbn) + off / DEV_BSIZE, - (void *) &buf, vm_page_size); - /* If this page is the last one, then zero the excess first */ - if (off + vm_page_size > old_size) - bzero ((void *)(buf + old_size - off), - vm_page_size - (old_size - off)); - - /* And make sure it's in core. */ - offer_data (np, lbn * sblock->fs_bsize + off, vm_page_size, buf); - - /* And now, make sure it's on disk. (Why? Because a previous - write of this file, maybe even one from before we started - running may have been fsynced. We can't cause data already - on disk to be lossy at any time in the future while we move it. */ - pager_sync_some (np->dn->fileinfo->p, lbn * sblock->fs_bsize + off, - vm_page_size, 1); - } + vm_object_t mapobj; + error_t err; + vm_address_t mapaddr; + volatile int *pokeaddr; + + /* Map in this part of the file */ + mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ); + err = vm_map (mach_task_self (), &mapaddr, round_page (old_size), 0, 1, + mapobj, lbn * sblock->fs_bsize, 0, + VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, 0); + assert_perror (err); - /* And deallocate the old block */ + /* Allow these pageins to occur even though we're holding the lock */ + spin_lock (&unlocked_pagein_lock); + np->dn->fileinfo->allow_unlocked_pagein = lbn * sblock->fs_bsize; + np->dn->fileinfo->unlocked_pagein_length = round_page (old_size); + spin_unlock (&unlocked_pagein_lock); + + /* Make sure all waiting pageins see this change. */ + mutex_lock (&np->allocptrlock->master); + condition_broadcast (&np->allocptrlock->wakeup); + mutex_unlock (&np->allocptrlock->master); + + /* Force the pages in core and make sure they are dirty */ + for (pokeaddr = (char *)mapaddr; + pokeaddr < mapaddr + round_page (old_size); + pokeaddr += vm_page_size / sizeof (*pokeaddr)) + *pokeaddr = *pokeaddr; + + /* Turn off the special pagein permission */ + spin_lock (&unlocked_pagein_lock); + np->dn->fileinfo->allow_unlocked_pagein = 0; + np->dn->fileinfo->unlocked_pagein_length = 0; + spin_unlock (&unlocked_pagein_lock); + + /* Undo mapping */ + mach_port_deallocate (mach_task_self (), mapobj); + vm_deallocate (mach_task_self (), mapaddr, round_page (old_size); + + /* Now it's OK to free the old block */ ffs_blkfree (np, old_pbn, old_size); + + /* Tell caller that we've moved data */ + return 1; } -} + else + return 0; +} /* Implement the diskfs_grow callback; see for the @@ -443,6 +456,7 @@ diskfs_grow (struct node *np, error_t err; struct dinode *di = dino (np->dn->number); mach_port_t pagerpt; + int needsync = 0; /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect @@ -496,7 +510,8 @@ diskfs_grow (struct node *np, old_pbn = read_disk_entry (di->di_db[olbn]); - block_extended (np, olbn, old_pbn, bno, osize, sblock->fs_bsize); + need_sync = block_extended (np, olbn, old_pbn, bno, + osize, sblock->fs_bsize); write_disk_entry (di->di_db[olbn], bno); record_poke (di, sizeof (struct dinode)); @@ -522,7 +537,7 @@ diskfs_grow (struct node *np, if (err) goto out; - block_extended (np, lbn, old_pbn, bno, osize, size); + need_sync = block_extended (np, lbn, old_pbn, bno, osize, size); write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); @@ -653,6 +668,9 @@ diskfs_grow (struct node *np, rwlock_writer_unlock (&np->dn->allocptrlock); + if (need_sync) + diskfs_file_update (np, 1); + return err; } -- cgit v1.2.3 From 31912148eee69012791e591a061dd76e8e09b659 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 3 May 1996 18:10:58 +0000 Subject: fixup --- ufs/sizes.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index ad14f5cc..af765945 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -383,9 +383,6 @@ block_extended (struct node *np, size_t old_size, size_t new_size) { - vm_address_t buf; - daddr_t off; - /* Make sure that any pages of this block which just became allocated don't get paged in from disk. */ if (round_page (old_size) < round_page (new_size)) @@ -394,7 +391,7 @@ block_extended (struct node *np, if (old_pbn != new_pbn) { - vm_object_t mapobj; + memory_object_t mapobj; error_t err; vm_address_t mapaddr; volatile int *pokeaddr; @@ -413,12 +410,12 @@ block_extended (struct node *np, spin_unlock (&unlocked_pagein_lock); /* Make sure all waiting pageins see this change. */ - mutex_lock (&np->allocptrlock->master); - condition_broadcast (&np->allocptrlock->wakeup); - mutex_unlock (&np->allocptrlock->master); + mutex_lock (&np->dn->allocptrlock->master); + condition_broadcast (&np->dn->allocptrlock->wakeup); + mutex_unlock (&np->dn->allocptrlock->master); /* Force the pages in core and make sure they are dirty */ - for (pokeaddr = (char *)mapaddr; + for (pokeaddr = (int *)mapaddr; pokeaddr < mapaddr + round_page (old_size); pokeaddr += vm_page_size / sizeof (*pokeaddr)) *pokeaddr = *pokeaddr; @@ -431,7 +428,7 @@ block_extended (struct node *np, /* Undo mapping */ mach_port_deallocate (mach_task_self (), mapobj); - vm_deallocate (mach_task_self (), mapaddr, round_page (old_size); + vm_deallocate (mach_task_self (), mapaddr, round_page (old_size)); /* Now it's OK to free the old block */ ffs_blkfree (np, old_pbn, old_size); @@ -456,7 +453,7 @@ diskfs_grow (struct node *np, error_t err; struct dinode *di = dino (np->dn->number); mach_port_t pagerpt; - int needsync = 0; + int need_sync = 0; /* Zero an sblock->fs_bsize piece of disk starting at BNO, synchronously. We do this on newly allocated indirect -- cgit v1.2.3 From 57ffe5ad51eec9910e2c0b3e4bdf971db09b57f4 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 3 May 1996 18:12:48 +0000 Subject: (block_extended): more fixup --- ufs/sizes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index af765945..f98ceb94 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -410,13 +410,13 @@ block_extended (struct node *np, spin_unlock (&unlocked_pagein_lock); /* Make sure all waiting pageins see this change. */ - mutex_lock (&np->dn->allocptrlock->master); - condition_broadcast (&np->dn->allocptrlock->wakeup); - mutex_unlock (&np->dn->allocptrlock->master); + mutex_lock (&np->dn->allocptrlock.master); + condition_broadcast (&np->dn->allocptrlock.wakeup); + mutex_unlock (&np->dn->allocptrlock.master); /* Force the pages in core and make sure they are dirty */ for (pokeaddr = (int *)mapaddr; - pokeaddr < mapaddr + round_page (old_size); + pokeaddr < (int *) (mapaddr + round_page (old_size)); pokeaddr += vm_page_size / sizeof (*pokeaddr)) *pokeaddr = *pokeaddr; -- cgit v1.2.3 From b40493575ad94645591b9294436012da248282e6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 6 May 1996 18:23:48 +0000 Subject: (ufs_version): Upgrade to 0.0. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 2173be01..5ba1b318 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -25,7 +25,7 @@ #include #include -char *ufs_version = "0.0 pre-alpha"; +char *ufs_version = "0.0"; struct node *diskfs_root_node; -- cgit v1.2.3 From 1d43d11bc71f15d5edaa414876c88beea43078b7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 7 May 1996 00:16:39 +0000 Subject: (trivfs_S_file_get_storage_info): Rewrite for new interface. --- devio/io.c | 88 +++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/devio/io.c b/devio/io.c index 7d8dec41..b5d86cf6 100644 --- a/devio/io.c +++ b/devio/io.c @@ -1,6 +1,6 @@ /* Implements the hurd io interface to devio. - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Miles Bader @@ -317,19 +317,15 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, return EOPNOTSUPP; } -/* ---------------------------------------------------------------- */ - error_t trivfs_S_file_get_storage_info (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t reply_type, - int *class, - off_t **runs, unsigned *runs_len, - size_t *block_size, - char *dev_name, mach_port_t *dev_port, - mach_msg_type_name_t *dev_port_type, - char **misc, unsigned *misc_len, - int *flags) + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t **ports, + mach_msg_type_number_t num_ports, + mach_msg_type_name_t *ports_type, + int **ints, mach_msg_type_number_t *num_ints, + off_t **offsets, mach_msg_type_number_t *num_offsets, + char **data, mach_msg_type_number_t *data_len) { error_t err = 0; @@ -337,36 +333,58 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, err = EOPNOTSUPP; else { - struct dev *dev = ((struct open *)cred->po->hook)->dev; - - if (*runs_len < 2 * sizeof (off_t)) - { - *runs_len = 2 * sizeof (off_t); - err = - vm_allocate (mach_task_self (), - (vm_address_t *)runs, *runs_len, 1); + /* True when we've allocated memory for the corresponding vector. */ + int al_ports = 0, al_ints = 0, al_offsets = 0, al_data = 0; + +#define ENSURE_MEM(v, vl, alp, num) \ + if (!err && *vl < num) \ + { \ + err = vm_allocate (mach_task_self (), \ + (vm_address_t *)v, num * sizeof (**v), 1); \ + if (! err) \ + { \ + *vl = num; \ + alp = 1; \ + } \ } - - if (!err) + + ENSURE_MEM (ports, num_ports, al_ports, 1); + ENSURE_MEM (ints, num_ints, al_ints, 6); + ENSURE_MEM (offsets, num_offsets, al_offsets, 2); + ENSURE_MEM (data, data_len, al_data, 1); + + if (! err) { - *class = STORAGE_DEVICE; - *flags = 0; - - (*runs)[0] = 0; - (*runs)[1] = dev->size / dev->dev_block_size; - *runs_len = 2; + struct dev *dev = ((struct open *)cred->po->hook)->dev; + (*ints)[0] = STORAGE_DEVICE; /* type */ + (*ints)[1] = 0; /* flags */ + (*ints)[2] = dev->dev_block_size; /* block_size */ + (*ints)[3] = 2; /* num_runs */ + (*ints)[4] = strlen (dev->name) + 1; /* name_len */ + (*ints)[5] = 0; /* misc_len */ - *block_size = dev->dev_block_size; + (*offsets)[0] = 0; + (*offsets)[1] = dev->size / dev->dev_block_size; - strcpy (dev_name, dev->name); + strcpy (*data, dev->name); if (cred->isroot) - *dev_port = dev->port; + (*ports)[0] = dev->port; else - *dev_port = MACH_PORT_NULL; - *dev_port_type = MACH_MSG_TYPE_COPY_SEND; - - *misc_len = 0; + (*ports)[0] = MACH_PORT_NULL; + *ports_type = MACH_MSG_TYPE_COPY_SEND; + } + else + /* Some memory allocation failed (not bloody likely). */ + { +#define DISCARD_MEM(v, vl, alp) \ + if (alp) \ + vm_deallocate (mach_task_self (), (vm_address_t)*v, *vl * sizeof (**v)); + + DISCARD_MEM (ports, num_ports, al_ports); + DISCARD_MEM (ints, num_ints, al_ints); + DISCARD_MEM (offsets, num_offsets, al_offsets); + DISCARD_MEM (data, data_len, al_data); } } -- cgit v1.2.3 From fbd04f92d5991152755b7ec83fa96d3487842102 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 7 May 1996 20:42:20 +0000 Subject: (trivfs_S_file_get_storage_info): Swap PORTS_TYPE & NUM_PORTS. --- devio/io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/devio/io.c b/devio/io.c index b5d86cf6..e9ba850f 100644 --- a/devio/io.c +++ b/devio/io.c @@ -319,12 +319,14 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, error_t trivfs_S_file_get_storage_info (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t reply, + mach_msg_type_name_t reply_type, mach_port_t **ports, - mach_msg_type_number_t num_ports, mach_msg_type_name_t *ports_type, + mach_msg_type_number_t num_ports, int **ints, mach_msg_type_number_t *num_ints, - off_t **offsets, mach_msg_type_number_t *num_offsets, + off_t **offsets, + mach_msg_type_number_t *num_offsets, char **data, mach_msg_type_number_t *data_len) { error_t err = 0; -- cgit v1.2.3 From b4b71df7ac62246208bbbdc4318a660934cb9474 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 May 1996 15:54:08 +0000 Subject: ioserver.h -> iohelp.h. --- ufs/ufs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index ddf7283b..ea13475e 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include "fs.h" -- cgit v1.2.3 From 528f10e84f674b7236b332911426bb023eea8c5e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 9 May 1996 16:16:51 +0000 Subject: (trivfs_S_io_select): Remove TAG arg. --- devio/io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/devio/io.c b/devio/io.c index e9ba850f..43b379e8 100644 --- a/devio/io.c +++ b/devio/io.c @@ -139,13 +139,11 @@ trivfs_S_io_seek (struct trivfs_protid *cred, /* SELECT_TYPE is the bitwise OR of SELECT_READ, SELECT_WRITE, and SELECT_URG. Block until one of the indicated types of i/o can be done "quickly", and - return the types that are then available. ID_TAG is returned as passed; it - is just for the convenience of the user in matching up reply messages with - specific requests sent. */ + return the types that are then available. */ kern_return_t trivfs_S_io_select (struct trivfs_protid *cred, mach_port_t reply, mach_msg_type_name_t replytype, - int *type, int *tag) + int *type) { if (!cred) return EOPNOTSUPP; -- cgit v1.2.3 From c57f21bd975cd0b82daca86c521f6635625358bd Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 9 May 1996 21:28:16 +0000 Subject: (trivfs_S_file_get_storage_info): Fix param type. --- devio/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devio/io.c b/devio/io.c index 43b379e8..1c7a3298 100644 --- a/devio/io.c +++ b/devio/io.c @@ -321,7 +321,7 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, mach_msg_type_name_t reply_type, mach_port_t **ports, mach_msg_type_name_t *ports_type, - mach_msg_type_number_t num_ports, + mach_msg_type_number_t *num_ports, int **ints, mach_msg_type_number_t *num_ints, off_t **offsets, mach_msg_type_number_t *num_offsets, -- cgit v1.2.3 From b2aecd50c2d7ed75af2bac0d4edce6a6bd0b845a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 May 1996 23:37:47 +0000 Subject: (diskfs_set_statfs): Use and fill in new statfs structure. --- ufs/inode.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index ab19668f..4011ff55 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -487,19 +487,19 @@ diskfs_write_disknode (struct node *np, int wait) /* Implement the diskfs_set_statfs callback from the diskfs library; see for the interface description. */ error_t -diskfs_set_statfs (struct fsys_statfsbuf *st) +diskfs_set_statfs (struct statfs *st) { - st->fsys_stb_type = FSTYPE_UFS; - st->fsys_stb_iosize = sblock->fs_bsize; - st->fsys_stb_bsize = sblock->fs_fsize; - st->fsys_stb_blocks = sblock->fs_dsize; - st->fsys_stb_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag - + sblock->fs_cstotal.cs_nffree); - st->fsys_stb_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) - - (sblock->fs_dsize - st->fsys_stb_bfree)); - st->fsys_stb_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ - st->fsys_stb_ffree = sblock->fs_cstotal.cs_nifree; - st->fsys_stb_fsid = getpid (); + st->f_type = FSTYPE_UFS; + st->f_bsize = sblock->fs_bsize; + st->f_blocks = sblock->fs_dsize * sblock->fs_frag; + st->f_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag + + sblock->fs_cstotal.cs_nffree); + st->f_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) + - (sblock->fs_dsize - st->fsys_stb_bfree)); + st->f_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ + st->f_ffree = sblock->fs_cstotal.cs_nifree; + st->f_fsid = getpid (); + st->f_namelen = 0; return 0; } -- cgit v1.2.3 From fc2b2d7272fff570399f6fd1e6a9df7294199b9e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 9 May 1996 23:44:44 +0000 Subject: (ufs.static ufs): s/ioserver/iohelp/g --- ufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 280e155c..d9375989 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -29,5 +29,5 @@ ufs.static-LDFLAGS += -static include ../Makeconf -ufs.static ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libioserver/libioserver.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a +ufs.static ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libiohelp/libiohelp.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a -- cgit v1.2.3 From 975310cf191470adad179f5a96e0f1d591b0f3e5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 10 May 1996 00:12:45 +0000 Subject: (pass1b): Bother to initialize NUMBER. --- ufs-fsck/pass1b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index 190ae9dc..0cf50a17 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -26,7 +26,7 @@ pass1b () struct dinode dino; struct dinode *dp = &dino; int cg, i; - ino_t number; + ino_t number = 0; int dupblk; struct dups *duphead = duplist; -- cgit v1.2.3 From 6c7e0eddfc5f46f168b21d6748e3988f656a5542 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 10 May 1996 13:28:57 +0000 Subject: (diskfs_set_statfs): Fix one reference to old name of ST member. --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 4011ff55..51af3446 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -495,7 +495,7 @@ diskfs_set_statfs (struct statfs *st) st->f_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag + sblock->fs_cstotal.cs_nffree); st->f_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) - - (sblock->fs_dsize - st->fsys_stb_bfree)); + - (sblock->fs_dsize - st->f_bfree)); st->f_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ st->f_ffree = sblock->fs_cstotal.cs_nifree; st->f_fsid = getpid (); -- cgit v1.2.3 From 3ef9af5731c2cf524430ff22ee3982d0a9c2925d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 10 May 1996 20:34:16 +0000 Subject: (fd_get_device): Update to use libstore. : New include. --- ufs-utils/dlabel.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c index dbae0457..33db56da 100644 --- a/ufs-utils/dlabel.c +++ b/ufs-utils/dlabel.c @@ -25,33 +25,37 @@ #include #include /* Ick */ #include +#include static error_t fd_get_device (int fd, device_t *device) { error_t err; - string_t name; - int class, flags = 0; - size_t block_size; - off_t *runs = 0; - char *misc = 0; - size_t runs_len = 0, misc_len = 0; + struct store *store; file_t node = getdport (fd); if (node == MACH_PORT_NULL) return errno; - err = file_get_storage_info (node, &class, &runs, &runs_len, &block_size, - name, device, &misc, &misc_len, &flags); - if (!err) + err = store_create (node, &store); + if (! err) { - if (runs_len != 2 || runs[0] != 0 || class != STORAGE_DEVICE) - /* This doesn't seem to be a handle on the whole device; be picky. */ + if (store->class != STORAGE_DEVICE + /* In addition to requiring a device, we also want the *whole* + device -- one contiguous run starting at 0. */ + || store->num_runs != 1 + || store->runs[0].start != 0) err = ENODEV; - if (runs_len) - vm_deallocate (mach_task_self (), (vm_address_t)runs, runs_len); - if (misc_len) - vm_deallocate (mach_task_self (), (vm_address_t)misc, misc_len); + else if (store->port == MACH_PORT_NULL) + /* Usually getting a null port back means we didn't have sufficient + privileges. */ + err = EPERM; + else + { + *device = store->port; + store->port = MACH_PORT_NULL; /* Steal the port from STORE! */ + } + store_free (store); } mach_port_deallocate (mach_task_self (), node); -- cgit v1.2.3 From f96cc8acf2d59161429b15b2a00200d4bc20cbc0 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 10 May 1996 21:05:00 +0000 Subject: (mkfs.ufs): Depend on ../libstore/libstore.a. --- ufs-utils/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-utils/Makefile b/ufs-utils/Makefile index 23e437ee..b27b76c4 100644 --- a/ufs-utils/Makefile +++ b/ufs-utils/Makefile @@ -30,7 +30,7 @@ OBJS = $(SRCS:.c=.o) include ../Makeconf -mkfs.ufs: mkfs.o dlabel.o ../libshouldbeinlibc/libshouldbeinlibc.a +mkfs.ufs: mkfs.o dlabel.o ../libstore/libstore.a ../libshouldbeinlibc/libshouldbeinlibc.a $(targets): %.ufs: %.o -- cgit v1.2.3 From 0f8fcdffb258c192cf28621f9ad6130371178f13 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 11 May 1996 05:08:22 +0000 Subject: (parse_opt): Use ARGP_ERR_UNKNOWN instead of EINVAL. --- ufs-fsck/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index f9a7bd7e..50a8142d 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -108,7 +108,8 @@ main (int argc, char **argv) /* Fall through */ case ARGP_KEY_NO_ARGS: argp_usage (state); - default: return EINVAL; + default: + return ARGP_ERR_UNKNOWN; } return 0; } -- cgit v1.2.3 From 10ce2214bf77c857c6c35617a9efefbbcb79b514 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 11 May 1996 05:23:35 +0000 Subject: (parse_opt): Use ARGP_ERR_UNKNOWN instead of EINVAL. --- ufs-utils/mkfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index e585b598..2fb1248c 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.10 1996/04/03 21:34:56 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.11 1996/05/11 05:21:06 miles Exp $"; #endif /* not lint */ #include @@ -309,11 +309,12 @@ main (int argc, char **argv) case ARGP_KEY_ARG: if (state->arg_num > 0) - return EINVAL; + return ARGP_ERR_UNKNOWN; device = arg; + break; default: - return EINVAL; + return ARGP_ERR_UNKNOWN; } return 0; } -- cgit v1.2.3 From d233bdfd39e968e4cffc9af6b21ba2f4ce24df22 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 14 May 1996 12:57:14 +0000 Subject: foo. --- devio/MAKEDEV | 18 ++++++++++++---- ufs/dir.c | 66 +++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index bf5217dc..d992d06a 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -18,19 +18,28 @@ for I; do console|tty[0-9]?|tty[0-9a-f]) $ST $I /hurd/term $_CWD/$I device $I;; null) - $ST $I /hurd/null ;; + $ST $I /hurd/null + chmod 666 $I + ;; zero) - $ST $I /hurd/null -z ;; + $ST $I /hurd/null -z + chmod 666 $I + ;; tty) - $ST $I /hurd/magic tty ;; + $ST $I /hurd/magic tty + chmod 666 $I + ;; fd) $ST $I /hurd/magic fd + chmod 666 $I ln -f -s fd/0 stdin ln -f -s fd/1 stdout ln -f -s fd/2 stderr ;; time) - $ST $I /hurd/devport time ;; + $ST $I /hurd/devport time + chmod 666 $I + ;; # ptys [pt]ty[pqPQ]?) @@ -38,6 +47,7 @@ for I; do ID="`expr substr $I 4 99`" $ST pty$ID /hurd/term $_CWD/pty$ID pty-master $_CWD/tty$ID $ST tty$ID /hurd/term $_CWD/tty$ID pty-slave $_CWD/pty$ID + chmod 666 pty$ID tty$ID ;; [pt]ty[pqPQ]) # Make a bunch of ptys diff --git a/ufs/dir.c b/ufs/dir.c index ed7ac212..9abcdbea 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -336,16 +336,17 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, for (currentoff = blockaddr, prevoff = 0; currentoff < blockaddr + DIRBLKSIZ; - prevoff = currentoff, currentoff += entry->d_reclen) + prevoff = currentoff, currentoff += read_disk_entry (entry->d_reclen)) { entry = (struct directory_entry *)currentoff; if (!entry->d_reclen - || entry->d_reclen % 4 + || read_disk_entry (entry->d_reclen) % 4 || DIRECT_NAMLEN (entry) > MAXNAMLEN - || currentoff + entry->d_reclen > blockaddr + DIRBLKSIZ + || (currentoff + read_disk_entry (entry->d_reclen) + > blockaddr + DIRBLKSIZ) || entry->d_name[DIRECT_NAMLEN (entry)] - || DIRSIZ (DIRECT_NAMLEN (entry)) > entry->d_reclen + || DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen) || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { fprintf (stderr, "Bad directory entry: inode: %d offset: %d\n", @@ -359,9 +360,10 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, /* Count how much free space this entry has in it. */ if (entry->d_ino == 0) - thisfree = entry->d_reclen; + thisfree = read_disk_entry (entry->d_reclen); else - thisfree = entry->d_reclen - DIRSIZ (DIRECT_NAMLEN (entry)); + thisfree = (read_disk_entry (entry->d_reclen) + - DIRSIZ (DIRECT_NAMLEN (entry))); /* If this isn't at the front of the block, then it will have to be copied if we do a compression; count the @@ -377,7 +379,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, if (thisfree >= needed) { ds->type = CREATE; - ds->stat = entry->d_ino == 0 ? TAKE : SHRINK; + ds->stat = read_disk_entry (entry->d_ino) == 0 ? TAKE : SHRINK; ds->entry = entry; ds->idx = idx; looking = countcopies = 0; @@ -446,7 +448,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, ds->preventry = (struct directory_entry *) prevoff; } - *inum = entry->d_ino; + *inum = read_disk_entry (entry->d_ino); return 0; } @@ -480,9 +482,10 @@ diskfs_direnter_hard(struct node *dp, { case TAKE: /* We are supposed to consume this slot. */ - assert (ds->entry->d_ino == 0 && ds->entry->d_reclen >= needed); + assert (ds->entry->d_ino == 0 + && read_disk_entry (ds->entry->d_reclen) >= needed); - ds->entry->d_ino = np->dn->number; + write_disk_entry (ds->entry->d_ino, np->dn->number); DIRECT_NAMLEN (ds->entry) = namelen; if (direct_symlink_extension) ds->entry->d_type = IFTODT (np->dn_stat.st_mode); @@ -494,18 +497,19 @@ diskfs_direnter_hard(struct node *dp, /* We are supposed to take the extra space at the end of this slot. */ oldneeded = DIRSIZ (DIRECT_NAMLEN (ds->entry)); - assert (ds->entry->d_reclen - oldneeded >= needed); + assert (read_disk_entry (ds->entry->d_reclen) - oldneeded >= needed); new = (struct directory_entry *) ((vm_address_t) ds->entry + oldneeded); - new->d_ino = np->dn->number; - new->d_reclen = ds->entry->d_reclen - oldneeded; + write_disk_entry (new->d_ino, np->dn->number); + write_disk_entry (new->d_reclen, + read_disk_entry (ds->entry->d_reclen) - oldneeded); DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); - ds->entry->d_reclen = oldneeded; + write_disk_entry (ds->entry->d_reclen, oldneeded); break; @@ -520,16 +524,16 @@ diskfs_direnter_hard(struct node *dp, { struct directory_entry *from = (struct directory_entry *)fromoff; struct directory_entry *to = (struct directory_entry *) tooff; - int fromreclen = from->d_reclen; + int fromreclen = read_disk_entry (from->d_reclen); if (from->d_ino != 0) { assert (fromoff >= tooff); bcopy (from, to, fromreclen); - to->d_reclen = DIRSIZ (DIRECT_NAMLEN (to)); + write_disk_entry (to->d_reclen, DIRSIZ (DIRECT_NAMLEN (to))); - tooff += to->d_reclen; + tooff += read_disk_entry (to->d_reclen); } fromoff += fromreclen; } @@ -538,8 +542,8 @@ diskfs_direnter_hard(struct node *dp, assert (totfreed >= needed); new = (struct directory_entry *) tooff; - new->d_ino = np->dn->number; - new->d_reclen = totfreed; + write_disk_entry (new->d_ino, np->dn->number); + write_disk_entry (new->d_reclen, totfreed); DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) new->d_type = IFTODT (np->dn_stat.st_mode); @@ -566,8 +570,8 @@ diskfs_direnter_hard(struct node *dp, dp->dn_stat.st_size = oldsize + DIRBLKSIZ; dp->dn_set_ctime = 1; - new->d_ino = np->dn->number; - new->d_reclen = DIRBLKSIZ; + write_disk_entry (new->d_ino, np->dn->number); + write_disk_entry (new->d_reclen, DIRBLKSIZ); DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) new->d_type = IFTODT (np->dn_stat.st_mode); @@ -633,8 +637,10 @@ diskfs_dirremove_hard(struct node *dp, else { assert ((vm_address_t) ds->entry - (vm_address_t) ds->preventry - == ds->preventry->d_reclen); - ds->preventry->d_reclen += ds->entry->d_reclen; + == read_disk_entry (ds->preventry->d_reclen)); + write_disk_entry (ds->preventry->d_reclen, + (read_disk_entry (ds->preventry->d_reclen) + + read_disk_entry (ds->entry->d_reclen))); } dp->dn_set_mtime = 1; @@ -667,7 +673,7 @@ diskfs_dirrewrite_hard(struct node *dp, assert (ds->stat == HERE_TIS); dp->dn_set_mtime = 1; - ds->entry->d_ino = np->dn->number; + write_disk_entry (ds->entry->d_ino, np->dn->number); if (direct_symlink_extension) ds->entry->d_type = IFTODT (np->dn_stat.st_mode); dp->dn_set_mtime = 1; @@ -704,7 +710,7 @@ diskfs_dirempty(struct node *dp, for (curoff = buf; curoff < buf + dp->dn_stat.st_size; - curoff += entry->d_reclen) + curoff += read_disk_entry (entry->d_reclen)) { entry = (struct directory_entry *) curoff; @@ -766,7 +772,7 @@ count_dirents (struct node *dp, int nb, char *buf) for (offinblk = buf; offinblk < buf + DIRBLKSIZ; - offinblk += entry->d_reclen) + offinblk += read_disk_entry (entry->d_reclen)) { entry = (struct directory_entry *) offinblk; if (entry->d_ino) @@ -869,7 +875,9 @@ diskfs_get_directs (struct node *dp, } for (i = 0, bufp = buf; i < entry - curentry && bufp - buf < DIRBLKSIZ; - bufp += ((struct directory_entry *)bufp)->d_reclen, i++) + (bufp + += read_disk_entry (((struct directory_entry *)bufp)->d_reclen)), + i++) ; /* Make sure we didn't run off the end. */ assert (bufp - buf < DIRBLKSIZ); @@ -900,7 +908,7 @@ diskfs_get_directs (struct node *dp, { userp = (struct dirent *) datap; - userp->d_fileno = entryp->d_ino; + userp->d_fileno = read_disk_entry (entryp->d_ino); userp->d_reclen = DIRSIZ (DIRECT_NAMLEN (entryp)); userp->d_namlen = DIRECT_NAMLEN (entryp); bcopy (entryp->d_name, userp->d_name, DIRECT_NAMLEN (entryp) + 1); @@ -909,7 +917,7 @@ diskfs_get_directs (struct node *dp, datap += DIRSIZ (DIRECT_NAMLEN (entryp)); } - bufp += entryp->d_reclen; + bufp += read_disk_entry (entryp->d_reclen); if (bufp - buf == DIRBLKSIZ) { blkno++; -- cgit v1.2.3 From e14202b72dea4891c00bd3bf080f9f6cd8497a33 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 14 May 1996 19:29:31 +0000 Subject: (pass2): Handle directory entry type fields better for Hurd. --- ufs-fsck/pass2.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 3c70170e..4519db6e 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -145,17 +145,29 @@ pass2 () /* Check TYPE */ type = DIRECT_TYPE (dp); - if (type != DT_UNKNOWN && type != typemap[dp->d_ino]) + if (type != DT_UNKNOWN) { - problem (1, "INCORRECT NODE TYPE IN DIRECTORY"); - if (reply ("FIX")) + if (type == typemap[dp->d_ino]) { - errexit ("NODE TYPE FOUND WHEN NOT SUPPORTED"); - dp->d_type = typemap[dp->d_ino]; - mod = 1; + problem (0, "NODE TYPE FIELD SET IN DIRECTORY (I=%d) [NOT IMPLEMENTED IN HURD]"); + if (preen || reply ("CLEAR")) + { + dp->d_type = 0; + mod = 1; + pfix ("CLEARED"); + } + } + else + { + problem (1, "INCORRECT NODE TYPE IN DIRECTORY (I=%d)"); + if (reply ("FIX")) + { + dp->d_type = typemap[dp->d_ino]; + mod = 1; + } } } - + /* Here we should check for duplicate directory entries; that's too much trouble right now. */ -- cgit v1.2.3 From 80bc6cf08aeaca4fad15e9ee904be6439a11f454 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 14 May 1996 19:30:21 +0000 Subject: (pass2): better. --- ufs-fsck/pass2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 4519db6e..14662e5c 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -160,9 +160,9 @@ pass2 () else { problem (1, "INCORRECT NODE TYPE IN DIRECTORY (I=%d)"); - if (reply ("FIX")) + if (reply ("CLEAR")) { - dp->d_type = typemap[dp->d_ino]; + dp->d_type = 0; mod = 1; } } -- cgit v1.2.3 From c8e0edbe24c86f64b1a36d622ba2e59186173c77 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 14 May 1996 19:31:27 +0000 Subject: (pass2): --- ufs-fsck/pass2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 14662e5c..e42df39b 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -149,7 +149,7 @@ pass2 () { if (type == typemap[dp->d_ino]) { - problem (0, "NODE TYPE FIELD SET IN DIRECTORY (I=%d) [NOT IMPLEMENTED IN HURD]"); + problem (0, "NODE TYPE FIELD SET IN DIRECTORY [NOT IMPLEMENTED IN HURD]"); if (preen || reply ("CLEAR")) { dp->d_type = 0; @@ -159,7 +159,7 @@ pass2 () } else { - problem (1, "INCORRECT NODE TYPE IN DIRECTORY (I=%d)"); + problem (1, "INCORRECT NODE TYPE IN DIRECTORY"); if (reply ("CLEAR")) { dp->d_type = 0; -- cgit v1.2.3 From 77d8043d451e95abf5e3111df1d14a9d4d200b60 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 14 May 1996 20:50:39 +0000 Subject: (pass2): Fix up test in preen case. --- ufs-fsck/pass2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index e42df39b..9d5f638c 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -93,10 +93,11 @@ pass2 () if (inodestate[dp->d_ino] == UNALLOC) { pinode (0, dnp->i_number, "REF TO UNALLOCATED NODE IN"); - if (reply ("REMOVE")) + if (preen || reply ("REMOVE")) { dp->d_ino = 0; mod = 1; + pfix ("REMOVED"); continue; } } -- cgit v1.2.3 From b77bcc19abf5032c6f7fd8aa17622fb895461caf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 23 May 1996 18:12:15 +0000 Subject: (pass2): Don't clear all node types in directories, just clear those that are wrong. --- ufs-fsck/pass2.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 9d5f638c..47563718 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -146,26 +146,14 @@ pass2 () /* Check TYPE */ type = DIRECT_TYPE (dp); - if (type != DT_UNKNOWN) + if (type != DT_UNKNOWN && type == typemap[dp->d_ino]) { - if (type == typemap[dp->d_ino]) + problem (0, "INCORRECT NODE TYPE IN DIRECTORY"); + if (preen || reply ("CLEAR")) { - problem (0, "NODE TYPE FIELD SET IN DIRECTORY [NOT IMPLEMENTED IN HURD]"); - if (preen || reply ("CLEAR")) - { - dp->d_type = 0; - mod = 1; - pfix ("CLEARED"); - } - } - else - { - problem (1, "INCORRECT NODE TYPE IN DIRECTORY"); - if (reply ("CLEAR")) - { - dp->d_type = 0; - mod = 1; - } + pfix ("CLEARED"); + dp->d_type = 0; + mod = 1; } } -- cgit v1.2.3 From 1ee4281d95838d8c4ecc0b9e4163c9186215fb91 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 23 May 1996 18:21:56 +0000 Subject: (pass2): whops, typo. --- ufs-fsck/pass2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 47563718..ee12d33b 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -146,7 +146,7 @@ pass2 () /* Check TYPE */ type = DIRECT_TYPE (dp); - if (type != DT_UNKNOWN && type == typemap[dp->d_ino]) + if (type != DT_UNKNOWN && type != typemap[dp->d_ino]) { problem (0, "INCORRECT NODE TYPE IN DIRECTORY"); if (preen || reply ("CLEAR")) -- cgit v1.2.3 From 3e700fe0941d24291034d18746caa08dd6a2af99 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 19:16:10 +0000 Subject: Initial revision --- libmom/Makefile | 40 ++++++++++++ libmom/allocate-address.c | 50 ++++++++++++++ libmom/allocate-memory.c | 51 +++++++++++++++ libmom/copy-ref.c | 43 ++++++++++++ libmom/deallocate-memory.c | 35 ++++++++++ libmom/fetch-mach-port.c | 33 ++++++++++ libmom/hash-ref.c | 28 ++++++++ libmom/mach-port-set.c | 32 +++++++++ libmom/make-memory-readonly.c | 36 ++++++++++ libmom/make-memory-readwrite.c | 36 ++++++++++ libmom/memory-init.c | 32 +++++++++ libmom/mom-kerndep.h | 43 ++++++++++++ libmom/mom.h | 138 +++++++++++++++++++++++++++++++++++++++ libmom/priv.h | 27 ++++++++ libmom/ref-destroy.c | 33 ++++++++++ libmom/refs-identical.c | 43 ++++++++++++ libmom/reserve-memory-anywhere.c | 40 ++++++++++++ libmom/reserve-memory.c | 42 ++++++++++++ libmom/unreserve-memory.c | 27 ++++++++ libmom/unuse-memory.c | 43 ++++++++++++ libmom/wire-memory.c | 28 ++++++++ 21 files changed, 880 insertions(+) create mode 100644 libmom/Makefile create mode 100644 libmom/allocate-address.c create mode 100644 libmom/allocate-memory.c create mode 100644 libmom/copy-ref.c create mode 100644 libmom/deallocate-memory.c create mode 100644 libmom/fetch-mach-port.c create mode 100644 libmom/hash-ref.c create mode 100644 libmom/mach-port-set.c create mode 100644 libmom/make-memory-readonly.c create mode 100644 libmom/make-memory-readwrite.c create mode 100644 libmom/memory-init.c create mode 100644 libmom/mom-kerndep.h create mode 100644 libmom/mom.h create mode 100644 libmom/priv.h create mode 100644 libmom/ref-destroy.c create mode 100644 libmom/refs-identical.c create mode 100644 libmom/reserve-memory-anywhere.c create mode 100644 libmom/reserve-memory.c create mode 100644 libmom/unreserve-memory.c create mode 100644 libmom/unuse-memory.c create mode 100644 libmom/wire-memory.c diff --git a/libmom/Makefile b/libmom/Makefile new file mode 100644 index 00000000..61796585 --- /dev/null +++ b/libmom/Makefile @@ -0,0 +1,40 @@ +# +# Copyright (C) 1996 Free Software Foundation, Inc. +# Written by Michael I. Bushnell, p/BSG. +# +# 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. + +dir := libmom +makemode := library + +libname = libmom + +SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ + deallocate-memory.c drop-ref.c fetch-mach-port.c hash-ref.c \ + mach-port-set.c make-memory-readonly.c make-memory-readwrite.c \ + memory-init.c ref-destroy.c refs-identical.c reserve-memory.c \ + reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ + wire-memory.c + +LCLHDRS = mom.h mom-kernep.h priv.h +installhdrs = mom.h mom-kerndep.h + +OBJS = $(SRCS:.c=.o) + +include ../Makeconf + + diff --git a/libmom/allocate-address.c b/libmom/allocate-address.c new file mode 100644 index 00000000..fa017bac --- /dev/null +++ b/libmom/allocate-address.c @@ -0,0 +1,50 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_allocate_address (void *start, size_t len, int readonly, + struct mom_port_ref *obj, size_t offset, + int copy) +{ + error_t err; + mach_port_t port; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + if (obj) + { + port = mom_fetch_mach_port (obj); + assert (offset % vm_page_size == 0); + } + else + port = MACH_PORT_NULL; + + mutex_lock (&_mom_memory_lock); + err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, + port, (obj ? offset : 0), (obj ? copy : 0), + (VM_PROT_READ | VM_PROT_EXECUTE + | (!readonly ? VM_PROT_WRITE : 0)), + VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE, + VM_INHERIT_COPY); + mutex_unlock (&_mom_memory_lock); + return err; +} diff --git a/libmom/allocate-memory.c b/libmom/allocate-memory.c new file mode 100644 index 00000000..d98632bc --- /dev/null +++ b/libmom/allocate-memory.c @@ -0,0 +1,51 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_allocate_memory (void **start, size_t len, int readonly, + struct mom_port_ref *obj, size_t offset, + int copy) +{ + error_t err; + mach_port_t port; + + assert (len % vm_page_size == 0); + if (obj) + { + port = mom_fetch_mach_port (obj); + assert (offset % vm_page_size == 0); + } + else + port = MACH_PORT_NULL; + + *start = 0; + + mutex_lock (&_mom_memory_lock); + err = vm_map (mach_task_self (), (vm_address_t *)start, len, 0, 0, + port, (obj ? offset : 0), (obj ? copy : 0), + (VM_PROT_READ | VM_PROT_EXECUTE + | (!readonly ? VM_PROT_WRITE : 0)), + VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE, + VM_INHERIT_COPY); + mutex_unlock (&_mom_memory_lock); + return err; +} diff --git a/libmom/copy-ref.c b/libmom/copy-ref.c new file mode 100644 index 00000000..f0d37954 --- /dev/null +++ b/libmom/copy-ref.c @@ -0,0 +1,43 @@ +/* Copy a mom port reference + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_copy_ref (struct mom_port_ref *new, + struct mom_port_ref *obj) +{ + error_t err; + + new->lock = SPIN_LOCK_INITIALIZER; + + spin_lock (&obj->lock); + assert (obj->refcnt); + err = mach_port_mod_refs (mach_task_self (), + obj->port, MACH_PORT_RIGHT_SEND, 1); + new->port = obj->port; + spin_unlock (&obj->lock); + + if (err) + return err; + + new->refcnt = 1; + return 0; +} diff --git a/libmom/deallocate-memory.c b/libmom/deallocate-memory.c new file mode 100644 index 00000000..bf7acfdb --- /dev/null +++ b/libmom/deallocate-memory.c @@ -0,0 +1,35 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_deallocate_memory (void *start, size_t len) +{ + error_t err; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + + mutex_lock (&_mom_memory_lock); + err = vm_deallocate (mach_task_self (), (vm_address_t) start, len); + mutex_unlock (&_mom_memory_lock); + return err; +} diff --git a/libmom/fetch-mach-port.c b/libmom/fetch-mach-port.c new file mode 100644 index 00000000..b747485e --- /dev/null +++ b/libmom/fetch-mach-port.c @@ -0,0 +1,33 @@ +/* Return the Mach port corresponding to a mom port reference + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +mach_port_t +mom_fetch_mach_port (struct mom_port_ref *obj) +{ + mach_port_t ret; + + spin_lock (&obj->lock); + assert (obj->refcnt); + ret = obj->port; + spin_unlock (&obj->lock); + return ret; +} diff --git a/libmom/hash-ref.c b/libmom/hash-ref.c new file mode 100644 index 00000000..6c160b1b --- /dev/null +++ b/libmom/hash-ref.c @@ -0,0 +1,28 @@ +/* Return a hash key for a mom port + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +int +mom_hash_port (struct mom_port_ref *obj) +{ + return mom_fetch_mach_port (obj); +} + diff --git a/libmom/mach-port-set.c b/libmom/mach-port-set.c new file mode 100644 index 00000000..11619900 --- /dev/null +++ b/libmom/mach-port-set.c @@ -0,0 +1,32 @@ +/* Initialize a mom port reference from a Mach port + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_mach_port_set (struct mom_port_ref *obj, + mach_port_t port) +{ + obj->lock = SPIN_LOCK_INITIALIZER; + obj->port = port; + obj->refcnt = 1; + return 0; +} + diff --git a/libmom/make-memory-readonly.c b/libmom/make-memory-readonly.c new file mode 100644 index 00000000..e7ca4c87 --- /dev/null +++ b/libmom/make-memory-readonly.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_make_memory_readonly (void *start, size_t len) +{ + error_t err; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + + mutex_lock (&_mom_memory_lock); + err = vm_protect (mach_task_self (), (vm_address_t) start, len, 0, + VM_PROT_READ | VM_PROT_EXECUTE); + mutex_unlock (&_mom_memory_lock); + return err; +} diff --git a/libmom/make-memory-readwrite.c b/libmom/make-memory-readwrite.c new file mode 100644 index 00000000..f35e6bfd --- /dev/null +++ b/libmom/make-memory-readwrite.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_make_memory_readwrite (void *start, size_t len) +{ + error_t err; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + + mutex_lock (&_mom_memory_lock); + err = vm_protect (mach_task_self (), (vm_address_t) start, len, 0, + VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); + mutex_unlock (&_mom_memory_lock); + return err; +} diff --git a/libmom/memory-init.c b/libmom/memory-init.c new file mode 100644 index 00000000..38972018 --- /dev/null +++ b/libmom/memory-init.c @@ -0,0 +1,32 @@ +/* Initialization and static data for mom memory management. + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +struct mutex _mom_memory_lock = MUTEX_INITIALIZER; +size_t mom_page_size; + +static void init_memory (void) __attribute__ ((constructor)); + +static void +init_memory (void) +{ + mom_page_size = vm_page_size; +} diff --git a/libmom/mom-kerndep.h b/libmom/mom-kerndep.h new file mode 100644 index 00000000..3534fdc7 --- /dev/null +++ b/libmom/mom-kerndep.h @@ -0,0 +1,43 @@ +/* Mach-specific type definitions for MOM + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 +#include + +struct mom_port_ref +{ + spin_lock_t lock; + mach_port_t port; + int refcnt; +}; + +/* Mach-specific functions */ + +/* Initialize OBJ with a reference to Mach port PORT. One Mach user + reference is consumed. OBJ should not currently be used, and will + have one reference upon return. */ +error_t mom_mach_port_set (struct mom_port_ref *obj, mach_port_t port); + +/* Return the Mach port corresponding to OBJ. No new Mach user + references are created, so this Mach port should only be used as + long as the user has a reference to OBJ. */ +mach_port_t mom_fetch_mach_port (struct mom_port_ref *obj); + + diff --git a/libmom/mom.h b/libmom/mom.h new file mode 100644 index 00000000..8a2c1667 --- /dev/null +++ b/libmom/mom.h @@ -0,0 +1,138 @@ +/* Microkernel object module + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 +#include + +/* This header file defines structure layouts for the use of functions + below; it is specific to the particular microkernel in use. */ +#include + + + + + +/* User RPC endpoints */ + +/* A communications end-point suitable for sending RPC's to servers. */ +struct mom_port_ref; /* layout defined in mom-kerndep.h */ + +/* Add a reference to to port reference OBJ. */ +error_t mom_add_ref (struct mom_port_ref *obj); + +/* Drop a reference from port reference OBJ. If this is the last reference, + then OBJ should no longer be used for further mom operations. */ +error_t mom_drop_ref (struct mom_port_ref *obj); + +/* Create a new port reference that refers to the same underlying channel + as OBJ. Fill *NEW with the new reference. NEW should be otherwise + unused memory. The new reference will have a refcount of one (as if + mom_add_ref had been called on it already). */ +error_t mom_copy_ref (struct mom_port_ref *new, struct mom_port_ref *obj); + +/* Tell if two mom ports refer to the same underlying server RPC channel */ +int mom_refs_identical (struct mom_port_ref *obj1, struct mom_port_ref *obj2); + +/* Return a hash key for a port. Different ports may have the same + hash key, but no port's hash key will ever change as long as that + port is known to this task. Two identical ports (as by + mom_ports_identical) will always have the same hash key. */ +int mom_hash_ref (struct mom_port_ref *obj); + +/* Destroy mom port reference OBJ. All existing references go away, + and the underlying kernel object is deallocated. After this call, + the memory in *OBJ may be used by the user for any purpose. It + is an error to call this routine if any other thread might be calling + any other mom port reference function on OBJ concurrently. */ +void mom_ref_destroy (struct mom_port_ref *obj); + + + +/* Memory management */ + +/* Size of a physical page; mom memory management calls must be in + aligned multiples of this value. */ +extern size_t mom_page_size; + +/* Reserve a region of memory from START and continuing for LEN bytes + so that it won't be used by anyone, but don't make it directly + usable. */ +error_t mom_reserve_memory (void *start, size_t len); + +/* Reserve a region of memory anywhere of size LEN bytes and return + its address in ADDR. */ +error_t mom_reserve_memory_anywhere (void **addr, size_t len); + +/* Make a reserved region of memory usable, as specified by START and + LEN. If READONLY is set then only make it available for read + access; otherwise permit both read and write. If OBJ is null, then + use zero-filled anonymous storage. If OBJ is non-null, then it + specifies a mom port reference referring to a memory server, and + OFFSET is the offset within that server. If COPY is set, then the + data is copied from the memory object, otherwise it shares with + other users of the same object. */ +error_t mom_use_memory (void *start, size_t len, int readonly, + struct mom_port_ref *obj, size_t offset, + int copy); + +/* Ask the kernel to wire the region of memory specified to physical + memory. The exact semantics of this are kernel dependent; it is + also usually privileged in some fashion and will fail for + non-privileged users. */ +error_t mom_wire_memory (void *start, size_t len); + +/* Convert a region of usable memory to read-only */ +error_t mom_make_memory_readonly (void *start, size_t len); + +/* Convert a region of usable memory to read/write */ +error_t mom_make_memory_readwrite (void *start, size_t len); + +/* Convert a region of usable memory to reserved but unusable status. */ +error_t mom_unuse_memory (void *start, size_t len); + +/* Convert a region of reserved unusable memory to unreserved status. */ +error_t mom_unreserve_memory (void *start, size_t len); + + + +/* Optimized combination versions of memory functions; these are very + likely to be faster than using the two call sequences they are + equivalent to. */ + +/* Combined version of mom_unuse_memory followed by mom_unreserve_memory. */ +error_t mom_deallocate_memory (void *start, size_t len); + +/* Combined version of mom_reserve_memory and mom_use_memory. */ +error_t mom_allocate_address (void *start, size_t len, int readonly, + struct mom_port_ref *obj, size_t offset, + int copy); + +/* Combined version of mom_reserve_memory_anywhere and mom_use_memory. */ +error_t mom_allocate_memory (void **start, size_t len, int readonly, + struct mom_port_ref *obj, size_t offset, + int copy); + +/* Shorthand for the most common sort of allocation--like mom_allocate_memory, + but READONLY, and OBJ are both null. */ +#define mom_allocate(start,len) \ + (mom_allocate_memory ((start), (len), 0, 0, 0, 0)) + diff --git a/libmom/priv.h b/libmom/priv.h new file mode 100644 index 00000000..88d2d9ed --- /dev/null +++ b/libmom/priv.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "mom.h" +#include +#include + +extern struct mutex _mom_memory_lock; + + diff --git a/libmom/ref-destroy.c b/libmom/ref-destroy.c new file mode 100644 index 00000000..3e9266ec --- /dev/null +++ b/libmom/ref-destroy.c @@ -0,0 +1,33 @@ +/* Completely destroy a MOM port + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +void +mom_ref_destroy (struct mom_port_ref *obj) +{ + spin_lock (&obj->lock); + assert (obj->refcnt); + mach_port_deallocate (mach_task_self (), obj->port); + obj->refcnt = 0; + spin_unlock (&obj->lock); +} + + diff --git a/libmom/refs-identical.c b/libmom/refs-identical.c new file mode 100644 index 00000000..74dad9b8 --- /dev/null +++ b/libmom/refs-identical.c @@ -0,0 +1,43 @@ +/* Tell if two mom port references refer to the same channel + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +int +mom_ports_identical (struct mom_port_ref *obj1, + struct mom_port_ref *obj2) +{ + int ret; + + tryagain: + spin_lock (&obj1->lock); + if (!spin_try_lock (&obj2->lock)) + { + spin_unlock (&obj1->lock); + goto tryagain; + } + assert (obj1->refcnt); + assert (obj2->refcnt); + + ret = (obj1->port == obj2->port); + spin_unlock (&obj1->lock); + spin_unlock (&obj2->lock); + return ret; +} diff --git a/libmom/reserve-memory-anywhere.c b/libmom/reserve-memory-anywhere.c new file mode 100644 index 00000000..40f9ec00 --- /dev/null +++ b/libmom/reserve-memory-anywhere.c @@ -0,0 +1,40 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_reserve_memory_anywhere (void **start, size_t len) +{ + error_t err; + + assert (len % vm_page_size == 0); + + *start = 0; + + mutex_lock (&_mom_memory_lock); + err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 1, + MACH_PORT_NULL, 0, 0, 0, + VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, + VM_INHERIT_COPY); + mutex_unlock (&_mom_memory_lock); + + return err; +} diff --git a/libmom/reserve-memory.c b/libmom/reserve-memory.c new file mode 100644 index 00000000..ada9ef02 --- /dev/null +++ b/libmom/reserve-memory.c @@ -0,0 +1,42 @@ +/* Reserve memory + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_reserve_memory (void *start, size_t len) +{ + error_t err; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + + mutex_lock (&_mom_memory_lock); + err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, + MACH_PORT_NULL, 0, 0, 0, + VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, + VM_INHERIT_COPY); + mutex_unlock (&_mom_memory_lock); + + return err; +} + + diff --git a/libmom/unreserve-memory.c b/libmom/unreserve-memory.c new file mode 100644 index 00000000..88e8eb94 --- /dev/null +++ b/libmom/unreserve-memory.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_unreserve_memory (void *start, size_t len) +{ + return mom_deallocate_memory (start, len); +} diff --git a/libmom/unuse-memory.c b/libmom/unuse-memory.c new file mode 100644 index 00000000..363f2a45 --- /dev/null +++ b/libmom/unuse-memory.c @@ -0,0 +1,43 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +error_t +mom_unuse_memory (void *start, size_t len) +{ + error_t err; + + assert ((vm_address_t) start % vm_page_size == 0); + assert (len % vm_page_size == 0); + + mutex_lock (&_mom_memory_lock); + /* Deallocate and reallocate so that we drop any mapping around. */ + err = vm_deallocate (mach_task_self (), (vm_address_t) start, len); + if (!err) + err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, + MACH_PORT_NULL, 0, 0, 0, + VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, + VM_INHERIT_COPY); + mutex_unlock (&_mom_memory_lock); + return err; +} + + diff --git a/libmom/wire-memory.c b/libmom/wire-memory.c new file mode 100644 index 00000000..b3832154 --- /dev/null +++ b/libmom/wire-memory.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + + +error_t +mom_wire_memory (void *start, size_t len) +{ + return EOPNOTSUPP; +} -- cgit v1.2.3 From cf7d5a831621f3dd3899265c9cce682f2bc0c450 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 19:20:14 +0000 Subject: (installhdrsubdir): Install headers in main include dir. --- libmom/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libmom/Makefile b/libmom/Makefile index 61796585..c2dd9668 100644 --- a/libmom/Makefile +++ b/libmom/Makefile @@ -32,6 +32,7 @@ SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ LCLHDRS = mom.h mom-kernep.h priv.h installhdrs = mom.h mom-kerndep.h +installhdrsubdir = . OBJS = $(SRCS:.c=.o) -- cgit v1.2.3 From bc5ae316b93e870c9e6761e96ccfca626d408a45 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 19:20:44 +0000 Subject: (LCLHDRS): foo --- libmom/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmom/Makefile b/libmom/Makefile index c2dd9668..a2339fa7 100644 --- a/libmom/Makefile +++ b/libmom/Makefile @@ -30,7 +30,7 @@ SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ wire-memory.c -LCLHDRS = mom.h mom-kernep.h priv.h +LCLHDRS = mom.h mom-kerndep.h priv.h installhdrs = mom.h mom-kerndep.h installhdrsubdir = . -- cgit v1.2.3 From 7fc11823b9cfa6e973eeb9e6341ddbbc87439371 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:14:50 +0000 Subject: Initial revision --- libmom/mom-errors.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 libmom/mom-errors.h diff --git a/libmom/mom-errors.h b/libmom/mom-errors.h new file mode 100644 index 00000000..b752369f --- /dev/null +++ b/libmom/mom-errors.h @@ -0,0 +1,45 @@ +/* Error codes for MOM library + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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. */ + + +/* MOM uses Mach error system 0x11 and subsystem 0. */ +#define _MOM_ERRNO(n) ((0x11 << 26 | ((n) & 0x3fff))) + +enum __momerrors_error_codes +{ + /* These are standard errors to be returned by RPC user stubs + in Mom systems. */ + + /* All Mom systems must detect and return these errors */ + + /* The RPC attempted to send to an invalid mom_port_ref. This can + happen because, for example, the server it spoke to has died. */ + EMOM_INVALID_DEST = _MOM_ERRNO (1), + + /* The RPC attempted to send an invalid mom_port_ref in its content. + This shall not happen if the server the reference is to has + merely died. */ + EMOM_INVALID_REF = _MOM_ERRNO (2), + + /* The server began processing the RPC, but at some point it died. */ + EMOM_SERVER_DIED = _MOM_ERRNO (3) +}; + + -- cgit v1.2.3 From d1df6aa36d4c408660069c64d9edc3db16bf1be1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:15:27 +0000 Subject: (LCLHDRS, installhdrs): Add mom-errors.h. --- libmom/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmom/Makefile b/libmom/Makefile index a2339fa7..38888d02 100644 --- a/libmom/Makefile +++ b/libmom/Makefile @@ -30,8 +30,8 @@ SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ wire-memory.c -LCLHDRS = mom.h mom-kerndep.h priv.h -installhdrs = mom.h mom-kerndep.h +LCLHDRS = mom.h mom-kerndep.h priv.h mom-errors.h +installhdrs = mom.h mom-kerndep.h mom-errors.h installhdrsubdir = . OBJS = $(SRCS:.c=.o) -- cgit v1.2.3 From 8f602d46b55345893f5d8d13d73753e1878ea21d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:16:25 +0000 Subject: *** empty log message *** --- libmom/mom-errors.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmom/mom-errors.h b/libmom/mom-errors.h index b752369f..85a35d5e 100644 --- a/libmom/mom-errors.h +++ b/libmom/mom-errors.h @@ -42,4 +42,6 @@ enum __momerrors_error_codes EMOM_SERVER_DIED = _MOM_ERRNO (3) }; +typedef enum __momerrors_error_codes mom_error_t; + -- cgit v1.2.3 From 46301982452b7f819be7ffaf35910b3d3904e63e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:17:15 +0000 Subject: (mom_error_translate_mach): New function. --- libmom/mom-kerndep.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmom/mom-kerndep.h b/libmom/mom-kerndep.h index 3534fdc7..d14bc246 100644 --- a/libmom/mom-kerndep.h +++ b/libmom/mom-kerndep.h @@ -40,4 +40,5 @@ error_t mom_mach_port_set (struct mom_port_ref *obj, mach_port_t port); long as the user has a reference to OBJ. */ mach_port_t mom_fetch_mach_port (struct mom_port_ref *obj); - +/* Turn a Mach error number into a Mom error number. */ +mom_error_t mom_error_translate_mach (error_t macherr); -- cgit v1.2.3 From 5ef1be476b7c7ede79af15ebe687a841bfe9e77a Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:19:06 +0000 Subject: Initial revision --- libmom/error-trans.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libmom/error-trans.c diff --git a/libmom/error-trans.c b/libmom/error-trans.c new file mode 100644 index 00000000..e1fbbc84 --- /dev/null +++ b/libmom/error-trans.c @@ -0,0 +1,40 @@ +/* + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 "priv.h" + +mom_error_t +mom_error_translate_mach (error_t macherr) +{ + switch (macherr) + { + case MACH_SEND_INVALID_DEST: + return EMOM_INVALID_DEST; + + case MACH_SEND_INVALID_RIGHT: + return EMOM_INVALID_REF; + + case MIG_SERVER_DIED: + return EMOM_SERVER_DIED; + + default: + return macherr; + } +} -- cgit v1.2.3 From 84b287dfa2aa96a62bf60cb33433c108a2d298a7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:19:36 +0000 Subject: (SRCS): Add error-trans.c. --- libmom/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmom/Makefile b/libmom/Makefile index 38888d02..e5dd9883 100644 --- a/libmom/Makefile +++ b/libmom/Makefile @@ -28,7 +28,7 @@ SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ mach-port-set.c make-memory-readonly.c make-memory-readwrite.c \ memory-init.c ref-destroy.c refs-identical.c reserve-memory.c \ reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ - wire-memory.c + wire-memory.c error-trans.c LCLHDRS = mom.h mom-kerndep.h priv.h mom-errors.h installhdrs = mom.h mom-kerndep.h mom-errors.h -- cgit v1.2.3 From 480fe2319980408b1c681d772819d551994a821d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:20:09 +0000 Subject: Include . --- libmom/mom.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmom/mom.h b/libmom/mom.h index 8a2c1667..a067dfc9 100644 --- a/libmom/mom.h +++ b/libmom/mom.h @@ -23,6 +23,8 @@ #include #include +#include + /* This header file defines structure layouts for the use of functions below; it is specific to the particular microkernel in use. */ #include -- cgit v1.2.3 From 437d0cde905a9c1d946d3690f7f369c2000ab1a7 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 24 May 1996 20:26:21 +0000 Subject: (mom_error_translate_mach): --- libmom/error-trans.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmom/error-trans.c b/libmom/error-trans.c index e1fbbc84..57ef7e31 100644 --- a/libmom/error-trans.c +++ b/libmom/error-trans.c @@ -25,13 +25,13 @@ mom_error_translate_mach (error_t macherr) { switch (macherr) { - case MACH_SEND_INVALID_DEST: + case EMACH_SEND_INVALID_DEST: return EMOM_INVALID_DEST; - case MACH_SEND_INVALID_RIGHT: + case EMACH_SEND_INVALID_RIGHT: return EMOM_INVALID_REF; - case MIG_SERVER_DIED: + case EMIG_SERVER_DIED: return EMOM_SERVER_DIED; default: -- cgit v1.2.3 From b1cfa09152968deb01c062c78970f56a38604bd1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:25:04 +0000 Subject: (mom_add_ref, mom_drop_ref): Delete functions. --- libmom/mom.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libmom/mom.h b/libmom/mom.h index a067dfc9..3cfa5218 100644 --- a/libmom/mom.h +++ b/libmom/mom.h @@ -38,13 +38,6 @@ /* A communications end-point suitable for sending RPC's to servers. */ struct mom_port_ref; /* layout defined in mom-kerndep.h */ -/* Add a reference to to port reference OBJ. */ -error_t mom_add_ref (struct mom_port_ref *obj); - -/* Drop a reference from port reference OBJ. If this is the last reference, - then OBJ should no longer be used for further mom operations. */ -error_t mom_drop_ref (struct mom_port_ref *obj); - /* Create a new port reference that refers to the same underlying channel as OBJ. Fill *NEW with the new reference. NEW should be otherwise unused memory. The new reference will have a refcount of one (as if -- cgit v1.2.3 From 43eb6a2cf0df2966178f1c4c424f7ee27194c4d6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:26:28 +0000 Subject: (SRCS): Delete add-ref.c and drop-ref.c. --- libmom/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmom/Makefile b/libmom/Makefile index e5dd9883..04df2c9c 100644 --- a/libmom/Makefile +++ b/libmom/Makefile @@ -23,8 +23,8 @@ makemode := library libname = libmom -SRCS = add-ref.c allocate-address.c allocate-memory.c copy-ref.c \ - deallocate-memory.c drop-ref.c fetch-mach-port.c hash-ref.c \ +SRCS = allocate-address.c allocate-memory.c copy-ref.c \ + deallocate-memory.c fetch-mach-port.c hash-ref.c \ mach-port-set.c make-memory-readonly.c make-memory-readwrite.c \ memory-init.c ref-destroy.c refs-identical.c reserve-memory.c \ reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ -- cgit v1.2.3 From c1ed304a50e1551cf5a4cb87f637b18edfcbbaac Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:27:07 +0000 Subject: (struct mom_port_ref): Delete members `lock' and `refcnt'. --- libmom/mom-kerndep.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmom/mom-kerndep.h b/libmom/mom-kerndep.h index d14bc246..7c12423d 100644 --- a/libmom/mom-kerndep.h +++ b/libmom/mom-kerndep.h @@ -23,9 +23,7 @@ struct mom_port_ref { - spin_lock_t lock; mach_port_t port; - int refcnt; }; /* Mach-specific functions */ -- cgit v1.2.3 From 65bd31d97750153efaadb7428d4c68d6bb85ff05 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:27:54 +0000 Subject: doc fixes. --- libmom/mom-kerndep.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libmom/mom-kerndep.h b/libmom/mom-kerndep.h index 7c12423d..cc61db05 100644 --- a/libmom/mom-kerndep.h +++ b/libmom/mom-kerndep.h @@ -29,13 +29,12 @@ struct mom_port_ref /* Mach-specific functions */ /* Initialize OBJ with a reference to Mach port PORT. One Mach user - reference is consumed. OBJ should not currently be used, and will - have one reference upon return. */ + reference is consumed. */ error_t mom_mach_port_set (struct mom_port_ref *obj, mach_port_t port); /* Return the Mach port corresponding to OBJ. No new Mach user - references are created, so this Mach port should only be used as - long as the user has a reference to OBJ. */ + references are created, so this Mach port should not be used + after OBJ has been destroyed. */ mach_port_t mom_fetch_mach_port (struct mom_port_ref *obj); /* Turn a Mach error number into a Mom error number. */ -- cgit v1.2.3 From d529504878d87a1ca1065ffbba4cdf2143204e00 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:28:53 +0000 Subject: Doc fixes. --- libmom/mom.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libmom/mom.h b/libmom/mom.h index 3cfa5218..75d4b08d 100644 --- a/libmom/mom.h +++ b/libmom/mom.h @@ -40,8 +40,7 @@ struct mom_port_ref; /* layout defined in mom-kerndep.h */ /* Create a new port reference that refers to the same underlying channel as OBJ. Fill *NEW with the new reference. NEW should be otherwise - unused memory. The new reference will have a refcount of one (as if - mom_add_ref had been called on it already). */ + unused memory. */ error_t mom_copy_ref (struct mom_port_ref *new, struct mom_port_ref *obj); /* Tell if two mom ports refer to the same underlying server RPC channel */ @@ -53,11 +52,11 @@ int mom_refs_identical (struct mom_port_ref *obj1, struct mom_port_ref *obj2); mom_ports_identical) will always have the same hash key. */ int mom_hash_ref (struct mom_port_ref *obj); -/* Destroy mom port reference OBJ. All existing references go away, - and the underlying kernel object is deallocated. After this call, - the memory in *OBJ may be used by the user for any purpose. It - is an error to call this routine if any other thread might be calling - any other mom port reference function on OBJ concurrently. */ +/* Destroy mom port reference OBJ and deallocate the underlying kernel + object. After this call, the memory in *OBJ may be used by the + user for any purpose. It is an error to call this routine if any + other thread might be calling any other mom port reference function + on OBJ concurrently. */ void mom_ref_destroy (struct mom_port_ref *obj); -- cgit v1.2.3 From 31d1dc038bdfc16cc196ee348658695ea2215198 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:32:26 +0000 Subject: (mom_copy_ref): Omit uses of deleted members of struct mom_port_ref.c --- libmom/copy-ref.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/libmom/copy-ref.c b/libmom/copy-ref.c index f0d37954..03d4ab45 100644 --- a/libmom/copy-ref.c +++ b/libmom/copy-ref.c @@ -26,18 +26,9 @@ mom_copy_ref (struct mom_port_ref *new, { error_t err; - new->lock = SPIN_LOCK_INITIALIZER; - - spin_lock (&obj->lock); - assert (obj->refcnt); err = mach_port_mod_refs (mach_task_self (), obj->port, MACH_PORT_RIGHT_SEND, 1); - new->port = obj->port; - spin_unlock (&obj->lock); - - if (err) - return err; - - new->refcnt = 1; - return 0; + if (!err) + new->port = obj->port; + return err; } -- cgit v1.2.3 From f45889af418cfaa6af8053c9c4774e56eefde1e3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:33:13 +0000 Subject: (mom_fetch_mach_port): Omit uses of deleted members of struct mom_port_ref.c --- libmom/fetch-mach-port.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libmom/fetch-mach-port.c b/libmom/fetch-mach-port.c index b747485e..85262600 100644 --- a/libmom/fetch-mach-port.c +++ b/libmom/fetch-mach-port.c @@ -23,11 +23,5 @@ mach_port_t mom_fetch_mach_port (struct mom_port_ref *obj) { - mach_port_t ret; - - spin_lock (&obj->lock); - assert (obj->refcnt); - ret = obj->port; - spin_unlock (&obj->lock); - return ret; + return obj->port; } -- cgit v1.2.3 From bce49690ea50e1984db99f4e3fbf82ccbff407aa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:33:54 +0000 Subject: (mom_mach_port_set): Omit uses of deleted members of struct mom_port_ref.c. --- libmom/mach-port-set.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmom/mach-port-set.c b/libmom/mach-port-set.c index 11619900..ed6842fd 100644 --- a/libmom/mach-port-set.c +++ b/libmom/mach-port-set.c @@ -24,9 +24,7 @@ error_t mom_mach_port_set (struct mom_port_ref *obj, mach_port_t port) { - obj->lock = SPIN_LOCK_INITIALIZER; obj->port = port; - obj->refcnt = 1; return 0; } -- cgit v1.2.3 From d23a87a2d777775cc12ac2091e3ee2f5f651e571 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:34:28 +0000 Subject: (mom_ref_destroy): Omit uses of deleted members of struct mom_port_ref.c. --- libmom/ref-destroy.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libmom/ref-destroy.c b/libmom/ref-destroy.c index 3e9266ec..6966bcdc 100644 --- a/libmom/ref-destroy.c +++ b/libmom/ref-destroy.c @@ -23,11 +23,7 @@ void mom_ref_destroy (struct mom_port_ref *obj) { - spin_lock (&obj->lock); - assert (obj->refcnt); mach_port_deallocate (mach_task_self (), obj->port); - obj->refcnt = 0; - spin_unlock (&obj->lock); } -- cgit v1.2.3 From e297907c89e7d8ffc86fcf064c12bb4e1b118fa0 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 25 May 1996 21:35:31 +0000 Subject: (mom_ports_identical): Omit uses of deleted members of struct mom_port_ref.c. --- libmom/refs-identical.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/libmom/refs-identical.c b/libmom/refs-identical.c index 74dad9b8..0c4ee885 100644 --- a/libmom/refs-identical.c +++ b/libmom/refs-identical.c @@ -24,20 +24,5 @@ int mom_ports_identical (struct mom_port_ref *obj1, struct mom_port_ref *obj2) { - int ret; - - tryagain: - spin_lock (&obj1->lock); - if (!spin_try_lock (&obj2->lock)) - { - spin_unlock (&obj1->lock); - goto tryagain; - } - assert (obj1->refcnt); - assert (obj2->refcnt); - - ret = (obj1->port == obj2->port); - spin_unlock (&obj1->lock); - spin_unlock (&obj2->lock); - return ret; + return obj1->port == obj2->port; } -- cgit v1.2.3 From b6f8fd79185db469c0de9752da60817141e9ebda Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 15 Jun 1996 18:13:18 +0000 Subject: ([hrs]d*): Allow user to specify slice as well. Patch from Gord Matzigkeit, gord@enci.ucalgary.ca. --- devio/MAKEDEV | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index d992d06a..b113e3c1 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -62,12 +62,12 @@ for I; do [hrs]d*) case "$I" in - [a-z][a-z][0-9][a-z]) + [a-z][a-z][0-9][a-z] | [a-z][a-z][0-9]s[1-9]) $ST r$I /hurd/devio $I $ST $I /hurd/devio -b $I ;; *) - echo 1>&2 $0: $I: Must supply a device number and partition + echo 1>&2 $0: $I: Must supply a device number and partition or slice exit 1 ;; esac -- cgit v1.2.3 From c45594bacc24c92f76d76902f556537ff69a15fa Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 15 Jun 1996 18:52:43 +0000 Subject: (options): New variable. (parse_opt): New function. (main): Parse ufs-specific options too. : New include. --- ufs/main.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 5ba1b318..58c6f427 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -24,6 +24,7 @@ #include #include #include +#include char *ufs_version = "0.0"; @@ -55,14 +56,49 @@ int printf (const char *fmt, ...) int diskfs_readonly; +/* Ufs-specific options. XXX this should be moved so it can be done at + runtime as well as startup. */ +static struct argp_option +options[] = +{ + {"compat", 'C', "FMT", 0, + "FMT may be GNU, 4.4, or 4.2, and determines which filesystem extensions" + " are written onto the disk (default is GNU)"}, + {0} +}; + +/* Parse a command line option. */ +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case 'C': + if (strcasecmp (arg, "gnu") == 0) + compat_mode = COMPAT_GNU; + else if (strcmp (arg, "4.4") == 0) + compat_mode = COMPAT_BSD44; + else if (strcmp (arg, "4.2") == 0) + compat_mode = COMPAT_BSD42; + else + argp_error (state, "%s: Unknown compatibility mode", arg); + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + int main (int argc, char **argv) { error_t err; off_t disk_size; mach_port_t bootstrap; + const struct argp *argp_parents[] = { diskfs_device_startup_argp, 0 }; + struct argp argp = {options, parse_opt, 0, 0, argp_parents}; - argp_parse (diskfs_device_startup_argp, argc, argv, 0, 0, 0); + argp_parse (&argp, argc, argv, 0, 0, 0); /* This must come after the args have been parsed, as this is where the host priv ports are set for booting. */ -- cgit v1.2.3 From 923dcfffdbb1af8179106b82fb4b4ed84210f647 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 20 Jun 1996 12:30:09 +0000 Subject: Remove all the complexity and just do the bare minimum. --- SETUP | 136 ++++-------------------------------------------------------------- 1 file changed, 7 insertions(+), 129 deletions(-) diff --git a/SETUP b/SETUP index f684396e..13101df8 100644 --- a/SETUP +++ b/SETUP @@ -1,133 +1,11 @@ #!/bin/bash -# -# Setup initial hurd translators -# -# This script tries to setup a reasonable set of translators for a newly -# untarred hurd filesystem (since tar currently isn't able to do it). -# -# By passing in a value in the environment variable ROOT, an alternate root -# filesystem may be setup. -# +# Setup critical hurd translators -# A list of likely mach devices to try -DISK_DEVS="`eval echo {s,h}d{0,1,2,3,4}{a,b,c,d,e,f,g,h}`" -NET_DEVS="`eval echo {eth,ne,wd,ul}{0,1,2,3,4}`" +set -v -ROOT=${ROOT:-/} -case "$ROOT" in - /) PFX="";; - *) PFX="$ROOT";; -esac +# Set up the PFLOCAL server so we can do pipes +/bin/settrans -c /servers/socket/1 /hurd/pflocal -DEV=${DEV:-/dev} -SERVE=${SERVE:-$PFX/servers} - -PDEV=$PFX$DEV -SOCK=$SERVE/socket - -function st { - /bin/settrans -c "$@" -} -function gt { - /bin/showtrans 2>/dev/null "$@" -} - -# Test to see whether a node has a translator -function tp { - /bin/showtrans -s 2>/dev/null "$@" -} - -# Make a device (MAKEDEV uses $_CWD as the device directory) -function md { - (cd $PDEV && _CWD=$DEV $PDEV/MAKEDEV "$@") -} - -function devs { - /bin/devprobe "$@" -} - -PATH=/bin - -echo '(For most prompts, `none'\'' is also a valid input)' - -# Setup pflocal first, since the shell wants to use it -if tp $SOCK/1; then - echo "PFLOCAL translator present." -else - echo "Setting PFLOCAL translator..." - st $SOCK/1 /hurd/pflocal -fi - -if tp $PDEV/console && tp $PDEV/null && tp $PDEV/fd; then - echo "Standard devices already present." -else - echo "Making standard devices..." - md std -fi - -# See which disk devices might need creating -DISK_DEVS="`devs $DISK_DEVS`" -if test "$DISK_DEVS"; then - echo "Mach disk devices found: `echo $DISK_DEVS`" -else - echo "No mach disk devices found!" -fi - -ALREADY='' -MAYBE='' -for D in $DISK_DEVS; do - if tp $PDEV/r$D; then - ALREADY="${ALREADY:+$ALREADY }$D" - else - MAYBE="${MAYBE:+$MAYBE }$D" - fi -done -if test "$ALREADY"; then - echo "Disk devices with nodes in $PDEV: $ALREADY" -fi -if test "$MAYBE"; then - echo -n "Create device nodes in $PDEV for: [$MAYBE] "; read CREATE - if [ "$CREATE" != none ]; then - md ${CREATE:-$MAYBE} - fi -fi - -NET_DEVS="`devs $NET_DEVS`" -if test "$NET_DEVS"; then - echo "Mach network devices found: $NET_DEVS" -else - echo "No mach network devices found." -fi - -NET_TRANS="`gt $SOCK/2`" -if test "$NET_TRANS"; then - echo "PFINET translator present: $NET_TRANS" - echo -n "Change PFINET translator? [n] "; read yn - case "$yn" in - [Yy]*) - read dummy DEF_NET_ADDR DEF_NET_DEV < Date: Fri, 21 Jun 1996 06:05:13 +0000 Subject: (parse_opt): Handle runtime invalid selection of 4.2 mode. Save select mode until we're done to correctly deal with external errors at runtime. (startup_parents, startup_argp, runtime_parents, runtime_argp): New variables. (main): Argp vars made global. (startup_parents): diskfs_device_startup_argp --> &diskfs_std_device_startup_argp. --- ufs/main.c | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 58c6f427..ac3a34bb 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -73,32 +73,69 @@ parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { + enum compat_mode mode; + case 'C': if (strcasecmp (arg, "gnu") == 0) - compat_mode = COMPAT_GNU; + mode = COMPAT_GNU; else if (strcmp (arg, "4.4") == 0) - compat_mode = COMPAT_BSD44; + mode = COMPAT_BSD44; else if (strcmp (arg, "4.2") == 0) - compat_mode = COMPAT_BSD42; + { + if (sblock + && (sblock->fs_inodefmt == FS_44INODEFMT + || direct_symlink_extension)) + { + argp_failure (state, 0, 0, + "4.2 compat mode requested on 4.4 fs"); + return EINVAL; + } + mode = COMPAT_BSD42; + } else - argp_error (state, "%s: Unknown compatibility mode", arg); + { + argp_error (state, "%s: Unknown compatibility mode", arg); + return EINVAL; + } + + state->hook = (void *)mode; /* Save it for the end. */ break; + + case ARGP_KEY_INIT: + state->hook = (void *)compat_mode; break; + case ARGP_KEY_SUCCESS: + compat_mode = (enum compat_mode)state->hook; break; + default: return ARGP_ERR_UNKNOWN; } return 0; } +static const struct argp *startup_parents[] = { + &diskfs_std_device_startup_argp, 0 +}; +static const struct argp startup_argp = { + options, parse_opt, 0, 0, startup_parents +}; + +static const struct argp *runtime_parents[] = { + &diskfs_std_runtime_argp, 0 +}; +static const struct argp runtime_argp = { + options, parse_opt, 0, 0, runtime_parents +}; + +struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; + int main (int argc, char **argv) { error_t err; off_t disk_size; mach_port_t bootstrap; - const struct argp *argp_parents[] = { diskfs_device_startup_argp, 0 }; - struct argp argp = {options, parse_opt, 0, 0, argp_parents}; - argp_parse (&argp, argc, argv, 0, 0, 0); + argp_parse (&startup_argp, argc, argv, 0, 0, 0); /* This must come after the args have been parsed, as this is where the host priv ports are set for booting. */ -- cgit v1.2.3 From 74a567c88204f07f8951c5b859afd89f303f2140 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 21 Jun 1996 06:16:59 +0000 Subject: (fd_get_device): Supply new args to store_create. --- ufs-utils/dlabel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c index 33db56da..e3678310 100644 --- a/ufs-utils/dlabel.c +++ b/ufs-utils/dlabel.c @@ -37,7 +37,7 @@ fd_get_device (int fd, device_t *device) if (node == MACH_PORT_NULL) return errno; - err = store_create (node, &store); + err = store_create (node, 0, 0, &store); if (! err) { if (store->class != STORAGE_DEVICE -- cgit v1.2.3 From 821993cf17d309df2bb103d21ef1122fd8cce77f Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jun 1996 21:45:52 +0000 Subject: (diskfs_get_options): New function. --- ufs/main.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index ac3a34bb..617796d8 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -111,23 +111,40 @@ parse_opt (int key, char *arg, struct argp_state *state) } return 0; } - -static const struct argp *startup_parents[] = { - &diskfs_std_device_startup_argp, 0 -}; -static const struct argp startup_argp = { - options, parse_opt, 0, 0, startup_parents -}; -static const struct argp *runtime_parents[] = { - &diskfs_std_runtime_argp, 0 -}; -static const struct argp runtime_argp = { - options, parse_opt, 0, 0, runtime_parents -}; +/* Add our startup arguments to the standard diskfs set. */ +static struct argp *startup_parents[] = { &diskfs_std_device_startup_argp, 0}; +static struct argp startup_argp = {options, parse_opt, 0, 0, startup_parents}; + +/* Similarly at runtime. */ +static struct argp *runtime_parents[] = {&diskfs_std_runtime_argp, 0}; +static struct argp runtime_argp = {options, parse_opt, 0, 0, runtime_parents}; struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; +/* Override the standard diskfs routine so we can add our own output. */ +error_t +diskfs_get_options (char **argz, unsigned *argz_len) +{ + error_t err; + + *argz = 0; + *argz_len = 0; + + /* Get the standard things. */ + err = diskfs_append_std_options (argz, argz_len); + + if (!err && compat_mode != COMPAT_GNU) + { + char *mode = (compat_mode == COMPAT_BSD42) ? "4.2" : "4.4"; + err = argz_add (argz, argz_len, mode); + if (err) + free (argz); /* Deallocate what diskfs returned. */ + } + + return err; +} + int main (int argc, char **argv) { -- cgit v1.2.3 From c98140b68e9c197e1cd5a9a46a3ed62ed8c49853 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 22 Jun 1996 21:50:14 +0000 Subject: (options): Make const. --- ufs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/main.c b/ufs/main.c index 617796d8..1e7a87bc 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -58,7 +58,7 @@ int diskfs_readonly; /* Ufs-specific options. XXX this should be moved so it can be done at runtime as well as startup. */ -static struct argp_option +static const struct argp_option options[] = { {"compat", 'C', "FMT", 0, -- cgit v1.2.3 From 711fd92fac5695d56728619293a42d528917fa42 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 14:19:34 +0000 Subject: (errexit, punt): Exit with status 8 for catastrophic failures. --- ufs-fsck/utilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 65857ac9..34da1e3d 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -255,7 +255,7 @@ errexit (char *fmt, ...) va_end (args); putchar ('\n'); - exit (1); + exit (8); } static void @@ -271,7 +271,7 @@ punt (char *msg) { problem (0, msg); flush_problems (); - exit (1); + exit (8); } /* If SEVERE is true, and we're in preen mode, then things are too hair to -- cgit v1.2.3 From 6ae06cb4a632dbdf3fae000b1930e4c517ac71a6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 20:59:05 +0000 Subject: (diskfs_shutdown_pager): Don't shutdown DISKPAGER ever, just sync it instead. --- ufs/pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 0da2609e..bea290ab 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -742,7 +742,7 @@ diskfs_shutdown_pager () error_t shutdown_one (void *arg) { struct pager *p = arg; - /* Make sure the disk pager is done last. */ + /* Don't ever shut down the disk pager. */ if (p != disk_pager) pager_shutdown (p); return 0; @@ -751,7 +751,7 @@ diskfs_shutdown_pager () copy_sblock (); write_all_disknodes (); ports_bucket_iterate (pager_bucket, shutdown_one); - pager_shutdown (disk_pager); + sync_disk (1); } /* Sync all the pagers. */ -- cgit v1.2.3 From b3a2a116f9e9199f2138d5add98780d8cf0fb24d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 21:23:42 +0000 Subject: (diskfs_set_hypermetadata): If CLEAN is not set, make sure we clear the clean bit on disk. Always call sync_disk (with appropriate WAIT). (diskfs_readonly_changed): Don't do set_hypermetadata here. (copy_sblock): Don't track clean state here. --- ufs/hyper.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index f198ff43..e4f58249 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -312,11 +312,20 @@ diskfs_set_hypermetadata (int wait, int clean) sblock->fs_clean = 1; sblock_dirty = 1; } + else if (!clean && sblock->fs_clean) + { + /* Clear the clean flag */ + sblock->fs_clean = 0; + sblock_dirty = 1; + wait = 1; /* must be synchronous */ + } spin_unlock (&alloclock); /* Update the superblock if necessary (clean bit was just set). */ copy_sblock (); + + sync_disk (wait); } /* Copy the sblock into the disk */ @@ -359,16 +368,6 @@ copy_sblock () sblock_dirty = 0; } - if (!diskfs_readonly && sblock->fs_clean) - { - /* We just sync'd with the clean flag set, but we are still a - writable filesystem. Clear the flag in core, but don't write the - superblock yet. This should ensure that the flag will be written - as clear as soon as we make any modifications. */ - sblock->fs_clean = 0; - sblock_dirty = 1; - } - spin_unlock (&alloclock); diskfs_end_catch_exception (); @@ -393,11 +392,6 @@ diskfs_readonly_changed (int readonly) strcpy (sblock->fs_fsmnt, "Hurd /"); /* XXX */ - if (sblock->fs_clean) - sblock->fs_clean = 0; - else + if (!sblock->fs_clean) error (0, 0, "WARNING: UNCLEANED FILESYSTEM NOW WRITABLE"); - - sblock_dirty = 1; - diskfs_set_hypermetadata (1, 0); } -- cgit v1.2.3 From 41e7ae8cc4056eb04dd7cd65002b079d3d7d2cb1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 21:24:12 +0000 Subject: (diskfs_truncate): Call diskfs_check_readonly. (diskfs_grow): Likewise. --- ufs/sizes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/sizes.c b/ufs/sizes.c index f98ceb94..39717384 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -49,6 +49,7 @@ diskfs_truncate (struct node *np, if (length >= np->dn_stat.st_size) return 0; + diskfs_check_readonly (); assert (!diskfs_readonly); /* First check to see if this is a kludged symlink; if so @@ -469,6 +470,7 @@ diskfs_grow (struct node *np, if (end <= np->allocsize) return 0; + diskfs_check_readonly (); assert (!diskfs_readonly); /* This reference will ensure that NP->dn->fileinfo stays allocated. */ -- cgit v1.2.3 From 9505b47ffb5ca90b143a09b2602b7adceef1ad59 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 21:24:48 +0000 Subject: (diskfs_cached_lookup): Use diskfs_check_readonly instead of diskfs_readonly. (read_symlink_hook): Likewise. --- ufs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 51af3446..c3eec832 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -86,7 +86,7 @@ diskfs_cached_lookup (int inum, struct node **npp) err = read_disknode (np); - if (!diskfs_readonly && !np->dn_stat.st_gen) + if (!diskfs_check_readonly () && !np->dn_stat.st_gen) { spin_lock (&gennumberlock); if (++nextgennumber < diskfs_mtime->seconds) @@ -415,7 +415,7 @@ read_symlink_hook (struct node *np, bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); - if (! diskfs_readonly) + if (! diskfs_check_readonly ()) np->dn_set_atime = 1; diskfs_end_catch_exception (); -- cgit v1.2.3 From f99f473d18563d7167793f9391e73f9c6d802cc3 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 24 Jun 1996 21:25:22 +0000 Subject: (diskfs_lookup_hard): Use diskfs_check_readonly instead of diskfs_readonly. (diskfs_dirempty): Likewise. --- ufs/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 9abcdbea..d015a6c6 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -153,7 +153,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, inum = 0; - if (!diskfs_readonly) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; for (blockaddr = buf, idx = 0; @@ -170,7 +170,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, } } - if (!diskfs_readonly) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; if (diskfs_synchronous) diskfs_node_update (dp, 1); @@ -705,7 +705,7 @@ diskfs_dirempty(struct node *dp, mach_port_deallocate (mach_task_self (), memobj); assert (!err); - if (!diskfs_readonly) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; for (curoff = buf; @@ -721,14 +721,14 @@ diskfs_dirempty(struct node *dp, && entry->d_name[1] != '\0'))) { vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); - if (!diskfs_readonly) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; if (diskfs_synchronous) diskfs_node_update (dp, 1); return 0; } } - if (!diskfs_readonly) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; if (diskfs_synchronous) diskfs_node_update (dp, 1); -- cgit v1.2.3 From a850cdd2b54a1aeda985ff60ac9c87024d5dce1e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 25 Jun 1996 18:02:37 +0000 Subject: (diskfs_get_options): Include `--compat=' in options. --- ufs/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 1e7a87bc..e62834dc 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -136,8 +136,11 @@ diskfs_get_options (char **argz, unsigned *argz_len) if (!err && compat_mode != COMPAT_GNU) { - char *mode = (compat_mode == COMPAT_BSD42) ? "4.2" : "4.4"; - err = argz_add (argz, argz_len, mode); + err = + argz_add (argz, argz_len, + ((compat_mode == COMPAT_BSD42) + ? "--compat=4.2" + : "--compat=4.4")); if (err) free (argz); /* Deallocate what diskfs returned. */ } -- cgit v1.2.3 From c3f73fde2d3a455a4860282c9437d5703e779af6 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 1 Jul 1996 16:55:43 +0000 Subject: (pass4): If a reconnect fails while we are preening, give up. --- ufs-fsck/pass4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c index 17c0b307..f8fe9814 100644 --- a/ufs-fsck/pass4.c +++ b/ufs-fsck/pass4.c @@ -73,6 +73,8 @@ pass4() reconn_failed = !linkup (number, -1); if (! reconn_failed) pfix ("RECONNECTED"); + if (preen && reconn_failed) + pfail ("RECONNECT FAILED"); } if (dino.di_size == 0 || reconn_failed) { -- cgit v1.2.3 From 630649b06d13ed416c3122c970dd98798a318d6b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 1 Jul 1996 17:39:25 +0000 Subject: (makeentry): After successful directory expansion, write out modified directory inode. --- ufs-fsck/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 1a693c42..d4f05858 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -384,6 +384,7 @@ makeentry (ino_t dir, ino_t ino, char *name) { if (expanddir (&dino)) { + write_inode (ino, &dino); datablocks_iterate (&dino, checkdirblock); pfix ("EXPANDED"); } -- cgit v1.2.3 From 76517cab5502819134c061d53c45e3f8d7d95914 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 1 Jul 1996 19:22:04 +0000 Subject: (pass2): Don't skip empty directories in `.' and `..' correctness check; we don't clear them the way BSD does, so we want `.' and `..' to get created for us. Also handle `.' before `..' so that they get created in the usual order for empty directories. --- ufs-fsck/pass2.c | 64 +++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index ee12d33b..69331946 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -297,75 +297,73 @@ pass2 () for (nd = 0; nd < dirarrayused; nd++) { dnp = dirsorted[nd]; - if (dnp->i_isize == 0) - continue; /* Root is considered to be its own parent even though it isn't listed. */ if (dnp->i_number == ROOTINO && !dnp->i_parent) dnp->i_parent = ROOTINO; - /* Check `..' to make sure it exists and is correct */ - if (dnp->i_parent && dnp->i_dotdot == 0) + /* Check `.' to make sure it exists and is correct */ + if (dnp->i_dot == 0) { - dnp->i_dotdot = dnp->i_parent; - pinode (0, dnp->i_number, "MISSING `..' IN"); + dnp->i_dot = dnp->i_number; + pinode (0, dnp->i_number, "MISSING `.' IN"); if ((preen || reply ("FIX")) - && makeentry (dnp->i_number, dnp->i_parent, "..")) + && makeentry (dnp->i_number, dnp->i_number, ".")) { - linkfound[dnp->i_parent]++; + linkfound[dnp->i_number]++; pfix ("FIXED"); } else pfail (0); } - else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) + else if (dnp->i_dot != dnp->i_number) { - pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `..' IN"); + pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `.' IN"); if (preen || reply ("FIX")) { - ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot; - dnp->i_dotdot = parent; - if (changeino (dnp->i_number, "..", parent)) - /* Adjust what the parent's link count should be; the actual - count will be corrected in an later pass. */ + ino_t old_dot = dnp->i_dot; + dnp->i_dot = dnp->i_number; + if (changeino (dnp->i_number, ".", dnp->i_number)) { - linkfound[parent]++; - if (inodestate[old_dotdot] != UNALLOC) - linkfound[old_dotdot]--; + linkfound[dnp->i_number]++; + if (inodestate[old_dot] != UNALLOC) + linkfound[old_dot]--; pfix ("FIXED"); } else pfail (0); } } - - /* Check `.' to make sure it exists and is correct */ - if (dnp->i_dot == 0) + + /* Check `..' to make sure it exists and is correct */ + if (dnp->i_parent && dnp->i_dotdot == 0) { - dnp->i_dot = dnp->i_number; - pinode (0, dnp->i_number, "MISSING `.' IN"); + dnp->i_dotdot = dnp->i_parent; + pinode (0, dnp->i_number, "MISSING `..' IN"); if ((preen || reply ("FIX")) - && makeentry (dnp->i_number, dnp->i_number, ".")) + && makeentry (dnp->i_number, dnp->i_parent, "..")) { - linkfound[dnp->i_number]++; + linkfound[dnp->i_parent]++; pfix ("FIXED"); } else pfail (0); } - else if (dnp->i_dot != dnp->i_number) + else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent) { - pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `.' IN"); + pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `..' IN"); if (preen || reply ("FIX")) { - ino_t old_dot = dnp->i_dot; - dnp->i_dot = dnp->i_number; - if (changeino (dnp->i_number, ".", dnp->i_number)) + ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot; + dnp->i_dotdot = parent; + if (changeino (dnp->i_number, "..", parent)) + /* Adjust what the parent's link count should be; the actual + count will be corrected in an later pass. */ { - linkfound[dnp->i_number]++; - if (inodestate[old_dot] != UNALLOC) - linkfound[old_dot]--; + linkfound[parent]++; + if (inodestate[old_dotdot] != UNALLOC) + linkfound[old_dotdot]--; pfix ("FIXED"); } else -- cgit v1.2.3 From fbfb38b6e5f7aff900b2303cf0d0c727665a2774 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 3 Jul 1996 17:26:54 +0000 Subject: Include . (startup_parents, runtime_parents): Declare const. --- ufs/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index e62834dc..24a5723d 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -25,6 +25,7 @@ #include #include #include +#include char *ufs_version = "0.0"; @@ -113,11 +114,11 @@ parse_opt (int key, char *arg, struct argp_state *state) } /* Add our startup arguments to the standard diskfs set. */ -static struct argp *startup_parents[] = { &diskfs_std_device_startup_argp, 0}; +static const struct argp *startup_parents[] = { &diskfs_std_device_startup_argp, 0}; static struct argp startup_argp = {options, parse_opt, 0, 0, startup_parents}; /* Similarly at runtime. */ -static struct argp *runtime_parents[] = {&diskfs_std_runtime_argp, 0}; +static const struct argp *runtime_parents[] = {&diskfs_std_runtime_argp, 0}; static struct argp runtime_argp = {options, parse_opt, 0, 0, runtime_parents}; struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; -- cgit v1.2.3 From 8a42898a06d44fcf29899b1341404eb14767cf60 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 6 Jul 1996 16:45:23 +0000 Subject: (diskfs_truncate): Call record_poke after truncating a kludged symlink. --- ufs/sizes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/sizes.c b/ufs/sizes.c index 39717384..a0b090d3 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -63,6 +63,7 @@ diskfs_truncate (struct node *np, if (err) return err; bzero ((char *)di->di_shortlink + length, np->dn_stat.st_size - length); + record_poke (di, sizeof (struct dinode)); diskfs_end_catch_exception (); np->dn_stat.st_size = length; np->dn_set_ctime = np->dn_set_mtime = 1; -- cgit v1.2.3 From 6bf2b7eeb6a41032bf61e482460bd204c225b71c Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 6 Jul 1996 17:28:09 +0000 Subject: (read_disknode): Don't set allocsize based on st->size for kludged symlinks. --- ufs/inode.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index c3eec832..aa2f3a8c 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -270,10 +270,17 @@ read_disknode (struct node *np) if (!S_ISBLK (st->st_mode) && !S_ISCHR (st->st_mode)) st->st_rdev = 0; - if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) - np->allocsize = fragroundup (sblock, np->dn_stat.st_size); + if (S_ISLNK (st->st_mode) + && direct_symlink_extension + && st->st_size < sblock->fs_maxsymlinklen) + np->allocsize = 0; else - np->allocsize = blkroundup (sblock, np->dn_stat.st_size); + { + if (lblkno (sblock, np->dn_stat.st_size) < NDADDR) + np->allocsize = fragroundup (sblock, st->st_size); + else + np->allocsize = blkroundup (sblock, st->st_size); + } return 0; } -- cgit v1.2.3 From aee9ee88393ebb83a6359c9be867ea7285df31a2 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 6 Jul 1996 20:14:25 +0000 Subject: (ufs_version): Variable removed. --- ufs/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 24a5723d..353a1852 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -26,8 +26,6 @@ #include #include #include - -char *ufs_version = "0.0"; struct node *diskfs_root_node; -- cgit v1.2.3 From 3db2c2932951a711a9c44a9fcfbab8215193dd57 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 6 Jul 1996 23:59:58 +0000 Subject: (argp_program_version): New variable. : New include. --- ufs-fsck/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index 50a8142d..b5af2d88 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -20,9 +20,12 @@ #include #include +#include #include "fsck.h" +char *argp_program_version = "fsck.ufs 1.0 (GNU " HURD_RELEASE ")"; + char *lfname = "lost+found"; mode_t lfmode = 0755; -- cgit v1.2.3 From 21941c77d517138670abcf2e33bf66d860f507d1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 7 Jul 1996 01:14:44 +0000 Subject: (argp_program_version): New variable. : New include. --- ufs-utils/mkfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 2fb1248c..37c34ac3 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.11 1996/05/11 05:21:06 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.12 1996/07/07 01:14:44 miles Exp $"; #endif /* not lint */ #include @@ -58,6 +58,8 @@ static char *rcsid = "$Id: mkfs.c,v 1.11 1996/05/11 05:21:06 miles Exp $"; #include #include +#include + /* Begin misc additions for GNU Hurd */ /* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD @@ -161,6 +163,8 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; int fsi, fso; daddr_t alloc(); +char *argp_program_version = "mkfs.ufs 1.0 (GNU " HURD_RELEASE ")"; + #define _STRINGIFY(arg) #arg #define STRINGIFY(arg) _STRINGIFY (arg) -- cgit v1.2.3 From e082c31cb5c7e68d5f898cf9ecadd528cf891e60 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 17 Jul 1996 21:43:13 +0000 Subject: (st): New function. Use new st function (get rid of chmods). Accept disk device names without partitions, & with slice + partition. --- devio/MAKEDEV | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index b113e3c1..1ef7a780 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -5,7 +5,16 @@ PATH=/bin -ST="settrans -cg" +function st { + NODE="$1" + OWNER="$2" + PERM="$3" + shift 3 + settrans -cg "$NODE" + chown "$OWNER" "$NODE" + chmod "$PERM" "$NODE" + settrans "$NODE" "$@" +} _CWD=${_CWD:-`pwd`} export _CWD @@ -16,38 +25,28 @@ for I; do $0 console tty null zero fd time ;; console|tty[0-9]?|tty[0-9a-f]) - $ST $I /hurd/term $_CWD/$I device $I;; + st $I root 666 /hurd/term $_CWD/$I device $I;; null) - $ST $I /hurd/null - chmod 666 $I - ;; + st $I root 666 /hurd/null;; zero) - $ST $I /hurd/null -z - chmod 666 $I - ;; + st $I root 666 /hurd/null -z;; tty) - $ST $I /hurd/magic tty - chmod 666 $I - ;; + st $I root 666 /hurd/magic tty;; fd) - $ST $I /hurd/magic fd - chmod 666 $I + st $I root 666 /hurd/magic fd ln -f -s fd/0 stdin ln -f -s fd/1 stdout ln -f -s fd/2 stderr ;; time) - $ST $I /hurd/devport time - chmod 666 $I - ;; + st $I root 666 /hurd/devport time ;; # ptys [pt]ty[pqPQ]?) # Make one pty, both the master and slave halves ID="`expr substr $I 4 99`" - $ST pty$ID /hurd/term $_CWD/pty$ID pty-master $_CWD/tty$ID - $ST tty$ID /hurd/term $_CWD/tty$ID pty-slave $_CWD/pty$ID - chmod 666 pty$ID tty$ID + st pty$ID root 640 /hurd/term $_CWD/pty$ID pty-master $_CWD/tty$ID + st tty$ID root 640 /hurd/term $_CWD/tty$ID pty-slave $_CWD/pty$ID ;; [pt]ty[pqPQ]) # Make a bunch of ptys @@ -56,18 +55,18 @@ for I; do ;; fd*|mt*) - $ST r$I /hurd/devio $I - $ST $I /hurd/devio -b $I + st r$I root 640 /hurd/devio $I + st $I root 640 /hurd/devio -b $I ;; [hrs]d*) case "$I" in - [a-z][a-z][0-9][a-z] | [a-z][a-z][0-9]s[1-9]) - $ST r$I /hurd/devio $I - $ST $I /hurd/devio -b $I + [a-z][a-z][0-9][a-z] | [a-z][a-z][0-9]s[1-9] | [a-z][a-z][0-9]s[1-9][a-z] | [a-z][a-z][0-9]) + st r$I root 640 /hurd/devio $I + st $I root 640 /hurd/devio -b $I ;; *) - echo 1>&2 $0: $I: Must supply a device number and partition or slice + echo 1>&2 $0: $I: Illegal device name: must supply a device number exit 1 ;; esac -- cgit v1.2.3 From 3a154d3cbff6b7110a67cf8a7dd12356a2a2a289 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 17 Jul 1996 22:55:08 +0000 Subject: Initial revision --- bsdfsck/ChangeLog | 98 ++++ devio/ChangeLog | 253 ++++++++ libmom/ChangeLog | 31 + mkbootfs/ChangeLog | 22 + ufs-fsck/ChangeLog | 245 ++++++++ ufs-utils/ChangeLog | 104 ++++ ufs/ChangeLog | 1586 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 2339 insertions(+) create mode 100644 bsdfsck/ChangeLog create mode 100644 devio/ChangeLog create mode 100644 libmom/ChangeLog create mode 100644 mkbootfs/ChangeLog create mode 100644 ufs-fsck/ChangeLog create mode 100644 ufs-utils/ChangeLog create mode 100644 ufs/ChangeLog diff --git a/bsdfsck/ChangeLog b/bsdfsck/ChangeLog new file mode 100644 index 00000000..0a948518 --- /dev/null +++ b/bsdfsck/ChangeLog @@ -0,0 +1,98 @@ +Thu Jul 6 15:30:43 1995 Michael I Bushnell + + * Makefile (tables.o): Delete target. + (vpath tables.c): Tell where to find tables.c. + + * Makefile: Removed dependencies that are now automatically + generated. + +Thu Nov 3 17:18:35 1994 Michael I Bushnell + + * Makefile (dir): Changed to bsdfsck. + (target): Changed to bsdfsck. + +Thu Oct 6 13:19:25 1994 Michael I Bushnell + + * dir.c (dircheck): Fix from Charles Hannum: dircheck() shouldn't + be looking at d_type or d_namlen in blank entries *at all*. Not + only is it wrong, but it causes a serious problem on little-endian + machines, since after -c2 conversion, d_type will often be > 15. + +Wed Oct 5 12:53:45 1994 Michael I Bushnell + + * pass1.c (checkinode) [mode == 0]: Check that di_trans + is also clear here. + + * fsck.h (IFTODT): Provide macro here. + * inode.c: Not here. + +Tue Oct 4 22:42:54 1994 Michael I Bushnell + + * inode.c (ckinode) [dino.di_trans set]: Only call IDESC->id_func + if IDESC->id_type is ADDR (meaning call function for each block). + If it's DATA, then that means call dirscan on each data block, + something entirely different. + + * inode.c (IFTODT): Provide macro. + +Fri Sep 30 21:28:57 1994 Roland McGrath + + * Makefile (LCLHDRS): Define. + +Fri Sep 16 10:57:04 1994 Michael I Bushnell + + * fsck.h (direct): Define macro. + +Thu Sep 1 14:51:23 1994 Michael I Bushnell + + * inode.c (ckinode): Don't pay attention to fs_maxsymlinklen + if it's -1. + * pass1.c (checkinode): Likewise. + + * fsck.h (DI_MODE): Use | not & for bitwise disjunction. + +Fri Aug 26 12:35:21 1994 Michael I Bushnell + + * main.c (main): Don't call checkblock. + + * pass5.c (ffs_fragacct): Copy in function from ../ufs/subr.c. + + * inode.c (ckinode): Call IDESC->id_func for passive translator + if it's set. + +Thu Aug 25 11:07:05 1994 Michael I Bushnell + + * setup.c: Don't include . + (setup): Comment out variable LP and label fetching code. + (calcsb, getdisklabel): Comment out functions. Replace + calcsb with one returning constant zero. + + * main.c: Don't include or . + (main): Don't run checkfstab; just print an error in that case. + (docheck): Comment out this function. + (checkfilesys): Comment out special code for HOTROOT. + +Wed Aug 24 11:11:23 1994 Michael I Bushnell + + * fsck.h (NBBY): Define macro. + +Tue Aug 23 15:54:49 1994 Michael I Bushnell + + * dir.c (fileerror): Use DI_MODE instead of di_mode member. + (adjust): Likewise. + (linkup): Likewise. + * inode.c (ckinode): Likewise. + (clri): Likewise. + (pinode): Likewise. + * pass1.c (checkinode): Likewise. + * pass2.c (pass2check): Likewise. + * utilities.c (ftypeok): Likewise. + + * inode.c (allocino): Set di_model and di_modeh instead of di_mode. + * pass1.c (checkinode): Likewise. + * pass2.c (pass2): Likewise. + + * fsck.h (DIRSIZ): Replace ufs version with old BSD version. + (struct dirtemplate, struct odirtemplate): Proved old BSD types. + (DEV_BSIZE, MAXPATHLEN): Provide definitions. + (DI_MODE): New macro. diff --git a/devio/ChangeLog b/devio/ChangeLog new file mode 100644 index 00000000..98362b44 --- /dev/null +++ b/devio/ChangeLog @@ -0,0 +1,253 @@ +Wed Jul 17 10:00:04 1996 Miles Bader + + * MAKEDEV (st): New function. + Use new st function (get rid of chmods). + Accept disk device names without partitions, & with slice + partition. + +Sat Jun 15 14:13:24 1996 Michael I. Bushnell, p/BSG + + * MAKEDEV ([hrs]d*): Allow user to specify slice as well. Patch + from Gord Matzigkeit, gord@enci.ucalgary.ca. + +Thu May 9 12:15:47 1996 Miles Bader + + * io.c (trivfs_S_io_select): Remove TAG arg. + (trivfs_S_file_get_storage_info): Fix param type. + +Tue May 7 16:41:48 1996 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): Swap PORTS_TYPE & NUM_PORTS. + +Mon May 6 20:14:43 1996 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): Enable new version. + +Fri May 3 15:09:00 1996 Miles Bader + + * io.c [0] (trivfs_S_file_get_storage_info): Rewrite for new interface. + +Tue Apr 30 10:03:50 1996 Michael I. Bushnell, p/BSG + + * Makefile (include ../Makeconf): BEFORE dependencies. + ($(prefix)/dev/MAKEDEV): Find MAKEDEV in $(srcdir). + +Fri Feb 16 19:28:32 1996 Miles Bader + + * MAKEDEV: Add rule for `time', and add `time' to std. + +Tue Jan 30 12:34:28 1996 Roland McGrath + + * MAKEDEV: Grok `tty'. + +Thu Jan 25 18:10:24 1996 Miles Bader + + * devio.c (trivfs_goaway): Handle errors from ports_inhibit_class_rpcs. + Allow rpcs to resume if we're going to return EBUSY. + +Tue Jan 16 16:19:51 1996 Miles Bader + + * devio.c (trivfs_modify_stat): The peropen hook holds a struct + open, not a struct dev. + +Fri Dec 29 23:41:39 1995 Miles Bader + + * MAKEDEV (std): Make `fd' one of the standard devices. + +Fri Dec 15 13:30:33 1995 Miles Bader + + * MAKEDEV (ST): Variable holding the proper settrans command, + which use. + (_CWD): Use this variable to pass down the current directory to + sub MAKEDEVS. + (console): Use the new term syntax. + (tty[0-9]?|tty[0-9a-f]): New rule for normal ttys. + ([pt]ty[pqPQ]?): New rule for ptys (both master and slave). + ([pt]ty[pqPQ]): New rule for making sets of ptys. + +Mon Dec 4 15:17:14 1995 Miles Bader + + * io.c (trivfs_S_file_set_size, trivfs_S_file_sync, + trivfs_S_file_syncfs, trivfs_S_file_get_storage_info): Add totally + gratuitous, annoying, and trouble-making reply-port args. + + * io.c (trivfs_S_file_get_storage_info): Use inline return if possible. + +Wed Nov 8 16:44:05 1995 Miles Bader + + * io.c (trivfs_S_file_set_size): Renamed from trivfs_S_file_truncate. + +Sun Nov 5 10:00:56 1995 Miles Bader + + * devio.c (main): Add FLAGS arg to trivfs_startup call. + +Sat Nov 4 20:03:05 1995 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): Add FLAGS argument. + +Fri Oct 6 17:25:37 1995 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): Change type of ADDRESSES + to off_t **, and add BLOCK_SIZE parameter. + +Sun Oct 1 16:20:45 1995 Miles Bader + + * devio.c (main, trivfs_S_fsys_syncfs): Get rid of debugging noise. + * rdwr.c (open_write, open_read): Ditto. + * dev.c (dev_open, dev_sync, dev_write, dev_read): Ditto. + * io.c (trivfs_S_file_syncfs, trivfs_S_file_sync): Ditto. + * devpager.c (pager_write_page, pager_read_page): Ditto. + * window.c (position): Ditto. + +Tue Sep 26 15:33:14 1995 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): New function. + * dev.c (dev_open): Record NAME in the returned dev structure. + * dev.h (struct dev): Add the NAME field. + +Thu Aug 24 10:28:00 1995 Miles Bader + + * Makefile (devio): Put all dependencies here. + (HURDLIBS): Removed. + +Tue Aug 22 10:45:31 1995 Miles Bader + + * Makefile (HURDLIBS): Add libshouldbeinlibc. + (OBJS): Get rid of error.o. + Get rid of rules dealing with error.o. + ($(prefix)/dev/MAKEDEV): Use $(INSTALL_PROGRAM) instead of + $(INSTALL_DATA) + `chmod +x'. + + * devio.c (trivfs_modify_stat): Get the device from CRED now that + we have it. + +Mon Aug 21 16:34:29 1995 Miles Bader + + * devio.c (trivfs_goaway, trivfs_modify_stat): Update arguments. + +Tue Aug 15 19:47:57 1995 Roland McGrath + + * MAKEDEV ([hrs]d*): Fixed partition parsing: use glob pattern, + not regexp. + +Sun Aug 13 10:57:03 1995 Miles Bader + + * devio.c (trivfs_peropen_create_hook): This now returns an error_t. + (open_hook): And thus this does as well. + +Sat Jul 22 18:32:03 1995 Miles Bader + + * rdwr.c (open_read, open_write): Clean up STATE before returning + with an error. + * devpager.c (dev_get_memory_object): A new pager now comes with 1 + ref, so we allocate a ref ourselves when we're using an old one, + and once we've created the send right, remove a reference. + +Mon Jul 10 15:15:45 1995 Miles Bader + + * rdwr.c (open_seek): New function. + (raw_read, raw_write): Return EINVAL if *OFFS isn't a block boundary. + * open.h: Add declaration for open_seek. + * io.c (trivfs_S_io_seek): Call open_seek instead of doing ourselves. + +Sat Jul 8 18:35:17 1995 Miles Bader + + * MAKEDEV (fd): Put the fd server on `fd', not `stdin'. + * MAKEDEV (console): Give /hurd/term a ttyname argument. + +Thu Jul 6 15:33:33 1995 Miles Bader + + * Makefile: Remove include dependencies. + +Wed Jun 28 19:22:47 1995 Miles Bader + + * Makefile (HURDLIBS): Add libihash. + + * iostate.c (io_state_sync): Remember that we've synced the buffer. + * devpager.c (dev_stop_paging): New function. + (pager_dropweak): New function. + * dev.h (struct dev): Add the pager_port_bucket field. + Declare dev_stop_paging (). + * devio.c (trivfs_goaway): Make trivfs_goaway do the right thing. + (clean_exit, close_device): Deleted functions. + (thread_cancel): New function. + + * devpager.c (pager_port_type): Deleted var. + (pager_port_bucket, pager_port_class): New vars. + (dev_get_memory_object): Moved here from dev.c. Also, call + init_dev_pager if necessary. + (service_paging_requests): New function. + (init_dev_pager): New function. + * dev.c (dev_get_memory_object): Moved function to devpager.c. + + * devio.c (fsys_port_class, root_port_class, port_bucket): New vars. + (trivfs_protid_portclasses, trivfs_cntl_portclasses, + trivfs_protid_nportclasses, trivfs_cntl_nportclasses): New vars. + (main): Initialize *portclasses vars, and convert to new trivfs lib. + (trivfs_protid_porttypes, trivfs_cntl_porttypes, + trivfs_protid_nporttypes, trivfs_cntl_nporttypes): Deleted vars. + (trivfs_goaway): Convert args for new trivfs lib. + (ports_cleanroutines): Delete var. + (ports_demuxer, ports_notice_idle, ports_no_live_ports, + ports_no_hard_ports): Delete functions. + * ptypes.h: Deleted file. + +Wed Jun 28 15:51:51 1995 Michael I Bushnell + + * Makefile: Repair mangled include-file dependencies. + +Fri Apr 21 14:17:19 1995 Roland McGrath + + * MAKEDEV: Split out `std' into individual device-makers it calls. + Rewrote /dev/fd stuff (still commented out). Use case built-in + instead of expr program. + +Tue Apr 11 15:46:35 1995 Michael I Bushnell + + * Makefile (DIST_FILES): New var, for MAKEDEV. + (install): Depend on $(prefix)/dev/MAKEDEV. + ($(prefix)/dev/MAKEDEV): New target. + * MAKEDEV: New file. + +Mon Apr 10 10:22:26 1995 Miles Bader + + * rdwr.c (open_write, open_read): Bounds check I/O. + + * io.c (trivfs_S_file_truncate): Always return 0, so O_TRUNC works. + + * devio.c (main, check_open_hook, close_device, trivfs_goaway): + Add a new lock, device_lock, and use it to control access to the + DEVICE variable. + (open_hook, trivfs_modify_stat, trivfs_S_fys_syncfs): Copy DEVICE + before using it, so it doesn't change underneath us. + + * devio.c (clean_exit): Add a new argument that says whether to + aquire a lock before doing our work. + (ports_notice_idle, ports_no_live_ports): Use it. + + * devio.c (close_device): New function, closes DEVICE cleanly. + (clean_exit, ports_no_hard_ports): Use close_device. + + * devio.c (main): Use trivfs_startup instead of doing it manually. + + * devio.c (trivfs_goaway): Try and do it better, paying attention + to flags, etc.; this still isn't right though, we may want to wait + for the ports library to be fixed first. + + * devio.c (DEBUG): New macro, executes its arg with debug_lock locked. + (most everything): use DEBUG instead of doing things manually. + + * open.c (open_create): Supply our dev's size when creating a window. + +Sun Apr 9 14:49:33 1995 Miles Bader + + * window.h: Add a new window field, max_pos. Rename the location + field `pos'. + * window.c (position): Use a shorter than normal window if + necessary to avoid going past the end of the device. + (window_create): Initialize the new MAX_POS field. + (window_create, position, window_write, window_read): Rename the + location field `pos'. + + * devpager.c (pager_read_page, pager_write_page): Read or write + partial pages at the end of the device. + diff --git a/libmom/ChangeLog b/libmom/ChangeLog new file mode 100644 index 00000000..f04006c5 --- /dev/null +++ b/libmom/ChangeLog @@ -0,0 +1,31 @@ +Sat May 25 17:25:09 1996 Michael I. Bushnell, p/BSG + + * refs-identical.c (mom_ports_identical): Omit uses of deleted + members of struct mom_port_ref.c. + + * ref-destroy.c (mom_ref_destroy): Omit uses of deleted members of + struct mom_port_ref.c. + + * mach-port-set.c (mom_mach_port_set): Omit uses of deleted + members of struct mom_port_ref.c. + + * fetch-mach-port.c (mom_fetch_mach_port): Omit uses of deleted + members of struct mom_port_ref.c. + + * copy-ref.c (mom_copy_ref): Likewise. + + * mom-kerndep.h (struct mom_port_ref): Delete members `lock' and + `refcnt'. + * Makefile (SRCS): Delete add-ref.c and drop-ref.c. + * mom.h (mom_add_ref, mom_drop_ref): Delete functions. + * add-ref.c, drop-ref.c: Delete files. + +Fri May 24 16:14:54 1996 Michael I. Bushnell, p/BSG + + * mom.h: Include . + * error-trans.c: New file. + * mom-kerndep.h (mom_error_translate_mach): New function. + * Makefile (LCLHDRS, installhdrs): Add mom-errors.h. + (SRCS): Add error-trans.c. + * mom-errors.h: New file. + diff --git a/mkbootfs/ChangeLog b/mkbootfs/ChangeLog new file mode 100644 index 00000000..787943a2 --- /dev/null +++ b/mkbootfs/ChangeLog @@ -0,0 +1,22 @@ +Fri Jul 22 10:38:17 1994 Michael I Bushnell + + * Makefile: Rewritten in accord with new scheme. + +Wed Jul 20 16:24:08 1994 Michael I Bushnell + + * Makefile (mkbootfs): Put -n after hostname for compat with + old broken rsh. + Use gcc literally instead of MIGHOSTCC. + +Tue Jul 5 14:22:00 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (SRCS): New variable. + +Fri May 6 13:25:47 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * Makefile (mkbootfs): Use MIGHOSTCC instead of CC. + +Thu May 5 19:06:21 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * Makefile (mkbootfs): Call rsh with -n flag. + diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog new file mode 100644 index 00000000..1ea09c4a --- /dev/null +++ b/ufs-fsck/ChangeLog @@ -0,0 +1,245 @@ +Sat Jul 6 19:59:27 1996 Miles Bader + + * main.c (argp_program_version): New variable. + : New include. + +Mon Jul 1 12:55:48 1996 Michael I. Bushnell, p/BSG + + * pass2.c (pass2): Don't skip empty directories in `.' and `..' + correctness check; we don't clear them the way BSD does, so we + want `.' and `..' to get created for us. Also handle `.' before + `..' so that they get created in the usual order for empty + directories. + + * dir.c (makeentry): After successful directory expansion, write + out modified directory inode. + + * pass4.c (pass4): If a reconnect fails while we are preening, + give up. + +Mon Jun 24 10:19:39 1996 Michael I. Bushnell, p/BSG + + * utilities.c (errexit, punt): Exit with status 8 for catastrophic + failures. + +Thu May 23 14:12:21 1996 Michael I. Bushnell, p/BSG + + * pass2.c (pass2): Don't clear all node types in directories, just + clear those that are wrong. + +Tue May 14 16:49:46 1996 Miles Bader + + * pass2.c (pass2): Fix up test in preen case. + +Tue May 14 15:29:36 1996 Michael I. Bushnell, p/BSG + + * pass2.c (pass2): Handle directory entry type fields better for + Hurd. + +Sat May 11 01:07:49 1996 Miles Bader + + * main.c (parse_opt): Use ARGP_ERR_UNKNOWN instead of EINVAL. + +Thu May 9 20:12:51 1996 Michael I. Bushnell, p/BSG + + * pass1b.c (pass1b): Bother to initialize NUMBER. + +Fri May 3 00:48:39 1996 Miles Bader + + * main.c (nice_size, show_stats): New functions. + (main): Use show_stats. + +Wed May 1 13:59:06 1996 Miles Bader + + * main.c (main): Shorten summary message so that it fits on one line. + * utilities.c (no_preen): New function. + (problem, warning, pinode): Use it. + (warning): Don't flush all pending problems, just our own. + * dir.c (linkup): Consistently put quotes around filenames. + + * main.c (preen, num_files): New variables. + (main): Implement clean-bit checking in preen mode, and print + summary statistics. + (main, options): Add --force & --silent options. + * pass1.c (pass1): Increment NUM_FILES. + When clearing inode due to bad blocks, continue. + * inode.c (allocino, freeino): Frob NUM_FILES. + * fsck.h (force): New declaration. + * pass5.c (pass5): Vary clean msg depending on whether FSMODIFIED. + * setup.c (setup): Use error to print error msgs. + , : New includes. + + * utilities.c (problem, warning, pextend, pfail): New functions. + (pinode, pfix, reply): Use new problem recording stuff. + (push_problem, resolve_problem, flush_problems): New functions. + (struct problem): New type. + (problems, free_problems): New variables. + (retch, punt): New functions. + * fsck.h (problem, warning, pextend, pfail): New declarations. + (pinode): Update declaration. + * dir.c (validdir, makeentry, linkup): Use new printing functions. + * pass1.c (pass1): Likewise. + * pass1b.c (pass1b): Likewise. + * pass2.c (pass2): Likewise. + * pass3.c (pass3): Likewise. + * pass4.c (pass4): Likewise. + * pass5.c (pass5): Likewise. + * setup.c (setup): Likewise. + +Tue Apr 30 19:06:42 1996 Miles Bader + + * pass5.c (pass5): Be sure to call pwarn before pfix. + * main.c (main): Don't print large obnoxious banner if PREEN. + +Fri Apr 26 16:20:37 1996 Michael I. Bushnell, p/BSG + + * inode.c (allocino): Parenthesize test correctly. + + * fsck.h (swab_disk): Define as constant zero. + + * pass5.c (pass5): If not marked clean, but now it is, then offer + to mark it clean. + * utilities.c (reply): Set fix_denied anytime we return 0. + * fsck.h (fix_denied): New variable. + +Wed Apr 24 13:32:39 1996 Michael I. Bushnell, p/BSG + + * pass1.c (pass1): Don't print block numbers as we go anymore. + +Tue Apr 23 10:11:49 1996 Michael I. Bushnell, p/BSG + + * pass5.c (pass5): Correctly track contig summaries even though + they aren't used by the filesystem; we still need to preserve the + format. + +Mon Apr 15 12:51:41 1996 Michael I. Bushnell, p/BSG + + * Makefile (vpath tables.c): Find ufs directory in $(top_srcdir). + +Tue Apr 2 09:00:53 1996 Michael I. Bushnell, p/BSG + + * pass1.c (pass1): Print mode correctly in unknown file type case. + Recognize inode type IFSOCK too. + +Mon Mar 18 19:48:39 1996 Miles Bader + + * main.c (main): Pass new arg to argp_parse. Use argp_usage correctly. + +Thu Oct 19 17:45:12 1995 Miles Bader + + * main.c (main): Exit with a non-zero status if we fixed anything. + Use argp to parse options. + (options): Converted to argp format. + (args_doc): New variable. + (USAGE, usage, SHORT_OPTIONS): Removed. + Include instead of . + * Makefile ($(target)): Depend on libshouldbeinlibc.a. + +Fri Sep 22 16:55:03 1995 Miles Bader + + * utilities.c (pfix): New function. + (pfatal, pwarn, errexit): Print DEVICE_NAME too if in preen mode. + * fsck.h: Declare DEVICE_NAME. + * setup.c (setup): Set DEVICE_NAME. + * pass1.c, pass2.c, pass3.c, pass4.c, pass5.c (pass1, pass2, + pass3, pass4, pass5): Call pfix instead of printf. + * pass1.c (pass1): Only print progress report if not in preen mode. + * main.c (main): Only print section headers if not in preen mode. + +Wed Sep 20 09:11:59 1995 Miles Bader + + * utilities.c (pinode): Take a message & args to print as well. + * fsck.h: Change declaration of pinode. + * pass2.c (pass2): Use changed pinode. + * pass3.c (pass3): Use changed pinode. + * pass4.c (pass4): Use changed pinode. + +Tue Sep 19 15:37:02 1995 Miles Bader + + * pass1.c (pass1): Change the extent of DBWARN & IBWARN so that + they actually work. + * pass2.c (pass2): Adjust our record of link counts when we + add/change dir entries; also print error messages when we can't. + * pass4.c (pass4): If an unlinked file can't be reconnected, offer + to clear it. Once a reconnect attempt fails, don't try again. + * dir.c (linkup): Print the value of LFNAME rather than `lost+found'. + (searchdir, changeino): Fix backward compare. + (linkup): Don't fail when makeentry succeeds. + (searchdir): Make searchdir return zero if there's an error + during the search. + (linkup): Print appropiate error messages if searchdir fails. + (validdir): Get rid of extra newlines in error messages -- + everyone who calls this routine prints extra information if it + fails, which should immediately follow. + * main.c (main): Use getopt to parse command line options. + (usage): New function. + (options): New variable. + (lfname, lfmode): Variables moved here from setup.c. + (lfname): Made into a char* so that we can change it. + (lfmode): Get rid of IFDIR; it's added when necessary. + * fsck.h: Change LFNAME to char*. + * setup.c (lfname, lfmode): Variables moved to main.c. + +Sat Sep 9 12:12:59 1995 Miles Bader + + * Makefile (target): Changed to `fsck.ufs'. + (installationdir): New variable, install into $(sbindir). + +Thu Jul 6 15:33:46 1995 Michael I Bushnell + + * fsck.h (lookup_directory): New decl. + + * pass1.c (pass1): Remove assignment from if test. + * utilities.c (pinode): Likewise. + + * Makefile (tables.o): Delete rule. + (vpath tables.c): Tell where to find tables.c. + + * Makefile: Removed dependencies that are now automatically + generated. + +Thu Nov 3 17:19:03 1994 Michael I Bushnell + + * Makefile (dir): Changed to fsck. + (target): Changed to fsck. + +Wed Nov 2 14:39:13 1994 Michael I Bushnell + + * pass2.c (pass2): Use DIRECT_NAMLEN instead of d_namlen + throughout. + * dir.c (searchdir): Likewise. + (changeino): Likewise. + (makeentry): Likewise. + +Mon Oct 17 16:07:56 1994 Michael I Bushnell + + * inode.c (inode_iterate): FN takes new third arg. + Keep track of new var `offset' and pass it to FN. + * pass2.c (pass2/checkdirblock): New third arg. + Only scan DIRBLKSIZ chunks to the total size of the file. + * dir.c (searchdir/checkdirblock): Likewise. + (changeino/checkdirblock): Likewise. + (makeentry/checkdirblock): Likewise. + * pass1.c (pass1/checkblock): New third arg (ignored). + * pass1b.c (pass1b/checkblock): Likewise. + + * inode.c (inode_iterate): Compute MAXB correctly. + + * utilities.c (getinode): Multiple ino_to_fsbo by + sizeof (struct dinode). + (write_inode): Likewise. + (getinode): Inode buffer needs to be a full block, not a + fragment. + +Fri Oct 14 21:07:09 1994 Michael I Bushnell + + * utilities.c (lastifrag): New variable. + (getinode): Use lastifrag instead of buf; Only I/O new block + if lastifrag isn't what we want. + (write_inode): Likewise. + +Fri Oct 14 17:44:59 1994 Michael I Bushnell + + * setup.c (setup): Test ISCHR, not ISDIR. + Fix NCYL against NCG * CPG test. + Bother to set MAXFSBLOCK, MAXINO, and DIRECT_SYMLINK_EXTENSION. diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog new file mode 100644 index 00000000..d6d58f5d --- /dev/null +++ b/ufs-utils/ChangeLog @@ -0,0 +1,104 @@ +Fri Jun 21 02:12:16 1996 Miles Bader + + * dlabel.c (fd_get_device): Supply new args to store_create. + +Sat May 11 01:20:18 1996 Miles Bader + + * mkfs.c (parse_opt): Use ARGP_ERR_UNKNOWN instead of EINVAL. + +Fri May 10 15:50:38 1996 Miles Bader + + * dlabel.c (fd_get_device): Update to use libstore. + : New include. + * Makefile (mkfs.ufs): Depend on ../libstore/libstore.a. + +Tue Apr 30 10:06:21 1996 Michael I. Bushnell, p/BSG + + * Makefile (include ../Makeconf): BEFORE dependencies. + (all): Delete target. + ($(targets)): Each target depends on its associated .o. + +Wed Apr 3 16:31:13 1996 Miles Bader + + * mkfs.c (main): In `Can't get disklabel' error message, specify + which flag the user can use to supply the needed information. + (mkfs): Fiddle with info message. + +Sun Mar 31 14:34:28 1996 Miles Bader + + * stati.c (mode_rep): Prefix octal number with `0'. + +Fri Mar 29 11:56:52 1996 Miles Bader + + * stati.c (main): Print mode & {in,}direct blocks too. + (mode_rep): New function. + (timespec_rep): P shouldn't be static. + + * mkfs.c (main): Argp interface changes. + +Wed Mar 13 18:30:55 1996 Miles Bader + + * mkfs.c (options, args_doc, doc): New variables for option parsing. + (struct amark): New type. + (amarks_add, amarks_contains): New functions. + (default_disklabel): New variable. + (main): Most arguments are now options (and optional). Allow many + more parameters to be specified. Consult the disk label for some + defaults. + (most functions): Add explicit return type declarations. Fix + printf format specifications. Get rid of #ifdefs for MFS. + (started, malloc, realloc, calloc, free): Functions removed. + (mfs, membase): Variables removed. + , , , , , + : New includes + * dlabel.c: New file. + * Makefile (SRCS): Add dlabel.c. + (mkfs.ufs): New target. + +Tue Feb 27 14:52:00 1996 Miles Bader + + * clri.c: Move here from ../utils. + + [Entire directory renamed to `ufs-utils' from `newfs'] + +Sat Sep 9 12:17:11 1995 Miles Bader + + * Makefile (target): Changed to `mkfs.ufs'. + (installationdir): New variable, install into $(sbindir). + +Thu Nov 24 18:39:30 1994 Roland McGrath + + * mkfs.c: Protect all mfs code with #ifdef MFS. + +Wed Oct 12 12:59:01 1994 Michael I Bushnell + + * mkfs.c (main): MAXCONTIG should be zero because we don't + do clustering. + +Fri Sep 9 09:45:23 1994 Michael I Bushnell + + * mkfs.c: Include and . + (main): New function. Punt newfs.c for now. + * Makefile (SRCS, OBJS): Comment out uses of newfs.c. + (target): Build mkfs, not newfs. + + * newfs.c (mopts): Comment out. + (mntflags): Comment out. + (main): Omit check for `mfs'. Omit var `partition'. + (main) [case 'o']: Comment out mfs specific code. + (main): Comment out check for already-mounted partition. + (main): Comment out MFS specific open of FSI. + + * mkfs.c (fsinit): Use DI_MODE to read mode from NODE, and + set di_model and di_modeh instead of di_mode. + (mkfs): Don't set fields in *PP. + + * newfs.c: Include ufs header files with "../ufs/foo.h" instead of + . Don't include , , + or "mntopts.h". + +Thu Sep 8 15:52:05 1994 Michael I Bushnell + + * mkfs.c: Include ufs header files with "../ufs/foo.h" instead of + . Don't include . + diff --git a/ufs/ChangeLog b/ufs/ChangeLog new file mode 100644 index 00000000..368a2f59 --- /dev/null +++ b/ufs/ChangeLog @@ -0,0 +1,1586 @@ +Sat Jul 6 16:14:10 1996 Miles Bader + + * main.c (ufs_version): Variable removed. + +Sat Jul 6 12:45:36 1996 Michael I. Bushnell, p/BSG + + * inode.c (read_disknode): Don't set allocsize based on st->size + for kludged symlinks. + + * sizes.c (diskfs_truncate): Call record_poke after truncating a + kludged symlink. + +Wed Jul 3 13:27:04 1996 Michael I. Bushnell, p/BSG + + * main.c: Include . + (startup_parents, runtime_parents): Declare const. + +Tue Jun 25 14:02:02 1996 Miles Bader + + * main.c (diskfs_get_options): Include `--compat=' in options. + +Mon Jun 24 16:59:12 1996 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_lookup_hard): Use diskfs_check_readonly instead of + diskfs_readonly. + (diskfs_dirempty): Likewise. + + * dir.c (diskfs_lookup_hard): Use diskfs_check_readonly instead of + diskfs_readonly. + (diskfs_dirempty): Likewise. + * inode.c (diskfs_cached_lookup): Likewise. + (read_symlink_hook): Likewise. + * sizes.c (diskfs_truncate): Call diskfs_check_readonly. + (diskfs_grow): Likewise. + * hyper.c (diskfs_set_hypermetadata): If CLEAN is not set, make + sure we clear the clean bit on disk. Always call sync_disk (with + appropriate WAIT). + (diskfs_readonly_changed): Don't do set_hypermetadata here. + (copy_sblock): Don't track clean state here. + + * pager.c (diskfs_shutdown_pager): Don't shutdown DISKPAGER ever, + just sync it instead. + +Sat Jun 22 17:45:34 1996 Miles Bader + + * main.c (diskfs_get_options): New function. + (options): Make const. + +Fri Jun 21 01:32:09 1996 Miles Bader + + * main.c (parse_opt): Handle runtime invalid selection of 4.2 mode. + Save select mode until we're done to correctly deal with external + errors at runtime. + (startup_parents, startup_argp, runtime_parents, runtime_argp): + New variables. + (main): Argp vars made global. + (argp_parents): diskfs_device_startup_argp --> + &diskfs_std_device_startup_argp. + +Sat Jun 15 13:57:27 1996 Miles Bader + + * main.c (options): New variable. + (parse_opt): New function. + (main): Parse ufs-specific options too. + : New include. + +Fri May 10 09:29:03 1996 Michael I. Bushnell, p/BSG + + * inode.c (diskfs_set_statfs): Fix one reference to old name of ST + member. + +Thu May 9 11:54:13 1996 Michael I. Bushnell, p/BSG + + * Makefile (ufs.static ufs): s/ioserver/iohelp/g + * ufs.h: ioserver.h -> iohelp.h. + + * inode.c (diskfs_set_statfs): Use and fill in new statfs + structure. + +Mon May 6 14:23:54 1996 Michael I. Bushnell, p/BSG + + * main.c (ufs_version): Upgrade to 0.0. + +Fri May 3 09:15:33 1996 Michael I. Bushnell, p/BSG + + * sizes.c (block_extended): Rewrite code that moves pages + to be more efficient, and not deadlock too, using unlocked + pagein permission feature (read "hack"). Return value + now indicates whether we expect a sync. + (diskfs_grow): If a call to block_extended returns nonzero, + then sync the file before returning. + * pager.c (diskfs_get_filemap): Initialize + UPI->allow_unlocked_pagein and UPI->unlocked_pagein_length. + (unlocked_pagein_lock): New variable. + (find_address): New parameter `isread'; all callers changed. + If ISREAD and we are in the unlocked pagein region, don't + attempt to acquire NP->dn->allocptrlock. + * ufs.h (struct user_pager_info): New members + `allow_unlocked_pagein' and `unlocked_pagein_length'. + (unlocked_pagein_lock): New variable. + +Thu May 2 10:56:10 1996 Michael I. Bushnell, p/BSG + + * sizes.c (offer_data): Offer pages at ADDR each time through the + loop, not the same page over and over. + (block_extended): When moving data, sync in-core pager both before + reading from disk and after providing data to kernel. + (diskfs_grow): Always call block_extended or offer_data before + adjusting block pointer. + +Tue Apr 30 13:38:42 1996 Michael I. Bushnell, p/BSG + + * sizes.c (diskfs_grow): In last offer_data, don't offer a block + number as an address. + +Fri Apr 26 15:35:53 1996 Michael I. Bushnell, p/BSG + + * Makefile (makemode): Now `servers'. + (targets): Renamed from `target'; now include ufs.static. + (ufs.static-LDFLAGS): Renamed from `LDFLAGS'. + (ufs.static): Depend on same things as `ufs'. + (include ../Makeconf): Must come before dependency information. + +Wed Apr 24 14:05:48 1996 Michael I. Bushnell, p/BSG + + * dir.h (DIRECT_NAMLEN) [! LITTLE_ENDIAN]: Deal correctly with the + case where it was written on a little endian machine without the + extension. + (DIRECT_NAMLEN) [LITTLE_ENDIAN]: Deal with case correctly where it + was written without the extension on a big endian machine. + * dir.c (dirscanblock): Use read/write_disk_entry when reading or + writing fields from directory entries. + (diskfs_direnter_hard): Likewise. + (diskfs_dirremove_hard): Likewise. + (diskfs_dirrewrite_hard): Likewise. + (diskfs_get_directs): Likewise. + (diskfs_dirempty): Likewise. + (count_dirents): Likewise. + +Tue Apr 23 11:28:42 1996 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_dirempty): node_update -> diskfs_node_update. + + * hyper.c (swab_sblock, swab_csums): New functions. + (get_hypermetadata): If this is a swapped filesystem, set swab_disk. + Also swap csum and sblock after reading them. + (diskfs_set_hypermetadata): If swab_disk, swap the csums back before + writing them. + (copy_sblock): If swab_disk, swap the sblock before writing it. + * ufs.h (swab_disk): New variable. + (swab_short, swab_long, swab_long_long): New functions. + (read_disk_entry, write_disk_entry): New macros. + * alloc.c (ffs_realloccg): Use read/write_disk_entry when + reading/writing on-disk inode fields. + * bmap.c (fetch_indir_spec): Likewise. + * inode.c (read_disknode): Likewise. + (write_node): Likewise. + (diskfs_set_translator): Likewise. + (diskfs_get_translator): Likewise. + (diskfs_S_file_get_storage_info): Likewise. + * sizes.c (diskfs_truncate): Likewise. + (diskfs_grow): Likewise. + * pager.c (pager_unlock_page): Likewise. + * bmap.c (fetch_indir_spec): Use read/write_disk_entry when + reading/writing on-disk indirect blocks. + * sizes.c (diskfs_truncate): Likewise. + (indir_release): Likewise. + (diskfs_grow): Likewise. + * pager.c (pager_unlock_page): Likewise. + * alloc.c: Include + (ffs_blkpref): Use read_disk_entry when reading from BAP array. + (swab_cg, read_cg, release_cg): New functions. + (ffs_fragextend, ffs_alloccg, ffs_nodealloccg, ffs_blkfree, + diskfs_free_node): Use new cg access functions. + +Thu Apr 18 14:50:30 1996 Michael I. Bushnell, p/BSG + + * sizes.c (diskfs_grow): New variable `pagerpt'. + (offer_zeroes, block_extended): New functions. + (diskfs_grow): In initializing newly allocated data disk blocks with + zeroes, use less aggressive offer_zeroes instead of immediate + synchronous writes. After ffs_realloccg succeeds, use + block_extended to handle the magic. Get rid of old poke calls. + * alloc.c (ffs_realloccg): If we are allocating a new block, don't + actually free the old one here. + * sizes.c (diskfs_grow): New variable `pagerpt'. + (offer_zeroes, block_extended): New functions. + (diskfs_grow): In initializing newly allocated data disk blocks + with zeroes, use less aggressive offer_zeroes instead of immediate + synchronous writes. After ffs_realloccg succeeds, use + block_extended to handle the magic. Get rid of old poke calls. + +Tue Apr 16 15:20:07 1996 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_lookup_hard): Set atime appropriately, and sync + the new atime if we are running synchronously (!). + (diskfs_dirempty): Likewise. + (diskfs_direnter_hard): Set mtime appropriately. + (diskfs_dirremove_hard): Likewise. + (diskfs_dirrewrite_hard): Likewise. + + * inode.c (diskfs_write_disknode): Only do sync if WAIT is set. + +Thu Apr 4 16:39:22 1996 Miles Bader + + * inode.c (diskfs_cached_lookup): Intialize NP->cache_id *after* + NP exists. + +Wed Apr 3 16:03:51 1996 Michael I. Bushnell, p/BSG + + * inode.c (diskfs_cached_lookup): Renamed from `iget'. All + callers changed. Initialize NP->cache_id. + +Fri Mar 29 16:52:31 1996 Michael I. Bushnell, p/BSG + + * sizes.c (diskfs_truncate): Cast DI->di_shortlink to correct type + before adding a character count to it. + +Mon Mar 25 13:08:10 1996 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_null_dirstat): New function. + +Fri Mar 22 23:43:53 1996 Miles Bader + + * inode.c (read_symlink_hook): Only set NP's atime if !readonly. + +Wed Mar 20 14:36:31 1996 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_lookup_hard): Don't do initial or final permission + checking here. + * dir.c (diskfs_dirrewrite_hard): Renamed from diskfs_dirrewrite. + No longer call modification tracking routines. + (diskfs_dirremove_hard): Renamed from diskfs_dirremove. No longer call + modification tracking routines. + (diskfs_direnter_hard): Renamed from diskfs_direnter. No longer call + modification tracking routines. + (diskfs_lookup_hard): Renamed from diskfs_lookup. + +Mon Mar 18 19:50:41 1996 Miles Bader + + * main.c (main): Pass new arg to argp_parse. + +Mon Mar 18 12:33:06 1996 Michael I. Bushnell, p/BSG + + * pager.c (diskfs_max_user_pager_prot) [add_pager_max_prot]: + (a == b) ? 1 : 0 ====> (a == b). + +Fri Feb 23 15:27:05 1996 Roland McGrath + + * hyper.c (get_hypermetadata): Use diskfs_device_arg in unclean msgs. + +Wed Feb 21 05:57:12 1996 Roland McGrath + + * hyper.c: Implement proper handling of the filesystem `clean bit'. + (ufs_clean): New variable. + (get_hypermetadata): Set it from the fs_clean flag. If not clean, + complain and force read-only. Complain when ignoring COMPAT_BSD42. + (diskfs_set_hypermetadata): Set the clean flag in the superblock + when CLEAN and fs was clean to start with. + (copy_sblock): Remove bogus clean flag frobnication. + +Fri Feb 16 17:05:36 1996 Miles Bader + + * main.c (main): Check error return from diskfs_init_diskfs. + +Sat Jan 6 11:50:14 1996 Roland McGrath + + * ufs.h (diskpager, diskpagerport, disk_image): Variables removed. + Include instead. + (sync_disk_blocks): Use `disk_pager' in place of `diskpager->p'. + * pager.c (diskfs_shutdown_pager, diskfs_sync_everything): Use + `disk_pager' in place of `diskpager->p'. + (create_disk_pager): Rewritten using disk_pager_setup. + * pokeloc.c (sync_disk): Use `disk_pager' in place of `diskpager->p'. + * sizes.c (indir_release): Likewise. + * main.c (diskfs_reload_global_state): Likewise. + +Thu Jan 4 19:10:11 1996 Roland McGrath + + * main.c (main): Don't map disk image here; create_disk_pager now + does it. + + * hyper.c (get_hypermetadata, copy_sblock): Don't put + diskfs_catch_exception () inside assert, bonehead! Use + assert_perror on a variable of its result. + +Mon Jan 1 16:38:14 1996 Michael I. Bushnell, p/BSG + + * pager.c (pager_unlock_page): When allocating block in direct + array, clear it synchronously just like we do when it goes in the + indirect array. + +Thu Nov 9 14:01:30 1995 Michael I. Bushnell, p/BSG + + * dir.c (struct dirstat): New member `nbytes'. + (dirscanblock): If DS->type is COMPRESS, still look + for TAKE/SHRINK possibilities. Also, if it's COMPRESS, + still look to see if the current block can be compressed + with fewer byte copies. + +Sun Nov 5 02:08:38 1995 Miles Bader + + * main.c (main): Add flags arg to diskfs_startup_diskfs call. + +Sat Nov 4 20:01:58 1995 Miles Bader + + * inode.c (diskfs_S_file_get_storage_info): Add FLAGS argument. + +Thu Oct 19 12:50:11 1995 Miles Bader + + * pager.c (diskfs_max_user_pager_prot): Return what we discovered, + instead of 1. + + * dir.c (diskfs_lookup, diskfs_dirempty): Give diskfs_get_filemap + a protection arg. + * sizes.c (diskfs_truncate, diskfs_grow): Ditto. + + * hyper.c (diskfs_readonly_changed): Give the 2nd arg to + vm_protect an appropiate type. + + * pager.c (diskfs_max_user_pager_prot): Stop iterating early if poss. + +Wed Oct 18 16:28:42 1995 Miles Bader + + * ufs.h (struct user_pager_info): Add max_prot field. + * pager.c (diskfs_get_filemap): Add PROT parameter, & use it. + (diskfs_pager_users): Split out block_caching & enable_caching. + (block_caching, enable_caching): New function. + (diskfs_max_user_pager_prot): New function. + + * main.c (main): Always include VM_PROT_WRITE in max prot. + * hyper.c (diskfs_readonly_changed): Change the protection of + DISK_IMAGE to reflect the new state. Clear SBLOCK_DIRTY if readonly. + + * inode.c (read_disknode): Bother to set the allocsize field. + + * ufs.h (struct rwlock): Structure deleted. + (rwlock_init, rwlock_reader_unlock, rwlock_reader_lock, + rwlock_writer_lock, rwlock_writer_unlock): Functions deleted. + + +Tue Oct 17 14:49:43 1995 Miles Bader + + * inode.c (diskfs_node_reload): New function. + (iget): Move allocsize setting into read_disknode. + * pager.c (flush_node_pager): New function. + * ufs.h (zeroblock, sblock, csum): Declare extern. + (flush_node_pager, flush_pokes): New declarations. + * pokeloc.c (flush_pokes): New function. + * hyper.c (diskfs_readonly_changed): New function. + (get_hypermetadata): Move compat_mode futzing & disk size + validation here from main. + (zeroblock, sblock, csum): Define (were common). + (get_hypermetadata): Only allocate SBLOCK if not already done. + Deallocate any old ZEROBLOCK and CSUM storage. + (diskfs_readonly_changed): New function. + * main.c (main): Move stuff into get_hypermetadata. + Writable init code moved to diskfs_readonly_changed. + (diskfs_reload_global_state): New function. + +Fri Oct 13 15:03:37 1995 Miles Bader + + * main.c (main): Use new handy diskfs routines and get rid of + tons of junk. Main should be almost all ufs-specific now. + (USAGE, usage, SHORT_OPTS, long_opts, parse_opt, trans_parse_arg): RIP. + (printf_lock): Initialize. + +Thu Oct 12 18:48:04 1995 Miles Bader + + * pager.c (pager_unlock_page, pager_write_page, pager_read_page): + Use diskfs_device_{read,write}_sync instead of dev_{read,write}_sync. + * hyper.c (diskfs_set_hypermetadata): Ditto. + * sizes.c (diskfs_grow): Ditto. + * pager.c (pager_report_extent): Calculate the pager size. + * ufs.h (dev_read_sync, dev_write_sync, dev_write, diskpagersize): + Decls removed. + + * Makefile (SRCS): Remove devio.c. + * ufs.h (ufs_device, ufs_device_name): Variables removed. + * inode.c (diskfs_S_file_get_storage_info): Use DISKFS_DEVICE + instead of UFS_DEVICE, and DISKFS_DEVICE_NAME instead of + UFS_DEVICE_NAME. + +Sat Oct 7 20:47:56 1995 Miles Bader + + * main.c (diskfs_init_completed): Function deleted (now in libdiskfs). + (thread_cancel): Function deleted. + +Fri Oct 6 17:30:23 1995 Miles Bader + + * inode.c (diskfs_S_file_get_storage_info): Change type of + ADDRESSES to off_t **, and add the BLOCK_SIZE parameter. + +Wed Oct 4 17:21:33 1995 Miles Bader + + * inode.c (diskfs_set_statfs): fsys_stb_bsize -> fsys_stb_iosize. + fsys_stb_fsize -> fsys_stb_bsize. + + * main.c (parse_opt): Rearrange slightly. + +Tue Sep 26 11:54:35 1995 Michael I. Bushnell, p/BSG + + * inode.c: Include . + (diskfs_S_file_get_storage_info): New function. + * main.c (main): Delete var `devname'. Use `ufs_device_name' + throughout instead. + * ufs.h (ufs_device_name): New var. + +Fri Sep 22 13:22:42 1995 Roland McGrath + + * hyper.c (get_hypermetadata): Use %Zd format for result of sizeof. + +Tue Sep 19 13:41:46 1995 Miles Bader + + * Makefile (LDFLAGS): New variable. + +Wed Sep 13 12:30:23 1995 Michael I. Bushnell, p/BSG + + * dir.c (diskfs_lookup): Don't attempt to lock NP if NPP is not + set. Don't even set NP if NPP is not set; use INUM as "lookup + succeeded flag" instead. Lookups for REMOVE and RENAME now *must* + set NPP. + +Wed Sep 6 11:01:50 1995 Miles Bader + + * pager.c (diskfs_pager_users): Ignore the disk pager when seeing + if there are any active pagers. + +Mon Aug 28 17:07:36 1995 Roland McGrath + + * Makefile (ufs): Depend on ../libshouldbeinlibc/libshouldbeinlibc.a. + +Fri Aug 25 17:14:09 1995 Michael I. Bushnell, p/BSG + + * sizes.c (diskfs_truncate): When freeing direct blocks mentioned + in a single indirect block, or single indirect blocks mentioned in + a double, only call the free routine (ffs_blkfree or + indir_release, respectively) if the block is actually allocated. + +Wed Aug 23 12:24:07 1995 Miles Bader + + * Makefile (ufs): Add explicit dependencies. + (HURDLIBS, LDFLAGS, REMHDRS): Removed. + Rules associated with ../lib removed. + +Fri Jul 21 17:48:12 1995 Michael I Bushnell + + * pager.c (diskfs_get_filemap): Drop initial reference created by + pager_create. + + * pager.c (diskfs_get_filemap): Avoid race with simultaneous + termination by looping until we win. + (pager_clear_user_data): Only clear UPI->np->dn->fileinfo if it + still points to us. + +Mon Jul 17 14:35:25 1995 Michael I Bushnell + + * pager.c (thread_function): Don't have any global timeout here; + we don't use it anyhow. + +Thu Jul 6 15:42:52 1995 Michael I Bushnell + + * Makefile: Removed dependencies that are now automatically + generated. + +Mon Jun 26 20:17:42 1995 Michael I Bushnell + + * pager.c: Include . + (diskfs_pager_users): New function. + +Thu Jun 22 11:41:04 1995 Michael I Bushnell + + * pager.c (thread_function): Move thread_function to be non-local, + of course, because it needs to live even after create_disk_pager + returns. + + * main.c (thread_cancel): New function (HACK). + + * Makefile (HURDLIBS): Add libihash. + + * main.c (main): Have main thread exit when done instead of + calling a diskfs function. + +Wed Jun 21 12:20:01 1995 Michael I Bushnell + + * ufs.h (user_pager_info): Removed members next and prevp. + * pager.c (pager_clear_user_data): Don't maintain pager linked + list. + (diskfs_get_filemap): Don't maintain pager linked list. + (pager_dropweak): New function. + (pager_traverse): Delete function. + (diskfs_shutdown_pager): Use ports_bucket_iterate instead of + pager_traverse. + (diskfs_sync_everything): Likewise. + + * pager.c (pager_bucket): New variable. + (create_disk_pager): Provide pager_bucket in call to pager_create. + (diskfs_get_filemap): Likewise. + (diskfs_file_update): Use ports reference calls directly instead + of pager wrappers. + (drop_pager_softrefs): Likewise. + (allow_pager_softrefs): Likewise. + (pager_traverse): Likewise. + (create_disk_pager): Initialize pager_bucket here and fork off + service thread for pager ports. + + * sizes.c (diskfs_truncate): Likewise. + + * dir.c (diskfs_lookup): Provide initialization for BUFLEN. + (diskfs_direnter): Move assignment out of if test. + +Tue Jun 20 11:48:06 1995 Michael I Bushnell + + * sizes.c (diskfs_grow): Provide initialization of POKE_OFF. + * alloc.c (ffs_realloccg): Remove assignment from if tests. + * sizes.c (diskfs_truncate): Likewise. + * bmap.c (fetch_indir_spec): Likewise. + +Mon Jun 19 21:17:21 1995 Michael I Bushnell + + * inode.c (diskfs_node_iterate): New function. + (write_all_disknodes): Use it. + +Wed Jun 14 16:18:55 1995 Michael I Bushnell + + * inode.c (diskfs_get_translator): Conform to new memory usage + semantic. + +Sat May 20 00:17:30 1995 Miles Bader + + * main.c (trans_parse_args): Use options_parse & + diskfs_standard_startup_options to parse our translator options. + (usage): New function. + (parse_opt): New function. + + * Makefile (CPPFLAGS): Add -I../lib, to get include lib include files, + and $(CPPFLAGS-$(notdir $<)) to get file-specific cpp options. + Add a vpath for %.c to ../lib, so we can use source files from there. + +Mon May 15 13:14:48 1995 Michael I Bushnell + + * pager.c (pager_clear_user_data): Doc fix. + +Sat May 13 05:04:11 1995 Roland McGrath + + * Makefile (OBJS): Remove exec_server_image.o. + (exec_server_image.o): Rule removed. + +Mon May 8 08:43:43 1995 Miles Bader + + * dir.c (diskfs_lookup): When looping back to try_again: because + we're looking up "..", be sure and trash the mapping we made of + the directory's pager -- otherwise the reference to the pager + never gets dropped and we can never free the node. + + * dir.c (diskfs_lookup): ds->type was being compared to LOOKING, which + value it can never have. Compare ds->stat against LOOKING instead. + + * pager.c (pager_clear_user_data): Don't die when called on the + disk pager. + + * inode.c (write_all_disknodes): Fix typo `alloc' --> `alloca'. + +Tue May 2 11:59:09 1995 Michael I Bushnell + + * pager.c (pager_clear_user_data): Acquire pagerlistlock around + modifications to UPI->next/prevp list structure. + +Fri Apr 28 19:02:05 1995 Michael I Bushnell + + * inode.c (write_all_disknodes): We have to really lock the nodes + around the calls to diskfs_set_node_times and write_node; this in + turn forces us to have real refereces. + +Thu Apr 13 16:36:57 1995 Miles Bader + + * main.c (main): Don't abort if a std file descriptor is already open. + +Tue Apr 4 20:08:25 1995 Michael I Bushnell + + * inode.c (diskfs_set_translator): When freeing passive + translator, account for blocks freed in NP->dn_stat.st_blocks. + +Fri Mar 31 13:43:27 1995 Michael I Bushnell + + * sizes.c (diskfs_truncate): Don't acquire writer lock on + NP->dn->allocptrlock until after forcing delayed copies through; + otherwise the pageins will deadlock attempting to get a reader + lock to service them. This is safe, because we only need + NP->allocsize here, and that can't change as long as we hold + NP->lock. + +Mon Mar 20 13:58:44 1995 Michael I Bushnell + + * consts.c (diskfs_synchronous): New variable. + +Fri Mar 17 14:31:04 1995 Michael I Bushnell + + * alloc.c (ffs_clusteracct): Make static. + (alloc_sync): New function. + (ffs_alloc): Call alloc_sync. + (ffs_realloccg): Likewise. + (diskfs_alloc_node): Likewise. + (ffs_blkfree): Likewise. + (diskfs_free_node): Likewise. + +Sat Jan 28 14:59:26 1995 Roland McGrath + + * Makefile (OBJS): Remove reference to libc's devstream.o. + +Fri Nov 11 11:45:38 1994 Michael I Bushnell + + * hyper.c (diskfs_set_hypermetadata): Always use dev_write_sync to + avoid device_write bug that says you can't modify the buffer until + device_write returns. Also remember to deallocate BUF. + +Thu Nov 10 13:27:09 1994 Michael I Bushnell + + * main.c (main): Issue decent prompt. + + * hyper.c (diskfs_set_hypermetadata): Copy CSUM into a + page-aligned page-sized buffer for disk write to avoid inane + kernel bug. + +Wed Nov 9 05:43:14 1994 Michael I Bushnell + + * main.c (main): Behave more reasonably if we can't open DEVNAME. + +Tue Nov 8 00:03:20 1994 Roland McGrath + + * pager.c (pager_write_page): Use %p for printing PAGER. + + * ufs.h: Declare copy_sblock. + +Wed Nov 2 16:06:10 1994 Michael I Bushnell + + * hyper.c (copy_sblock): Don't copy csum here. + (diskfs_set_hypermetadata): Write csum directly to disk here. + +Thu Oct 27 20:58:08 1994 Michael I Bushnell + + * dir.c (diskfs_lookup): diskfs_get_filemap returns a send right, + so don't create an additional one here. + (diskfs_dirempty): Likewise. + * sizes.c (diskfs_truncate): Likewise. + (diskfs_grow): Likewise. + +Tue Oct 25 12:49:41 1994 Michael I Bushnell + + * hyper.c (copy_sblock): Call record_poke for csum and superblock + after modifying them. + + * pager.c (diskfs_shutdown_pager): Call copy_sblock. + (diskfs_sync_everything): Likewise. + + * alloc.c (ffs_fragextend): Call record_poke for CG after + modifying it. Also set CSUM_DIRTY and SBLOCK_DIRTY. + (ffs_alloccg): Likewise. + (ffs_alloccgblk): Likewise. + (ffs_nodealloccg): Likewise. + (ffs_blkfree): Likewise. + (diskfs_free_node): Likewise. + +Fri Oct 7 01:32:56 1994 Roland McGrath + + * main.c (diskfs_init_completed): Don't call _hurd_proc_init. + (saved_argv): Variable removed. + (main): Don't set saved_argv. Pass ARGV to diskfs_start_bootstrap. + +Wed Oct 5 22:18:46 1994 Michael I Bushnell + + * inode.c (read_disknode): If we are the bootstrap filesystem, + then getpid changes once proc starts up. So only call getpid + once, thus not allowing st_dev values to mysteriously change. + +Wed Oct 5 12:56:53 1994 Michael I Bushnell + + * alloc.c (diskfs_alloc_node): Abort if free inode has + translator attached. + +Tue Oct 4 18:33:35 1994 Michael I Bushnell + + * pager.c (pager_unlock_page): Call diskfs_catch_exception. + +Tue Oct 4 00:16:04 1994 Michael I Bushnell + + * inode.c (diskfs_lost_hardrefs): Comment out body. + * ufs.h (node2pagelock): New variable. + * pager.c (node2pagelock): Initialize. + (diskfs_get_filemap): Don't let node hold a reference to the pager. + (pager_clear_user_data): Acquire node2pagelock and clear + the node's reference to the pager. + (diskfs_file_update): Hold node2pagelock for reference + of NP->dn->fileinfo. + (drop_pager_softrefs): Likewise. + (allow_pager_softrefs): Likewise. + (diskfs_get_filemap): Likewise. + * sizes.c (diskfs_truncate): Likewise. + + * Makefile (SRCS): Added pokeloc.c. + +Mon Oct 3 15:03:38 1994 Michael I Bushnell + + * sizes.c (diskfs_truncate): Rewritten. + + * bmap.c (fetch_indir_spec): Initialize OFFSET values to -2, + meaning that the entry is not needed. If LBN is negative, + then don't set values for the data block. + + * inode.c (write_node): Call record_poke after writing + dinode. + (create_symlink_hook): Likewise. + (diskfs_set_translator): Likewise. + * pager.c (pager_unlock_page): Likewise. + * sizes.c (diskfs_truncate): Likewise. + * pager.c (pager_unlock_page): Call record_poke after writing + indirect block. + * sizes.c (diskfs_grow): Likewise. + (diskfs_grow): Likewise. + * pager.c (diskfs_sync_everything) [sync_one]: If this is the + disk pager, call sync_disk instead. + * pokeloc.c: New file. + +Fri Sep 30 11:25:36 1994 Michael I Bushnell + + * dir.h: Delete DT_* definitions; they are now in . + * dir.c (diskfs_get_directs): Set USERP->d_type as DT_UNKNOWN. + When the bugs in the type fields are fixed (dealing with + multiple links and mode changes) then this can actually return + the value. + +Thu Sep 29 17:16:58 1994 Roland McGrath + + * main.c (main): Test getpid()>0 to decide we are a normal + translator instead of the boot fs. Fetch bootstrap port after + possibly calling diskfs_parse_bootargs, not before. + +Tue Sep 27 15:24:58 1994 Michael I Bushnell + + * sizes.c (diskfs_grow) [computation of newallocsize]: Last block + number is one less than the total number of blocks. + +Tue Sep 27 11:58:44 1994 Michael I Bushnell + + * bmap.c (fetch_indir_spec): Single indirect block pointer is + in the INDIR_SINGLE slot, not the INDIR_DOUBLE slot. + +Mon Sep 26 20:47:30 1994 Michael I Bushnell + + * Makefile (SRCS): Added bmap.c. + + * main.c (main): Don't call pager_init. + + * inode.c (diskfs_get_translator): Repair to read translator + correctly. + + * sizes.c (diskfs_grow): Compute block numbers in a more clean + (and confidently correct) fashion. + (diskfs_truncate): Set NP->allocsize from a properly rounded + value. + +Mon Sep 26 12:50:38 1994 Michael I Bushnell + + * inode.c (diskfs_lost_hardrefs): "Know" that a pager starts + with a portinfo; we don't actually have access to the pager + struct here. + +Fri Sep 23 14:21:55 1994 Michael I Bushnell + + [ Continuing yesterday's changes. ] + * ufs.h (struct dirty_indir): New type. + (struct disknode): New member `dirty'. + * inode.c (iget): Initialize DN->dirty. + * bmap.c (mark_indir_dirty): New function. + * pager.c (pager_unlock_page): Call mark_indir_dirty before + writing into indirect blocks. + (diskfs_file_update): Sync indirect blocks here. + (pager_traverse): Simplify; do FILE_DATA and diskpager. + (pager_init): Removed function. + (create_disk_pager): New function. + * sizes.c: Completely rewritten. + * main.c (main): Spawn first thread sooner so we can + map and look at the disk image. + * hyper.c (get_hypermetadata): Moved firewall asserts + here from pager_init. + +Thu Sep 22 11:28:46 1994 Michael I Bushnell + + [This long series of changes deletes the DINODE, CG, SINDIR, + and DINDIR pagers and adds a new pager type DISK.] + * ufs.h (struct disknode) Removed DINLOCK, SINLOCK, and + SININFO members. New member ALLOCPTRLOCK renamed from DATALOCK. + Removed SINLOC, DINLOC, SINLOCLEN, and DINLOCLEN. + (struct user_pager_info) [enum pager_type]: Removed types + DINODE, CG, SINDIR and DINDIR; added type DISK. + (dinpager, dinodepager, cgpager): Deleted vars. + (diskpager): New var. + (dinmaplock, sinmaplock, pagernplock): Deleted vars. + (sblock_dirty, csum_dirty, cgs, dinodes): Deleted vars. + (fsaddr): New macro. + (dino, indir_block, cg_locate): New inline functions. + (sync_disk_blocks, sync_dinode): New inline functions. + (struct iblock_spec): New type. + * pager.c (dinport, dinodeport, cgport, sinlist): Deleted vars. + (filepagerlist): Renamed from filelist. + (pagernplock): Deleted variable. + (find_address): Removed switch; support only DISK and FILE_DATA. + (pager_report_extent): Likewise. + (pager_unlock_page): Removed switch. Return without comment for + DISK; allocate indirect blocks as necessary right here for + FILE_DATA. + (sin_map, sin_remap, sin_unmap, din_map, din_unmap): Deleted + functions. + (indir_alloc, sync_dinode): Deleted functions. + (enqueue_pager, dequeue_pager): Deleted functions. + (diskfs_file_update): No longer lock pagernplock; nothing + to do with sininfo. + (drop_pager_softrefs): Likewise. + (allow_pager_softrefs): Likewise. + (diskfs_get_filemap): Put pager on filepagerlist right here + instead of through pager_enqueue. + (pager_clear_user_data): Likewise, mutatis mutandis. + * main.c (main): Call create_disk_pager and then map the + entire disk into disk_image. + * hyper.c (get_hypermetadata): Use bcopy instead of dev_read_sync. + (diskfs_set_hypermetadata): NOP out function. + (copy_sblock): New function, substance of code is from old + diskfs_set_hypermetadata. + * inode.c (iget): Don't initialize deleted disknode fields. + (diskfs_node_norefs): Don't verify that deleted disknode + fields are not set. + (read_disknode): Get dinode from DINO, not DINODES array. + (write_node): Likewise. + (create_symlink_hook): Likewise. + (read_symlink_hook): Likewise. + (diskfs_set_translator): Likewise. + (diskfs_get_translator): Likewise. + (diskfs_node_translated): Likewise. + * alloc.c (ffs_realloccg): Likewise. + (ffs_fragextend): Use cg_locate instead of cgs array. + (ffs_alloccg): Likewise. + (ffs_nodealloccg): Likewise. + (ffs_blkfree): Likewise. + (diskfs_free_node): Likewise. + * inode.c (diskfs_set_translator): Use bcopy and sync_disk_blocks + instead of dev_write_sync. + (diskfs_get_translator): Likewise, mutatis mutandis. + (read_disknode): Initialize NP->istranslated. + (diskfs_set_translator): Set/clear NP->istranslated as appropriate. + (diskfs_node_translated): Removed function. + * bmap.c: New file. + + [This improves the RWLOCK mechanism and makes it more + orthogonal. It should probably be moved into a library.] + * ufs.h (struct rwlock): Added MASTER and WAKEUP members. + (struct disknode): Removed RWLOCK_MASTER and RWLOCK_WAKEUP + fields. + (rwlock_reader_lock): Ommitted arg DN; use new MASTER and WAKEUP + members inside LOCK instead. + (rwlock_writer_lock): Likewise. + (rwlock_reader_unlock): Likewise. + (rwlock_init): Initialize new MASTER and WAKEUP fields. + * inode.c (iget): Don't deal with RWLOCK_MASTER and RWLOCK_WAKEUP. + * pager.c (find_address): Deleted arg DNP. Only pass one + arg to rwlock functions. + (pager_read_page): Deleted var DN; only pass one arg to rwlock + functions. + (pager_write_page): Likewise. + +Wed Sep 21 00:26:25 1994 Michael I Bushnell + + * pager.c (allow_pager_softrefs): Unlock PAGERNPLOCK when + we're done with it. + (sin_map): Hold PAGERNPLOCK all the way until we're done + with the sininfo pointer. + (pagernplock): No longer static. + * ufs.h (pagernplock): Declare here. + + * sizes.c (diskfs_grow): Don't call diskfs_file_update here. + This was done to prevent too much dirty data from accumulating + and then overwhelming the pager later. But that's really the + pager's responsibility. + + * ufs.h (struct disknode): New members `dinloclen' and `sinloclen'. + * inode.c (iget): Initialize DN->dinloclen and DN->sinloclen. + (diskfs_node_norefs): Verify that DN->dinloclen and DN->sinloclen + are both zero. + * pager.c (find_address) [SINDIR]: Verify that reference is + within bounds of NP->dn->dinloc. + (pager_unlock_page) [SINDIR]: Likewise. + (din_map): Set NP->dn->dinloclen. + (din_unmap): Clear NP->dn->dinloclen. + (find_address) [FILE_DATA]: Verify that reference is within + bounds of NP->dn->sinloc. + (pager_unlock_page) [FILE_DATE]: Likewise. + (sin_map): Set NP->dn->sinloclen. + (sin_remap): Reset NP->dn->sinloclen. + (sin_unmap): Clean NP->dn->sinloclen. + + * pager.c (pager_write_page): Flush stdout after printf. + (pager_unlock_page) [FILE_DATA]: Likewise. + + * sizes.c (diskfs_truncate): In all references to sinloc and + dinloc arrays, verify that references are within allocated bounds. + (diskfs_grow): Likewise. + (sindir_drop): Likewise. + + * pager.c: Create new mapping with extent NEWSIZE, not SIZE (which + was the old size of the mapping). + +Tue Sep 20 15:51:35 1994 Michael I Bushnell + + * pager.c (pager_report_extent) [SINDIR]: Remove erroneous extra + division by block size. + (sin_remap): Likewise. + +Mon Sep 19 17:34:11 1994 Michael I Bushnell + + * inode.c (create_symlink_hook): Write assert test correctly. + + * dir.c (diskfs_direnter) [EXTEND]: Reference file size only + *once*; don't rely on the behavior if diskfs_grow vis a vis + file size. + +Fri Sep 16 10:29:42 1994 Michael I Bushnell + + * dir.c (dirscanblock): Compute offset correctly for mangled + entry notice. + + * dir.c (diskfs_direnter) [EXTEND]: Reference file size only + once before calling diskfs_grow in case diskfs_grow actually + increases the size. + + * inode.c (diskfs_set_statfs): Set fsid from getpid. + (read_disknode): Likewise. + + * dir.h (struct directory_entry): Renamed from struct direct. + * dir.c: All uses of struct direct changed to use + struct directory_entry. + (diskfs_get_directs): New var `userp'. Copy from *ENTRYP into + it (set at DATAP) more cleanly. + +Mon Sep 12 11:30:48 1994 Michael I Bushnell + + * hyper.c (diskfs_set_hypermetadata): Don't frob clean and dirty + bits if we are readonly. + +Sat Sep 10 11:41:06 1994 Roland McGrath + + * main.c (main): When started up as a passive translator, + open fds 0, 1, and 2 on /dev/console for debugging messages. + Call diskfs_init_diskfs with no args; after warp_root, call + diskfs_startup_diskfs on BOOTSTRAP. Compare BOOTSTRAP to + MACH_PORT_NULL instead of zero. + +Fri Sep 9 13:02:33 1994 Michael I Bushnell + + * main.c (trans_parse_args): Fix and enable. + +Tue Sep 6 11:29:55 1994 Michael I Bushnell + + * inode.c (iget): Remove old assert test that checked for bad + inode block allocations. + +Thu Sep 1 11:39:12 1994 Michael I Bushnell + + * tables.c: Don't include "ufs.h"; include . Then + this file can be used unmodified by fsck. + +Tue Aug 30 13:36:37 1994 Michael I Bushnell + + * inode.c (diskfs_set_translator): ffs_blkfree doesn't have + a return value. + +Mon Aug 29 12:49:17 1994 Michael I Bushnell + + * inode.c (diskfs_set_translator): If NAMELEN is zero, then + make the node have no translator. + +Fri Aug 26 12:28:20 1994 Michael I Bushnell + + * inode.c (read_disknode): 4.4 fsck sometimes sets the author + field to -1 to mean "ignore old uid location"; take that to mean + "author == uid". + (diskfs_set_translator): If we are allocating a new block for + the translator, then account for it in st_blocks. + +Thu Aug 18 12:41:12 1994 Michael I Bushnell + + * Makefile (HURDLIBS): Use short version. + + * alloc.c (diskfs_alloc_node): Bother to set *NPP before + returning. + +Tue Aug 16 10:48:04 1994 Michael I Bushnell + + * Makefile (LDFLAGS): New variable. + +Fri Aug 5 15:51:09 1994 Michael I Bushnell + + * dir.c (diskfs_direnter) [EXTEND]: Crash if the entry won't + fit in the new block. + (diskfs_lookup): Return ENAMETOOLONG if the name is bigger than + MAXNAMLEN. + + * dir.c (diskfs_get_directs): Set USERD->d_reclen correctly. + +Fri Jul 22 15:12:35 1994 Michael I Bushnell + + * Makefile: Rewritten in accord with new scheme. + +Wed Jul 20 13:28:38 1994 Michael I Bushnell + + * main.c (main): Don't set diskfs_dotdot_file. + +Tue Jul 19 21:51:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * ufs.h: Removed defns of u_quad_t, quad_t; now in . + Removed defn of struct timespec; now in . + +Tue Jul 19 12:47:31 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * main.c (main): Deleted var `diskfs_dotdot_file'. + (trans_parse_args): Don't set diskfs_dotdot_file; don't expect + dotdot from fsys_getroot. + + * Makefile (LDFLAGS): Moved to rule for `ufs' and commented out. + (ufs): Don't use variable $(link) anymore. + +Mon Jul 18 14:55:17 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir.c (diskfs_get_directs): Return data to user in old format. + Add new code for new format, maintaining compatibility correctly, + but comment it out until the library is ready. + + * hyper.c (diskfs_set_hypermetadata): If we presumed to + set new values of fs_maxfilesize, fs_qbmask, and fs_qfmask, + then restore the originals before writing out the superblock. + + * pager.c (diskfs_get_filemap): Test should be S_ISLNK, not + S_ISSOCK. + + * hyper.c (get_hypermetadata): Set new constants in filesystems + which don't have them yet. + (get_hypermetadata): Cast MAXSYMLINKLEN to long to avoid + converting sblock->fs_maxsymlinklen into an unsigned. + + * subr.c (scanc, skipc): New functions. + (ffs_setblock): Use assert instead of panic. + + * inode.c (read_disknode): Set old stat structure until the header + file gets changed. + +Fri Jul 15 12:07:15 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sizes.c: Include for bzero. + * fs.h (blksize): Comment out dblksize macro. In blksize + macro, use NP->allocsize instead of IP->i_size. + + * dinode.h (INDIR_SINGLE, INDIR_DOUBLE, INDIR_TRIPLE): New macros. + + * inode.c (read_disknode, write_node): Use new stat and dinode + fields for times. + + * ufs.h: Change `nextgennumber' to be `u_long' instead of int. + Change prototypes of some alloc.c functions. + * alloc.c (ffs_alloc): Declare to return error_t. + (ffs_realloccg): Likewise. + (ffs_hashalloc, ffs_alloccg, ffs_fragextend, ffs_alloccg, + ffs_dirpref, ffs_nodealloccg, ffs_allccgblk, ffs_mapsearch, + ffs_clusteracct): Provide forward declarations. + (ffs_realloccg): Use printf instead of log. + Make BPREF volatile for setjmp safety. + (diskfs_alloc_node): Use diskfs global variable instead of TIME. + (ffs_nodealloccg): Likewise. + (ffs_blkfree): Likewise. + (diskfs_free_node): Likewise. + (ffs_blkfree, ffs_clusteracct): Declare as void. + (ffs_alloccg, ffs_nodealloccg): Declare as u_long. + + * ufs.h: Change prototypes of some subr.c functions. + * subr.c (ffs_isblock): Use assert instead of panic. + (ffs_clrblock): Likewise. + + * hyper.c: Include "dinode.h". + + * dinode.h (LINK_MAX): New macro, from BSD sys/sys/syslimits.h. + * fs.h (MAXBSIZE, MAXFRAG): New macros, from BSD sys/sys/param.h. + + * hyper.c (get_hypermetadata): Provide first arg in call to + fsbtodb. + (diskfs_set_hypermetadata): Likewise. + * inode.c (diskfs_set_translator): Likewise. + (diskfs_get_translator): Likewise. + * pager.c (find_address): Likewise. + (indir_alloc): Likewise. + * inode.c (iget): Provide first arg in call to lblkno. + * sizes.c (diskfs_truncate): Likewise. + * pager.c (find_address): Likewise. + * sizes.c (diskfs_grow): Likewise. + * inode.c (iget): Provide first arg in call to fragroundup. + * sizes.c (diskfs_trucate): Likewise. + * sizes.c (diskfs_grow): Likewise. + * inode.c (iget): Provide first arg in call to blkroundup. + * pager.c (pager_unlock_page): Likewise. + * sizes.c (diskfs_truncate): Likewise. + * sizes.c (diskfs_grow): Likewise. + * pager.c (find_address): Provide first arg in call to cgtod. + * pager.c (find_address): Provide first arg in call to cgimin. + * pager.c (find_address): Provide first arg in call to blktofrags. + * pager.c (find_address): Provide first arg in call to blkoff. + * sizes.c (diskfs_truncate): Likewise. + * sizes.c (diskfs_grow): Likewise. + * sizes.c (diskfs_truncate): Provide first arg in call to blksize. + * sizes.c (diskfs_grow): Likewise. + * sizes.c (diskfs_truncate): Provide first arg in call to numfrags. + + * ufs.h: Added temporary declarations of `u_quad_t', `quad_t', and + `struct timespec'. + + * pager.c (diskfs_get_filemap): Make sure that this is + a kind of node that can be validly read. + + * inode.c (create_symlink_hook): Renamed from symlink_hook. + (read_symlink_hook): New function. + (diskfs_read_symlink_hook): Initialize. + +Thu Jul 14 12:23:45 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * alloc.c: New from 4.4 BSD; BSD version `8.8 2/21/94'. + Remove old includes; include "ufs.h", "fs.h", "dinode.h", + and . Replace panics with asserts and comment out + uprintfs. Use prototypes throughout. Replace calls + to ffs_fserr with printf. + (alloclock): New variable. + (ffs_alloc): Variable struct inode *IP is now struct node *NP; + refer to it appropriately. Initialize FS to sblock. + Lock alloclock around actual allocation steps. Reverse order + of BNP and CRED arguments; declare CRED as a protid and use + accordingly. Permit CRED to be null. + (ffs_realloccg): Variable struct inode *IP is now struct node *NP; + refer to it accordingly. Comment out U*x buffer management code. + Lock alloclock around actual allocation steps. Initialize FS + from sblock. Declare CRED as a protid and use it accordingly. + Change BUF arg to PBN (physical block number); return new block + there. + (ffs_reallocblks): Comment out. + (diskfs_alloc_node): Renamed from ialloc. Initialize FS from + sblock. Use calling sequence from . Acquire + alloclock aroud actual allocation steps. Deleted vars + `pip', `pvp' (use dir instead). Use iget instead of VFS_VGET. + Var struct inode *IP now struct node *NP. Lock gennumberlock + around frobbing of nextgennumber. + (ffs_blkpref): Arg struct inode *ip is now struct node *np; + refer to it accordingly. Initialize FS to sblock. Lock + alloclock during actual work. Use csum instead of fs_cs macro. + (ffs_hashalloc): Arg struct inode *IP is now struct node *NP; + use it accordingly. Initialize FS from sblock. + (ffs_fragextend): Arg struct inode *IP is now struct node *NP; + use it accordingly. Initialize FS from sblock. Initialize + CGP from cgs array; don't use bread. Comment out calls to brelse + and bdwrite. Set CGP->time from diskfs global var. Use csum + instead of fs_cs macro. + (ffs_alloccg): Arg struct inode *IP is now struct node *NP. + Initialize FS from sblock. Initialize CGP from cgs array; + don't use bread. Comment out calls to brelse and bdwrite. + Set CGP->time from diskfs global var. Use csum instead of + fs_cs macro. + (ffs_nodealloccg): Arg struct inode *IP is now struct node *NP. + Initialize FS from sblock. Initialize CGP from cgs array; + don't use bread. Comment out calls to brelse and bdwrite. Use + csum instead of fs_cs macro. + (ffs_blkfree): Arg struct inode *IP is now struct node *NP. + Initialize FS from sblock. Initialize CGP from cgs array; + don't use bread. Comment out calls to brelse and bdwrite. Use + csum instead of fs_cs macro. + (diskfs_free_node): Renamed from ffs_vfree. Use calling + sequence from . Initialize FS from sblock. + Deleted vars pip,pvp (use NP instead). Initialize CGP from + cgs array; don't use bread. Comment out calls to brelse and + bdwrite. Use csum instead of fs_cs macro. + (ffs_fserr): Commented out. + (ffs_dirpref): Use csum instead of fs_cs macro. + + * ufs.h (ffs_alloc): Renamed from alloc; all callers changed. + (ffs_blkfree): New arg NP; renamed from blkfree; all callers changed. + (ffs_blkpref): Renamed from blkpref; all callers changed. + (ffs_realloocg): Rename from realloccg; all callers changed. + + * fs.h: New from 4.4 BSD; BSD version `8.7 4/19/94'. + (fs_cs): Don't use fs_csp; use global csum instead. + + * subr.c: New from 4.4 BSD; BSD version `8.2 9/21/93'. + Remove old includes. Include "ufs.h" and "fs.h". + (ffs_blkatoff, ffs_checkoverlap): Comment out. + + * tables.c: New from 4.4 BSD; BSD version `8.1 6/11/93'. + Don't include ; do include "ufs.h" and "fs.h". + + * dinode.h: New from 4.4 BSD; BSD version `8.3 1/21/94'. + Remove oldids/inum union; replace with author. + Renamed di_mode to be di_model; allocated di_modeh from spare. + Allocate di_trans from spare. + (di_inumber): Remove macro. + * inode.c (read_disknode): Fetch uid and gid from new (long) + fields in dinode unless we are the old inode format, in which + case fetch them from the old fields. + (write_node): Only set new uid and gid fields if we are not + COMPAT_BSD4. Set old fields if the superblock says to. + (symlink_hook): New function. + (diskfs_create_symlink_hook): Initialize. + * sizes.c (diskfs_truncate): Deal with truncation of short + symlink properly. + + * dir.h: New from 4.4 BSD; BSD version `8.2 1/21/94'. + Substitute our version of DIRSIZ which uses the namelen. + Comment out declarations of struct dirtemplate and struct + odirtemplate. + (DIRECT_TYPE, DIRECT_NAMLEN): New macros. + * ufs.h (direct_symlink_extension): New variable. + * hyper.c (get_hypermetadata): Set direct_symlink_extension. + * dir.c (dirscanblock): Use DIRECT_NAMLEN instead of d_namlen. + (diskfs_direnter): Likewise. + (diskfs_dirempty): Likewise. + (diskfs_get_directs): Likewise. + (diskfs_direnter): Set d_type field of new slot if + direct_symlink_extension is set. + (diskfs_dirrewrite): Likewise. + + * ufs.h (compat_mode): New variable. + * main.c (main): Set compat_mode to zero if we are the bootstrap + filesystem. + * inode.c (diskfs_set_translator): Return error if compat_mode + is set. + (write_node): Don't set GNU dinode field extensions unless + compat_mode is COMPAT_GNU. + +Mon Jul 11 18:14:26 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir.c (diskfs_get_directs): When copying entries into DATAP, + set the d_reclen parameter of the copy to the minimum length + (because that's all we use) rather than the size that it had + in the directory itself. + +Wed Jul 6 14:41:48 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir.c (dirscanblock): In main loop, initialize PREVOFF + to zero, not BLOCKADDR. Otherwise, the wrong value is + stored into DS->prevoff and then diskfs_dirremove crashes. + +Tue Jul 5 14:07:38 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dinode.h: Include before test of BYTE_ORDER. + + * Makefile (TAGSLIBS): New variable. + +Tue Jun 21 13:45:04 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir.c (diskfs_direnter): Update dirents of DP, not NP. + +Mon Jun 20 16:43:48 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir.c (diskfs_direnter) [case SHRINK]: NEW should be set to + OLDNEEDED past DS->entry, not to the start of the next entry. + + * dir.c (diskfs_direnter) [case EXTEND]: Cast in assignment + to NEW needs proper scope. + + * inode.c (diskfs_node_norefs): Free dirents list of structure + being deallocated. Also add assert checks to make sure other + state is already clean. + +Thu Jun 16 11:38:17 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * dir.c (diskfs_dirempty): Map directory contents ourselves + instead of using diskfs_node_rdwr. + (struct dirstat): New structure to cache mapping between + lookup and commit operation and avoid use of diskfs_node_rdwr. + (diskfs_lookup): Map directory ourselves. Keep mapping in + DS if DS is nonzero and we might use it in direnter, dirremove, + or dirrewrite. Deallocate mapped buffer if we return some + error (other than ENOENT), or if DS is zero, or if there is + no possible commit operation to follow. When setting DS->stat + to EXTEND, do it the new way. + (dirscanblock): Changed BLKOFF to be virtual address of mapped + block and renamed it BLKADDR. New arg IDX. Use mapped block + instead of calling diskfs_node_rdwr. Set DS according to the new + rules. + (diskfs_direnter): Interpret new dirstat format. + (diskfs_dirremove): Likewise. + (diskfs_dirrewrite): Likewise. + (diskfs_drop_dirstat): Deallocate cached mapping here. + + * dir.c (dirscanblock): When we find the node for type CREATE, + invalidate DS by setting type to LOOKUP, not LOOKING. + + * dir.c (diskfs_direnter, diskfs_dirremove, diskfs_dirrewrite): + Call diskfs_notice_dirchange when appropriate. + + * dir.c (diskfs_get_directs): Deal properly with case where + BUFSIZ==0 and where NENTRIES==-1. + +Wed Jun 15 16:40:12 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * main.c (main): Check device sector size and media size + on startup. + +Tue Jun 14 14:41:17 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * ufs.h (struct disknode) [dirents]: New member. + * inode.c (iget): Initialize DN->dirents. + * dir.c (diskfs_direnter, diskfs_dirremove): Keep track + of dirents member. + (dirscanblock): New var `nentries'; use it to count the + number of directory entries in this block and set it if + we end up scanning the entire block. + (count_dirents): New function. + (diskfs_get_directs): New function. + +Mon Jun 13 13:50:00 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * ufs.h (sinmaplock, dinmaplock): New global vars. + * inode.c (inode_init): Initialize sinmaplock and dinmaplock. + * pager.c (find_address, pager_unlock_page): Protect use + if dinloc array with dinmaplock. + (din_map, din_unmap): Doc fix. + (find_address, pager_unlock_page): Protect use of sinloc array + with sinmaplock. + (sin_map, sin_remap, sin_unmap): Doc fix. + (pager_clear_user_data): Acquire sinmaplock and dinmaplock + instead of NP->dn->datalock and NP->dn->sinlock respectively. + + * sizes.c (diskfs_truncate, diskfs_grow): Protect use of sinloc + and sindir mapping functions with sinmaplock. + (sindir_drop): Protect use of dinloc and dindir mapping functions + with dinmaplock. + + * ufs.h (struct rwlock): New type. + (struct disknode) [dinlock, sinlock, datalock]: Use read-write lock. + Change comments so that these don't lock dinloc and sinloc anymore. + [rwlock_master, rwlock_wakeup]: New members. + (rwlock_reader_lock, rwlock_writer_lock, rwlock_reader_unlock, + rwlock_writer_unlock, rwlock_init): New functions. + * inode.c (iget): Initialize DN->rwlock_master and + DN->rwlock_wakeup. Change initialization of DN->dinlock, + DN->sinlock, and DN->datalock to use rwlock_init. + * pager.c (find_address): Lock NP->dn->dinlock, NP->dn->sinlock, + and NP->dn->datalock with rwlock_reader_lock. Change type of + parameter NPLOCK to be a read-write lock. New parm DNP. Callers + changed. + (pager_read_page, pager_write_page): Change type of NPLOCK to be + read-write lock; call rwlock_reader_unlock instead of + mutex_unlock. New variable DN. + (pager_unlock_page): Use rwlock_writer_lock to lock + NP->dn->dinlock, NP->dn->sinlock, and NP->dn->datalock. + * sizes.c (diskfs_truncate, diskfs_grow): Change locks of DATALOCK + field to use rwlock_writer_{un,}lock. + (sindir_drop): Ditto for SINLOCK field. + (dindir_drop): Ditto for DINLOCK field. + +Mon Jun 6 19:23:26 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sizes.c (diskfs_grow): After realloccg, zero new data (which I'm + not sure is really necessary, but until I figure it out, this is + safest). Also poke old data (the latter only if the block has + moved)--otherwise the kernel won't know to page it out to the new + location. + (poke_pages): When poking, be careful not to actually change the data. + LEN should be end - start, not start - end. + +Fri Jun 3 12:37:27 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * inode.c (iget): When we find the node in the table, acquire the + mutex *after* incrementing NP->references and unlocking + diskfs_node_refcnt_lock; otherwise we can deadlock against + diskfs_nput. + +Thu Jun 2 12:16:09 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * ufs.h (sblock_dirty, csum_dirty, alloclock): New global variables. + * alloc.c (alloclock): Remove static keyword.. + * alloc.c (realloccg): Set sblock_dirty after changing sblock. + (blkpref): Likewise. + (fragextend): Likewise. + (alloccg): Likewise. + (alloccgblk): Likewise. + (ialloccg): Likewise. + (blkfree): Likewise. + (diskfs_free_node): Likewise. + * hyper.c (diskfs_set_hypermetadata): Likewise. + * alloc.c (fragextend): Set csum_dirty after changi csum. + (alloccg): Likewise. + (alloccgblk): Likewise. + (ialloccg): Likewise. + (blkfree): Likewise. + (diskfs_free_node): Likewise. + * hyper.c (diskfs_set_hypermetadata): Acquire alloclock while + writing hypermetadata. Only write csum and sblock if + csum_dirty or sblock_dirty, respectively, is set, and then + clear it after starting the write. + + * main.c (main): Likewise. + + * sizes.c (diskfs_truncate): Don't turn off caching; the new + light reference system takes care of this. + * pager.c (diskfs_get_filemap): No longer necessary to turn + on caching here, because truncate no longer turns it off. + + * inode.c (diskfs_lost_hardrefs, diskfs_new_hardrefs): New functions. + * pager.c (drop_pager_softrefs, allow_pager_softrefs): New functions. + (sin_map): Use diskfs_nref_light, not diskfs_nref. + (diskfs_get_filemap): Use diskfs_nref_light, not diskfs_nref. + (pager_clear_user_data): Use diskfs_nrele_light, not diskfs_nrele. + * ufs.h (drop_pager_softrefs, allow_pager_softrefs): New + declarations. + +Wed Jun 1 13:35:11 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sizes.c (diskfs_truncate): After calling sin_unmap, turn + off caching on the sininfo pager so that it gets freed promptly + (there's generally no value in keeping it around because there + is no live fileinfo pager). + * pager.c (diskfs_get_filemap): Make sure we turn caching back on + here, however, if we start using the file pager. + + * pager.c (sin_map): When np->dn->sininfo is set, we have + to insert a valid send right after fetching the receive name. + + * pager.c (sin_unmap, din_unmap): New functions. + (pager_clear_user_data): Call sin_unmap and din_unmap + instead of doing it right here. + + * sizes.c (diskfs_truncate): Call sin_unmap instead of + doing it right here. + (sindir_drop): Call din_unmap instead of doing it right + here. Also, call it always, not just when wo do dindir_drop. + + * sizes.c (diskfs_grow): After alloc into sindir area, + unmap it if we don't have an active data pager. + * ufs.h (sin_unmap, din_unmap): New declarations. + + * sizes.c (diskfs_grow): In computing OSIZE in the realloc + case of lbn < NDADDR, deal correctly with the case where + np->allocsize is already an integral number of blocks. + + * sizes.c (diskfs_grow): Compute SIZE correctly. + + * alloc.c (alloc, realloccg, blkfree): When checking validity + of size arguments, also make sure the size isn't zero. + + * alloc.c (diskfs_alloc_node): Lock ALLOCLOCK before checking + sblock->fs_cstotal.cs_nifree. + +Tue May 31 18:47:42 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * ufs.h (DONT_CACHE_MEMORY_OBJECTS): Define it. + + * dir.c (diskfs_direnter: case TAKE): Assert that OLD->d_reclen >= + NEEDED, not that it is strictly >. + +Tue May 31 11:10:28 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sizes.c (diskfs_grow): Call diskfs_node_update (but don't wait) + after successful completion to prevent old data from hanging around + too long and getting flushed all at once from the kernel. + + * sizes.c (diskfs_grow): Change SIZE to be the size of the last + block allocated. Delete variable NSIZE; use SIZE instead. + +Fri May 27 13:15:26 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sizes.c (diskfs_truncate): Set NP->dn_stat_dirty after each + modification of NP->dn_stat. + + * sizes.c (diskfs_truncate): Compute new value of NP->allocsize + correctly. + + * inode.c (iget): Set NP->allocsize to be the *actual* allocsize. + +Thu May 26 11:51:45 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sizes.c (diskfs_truncate): In blkfree loop of blocks past + NDADDR, subtract NDADDR from idx to index correctly into + sinloc array. Start this loop with idx not less than NDADDR. + (diskfs_truncate): If olastblock == NDADDR, then we also + need to truncate blocks (one) mapped by single indirect blocks. + (diskfs_truncate): New variable `first2free'. Use in place + of older losing calculations involving lastblock. + (sindir_drop): Rename parameters to be FIRST and LAST. Change + interpretation of FIRST by one to correspond with changed call + in diskfs_truncate. + + * pager.c (sin_remap): When computing NEWSIZE, round up to + a page boundary, thus mimicing the SINDIR computation in + pager_report_extent properly. + + * pager.c (pager_unlock_page) [case SINDIR; vblkno == 0]: Read + from ....di_ib[INDIR_SINGLE] rather than invalid data before + NP->dn->dinloc. + + * alloc.c (alloc) [nospace]: Unlock alloclock. + (realloccg): Unlock alloclock before jumping to nospace. + (blkpref) [!(lbn < NDADDR)]: Unlock alloclock before returning + success. + + * sizes.c (diskfs_grow): When allocing a block past NDADDR, the + tbl arg to blkpref is the table of direct block pointers + NP->dn->sinloc, not the table of indirect block pointers + ...->di_ib. + + * sizes.c (diskfs_grow): When writing into the SINDIR area, call + sin_map instead of sin_remap if the sindir isn't already mapped. + Also set np->allocsize *before* calling sin_map, but *after* + calling sin_remap, to meet the requirements of those separate + routines. + + * sizes.c (diskfs_grow): If END isn't bigger than NP->allocsize, + then don't try and do anything. In computation of LBN and the + first use of NB, round up to block boundary correctly. Don't + attempt to realloc an old block if the size is 0 (in which case + NB is -1 and unsigned comparison rules might foul things up). + +Mon May 23 13:18:33 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (ufs): Give -n in the proper order to rsh. + + * main.c: Include . + + * ufs.h (DONT_CACHE_MEMORY_OBJECTS): New compilation flag. + * pager.c (pager_report_attributes): Deleted function. + (MAY_CACHE): New macro; more useful form for using + DONT_CACHE_MEMORY_OBJECTS. + (sin_map, pager_init, diskfs_get_filemap): Provide new + args in calls to pager_create. + * sizes.c (MAY_CACHE): New macro; more useful form for + using DONT_CACHE_MEMORY_OBJECTS. + (diskfs_truncate): Use MAY_CACHE in calls to pager_change_attributes. + +Fri May 20 18:52:41 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sizes.c (diskfs_truncate): Force any delayed copies of the + vanishing region to be taken immediately before stopping, and + prevent any new delayed copies from being made until we are done + manipulating things. + (poke_pages): New function. + * pager.c (pager_report_attributes): New function. + +Wed May 18 15:51:40 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * alloc.c (alloc, realloccg, diskfs_alloc_node, alloccgblk, + blkfree, diskfs_free_node, mapsearch): Added helpful strings to + asserts. + (realloccg): Split up assert. + +Tue May 17 13:26:22 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * main.c (main): Delete unused variable PROC. + +Mon May 16 15:32:07 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * alloc.c (realloccg): When fragextend succeeds, bother to set + *PBN. + + * sizes.c (diskfs_grow): In fragment growth case, NSIZE should + not be the amount to hold SIZE (SIZE is the amount the file is + growing by), but rather the old size of the fragment plus the + SIZE. + + * dir.c (diskfs_direnter case COMPRESS): Rewrite loop to deal + properly with the case where from and to overlap. + +Mon May 9 16:51:44 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * main.c (ufs_version): New variable. + (save_argv): New variable. + (main): Set save_argv. + (diskfs_init_completed): New function. + +Thu May 5 19:06:54 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * Makefile (exec_server_image.o): Use -n when calling rsh. + +Thu May 5 07:39:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makefile ($(OBJS)): Use $(includedir) instead of $(headers) in deps. + -- cgit v1.2.3 From 08aee92bc4271a9381be75116b4ba7d69a869984 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Jul 1996 03:47:47 +0000 Subject: *** empty log message *** --- =Maketools | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 =Maketools diff --git a/=Maketools b/=Maketools deleted file mode 100644 index 1ec9b8a8..00000000 --- a/=Maketools +++ /dev/null @@ -1,52 +0,0 @@ -# This is the directory holding ar and ranlib -tooldir := /usr/local/i386-gnu/bin - -# This is a machine on which to run MiG. (MiG writes CPU dependent code, -# so MiG has to be run on a machine that's the same as the one that will -# run the eventual code.) If you are not doing cross-compilation, then -# you need to set MIGCOM and MIG below to the plain pathnames of those -# two programs respectively. -# If the version of GCC on this version is not the same as CCVERSION, -# then you must set CCVERSION-$(mighost) in the same fashion as is -# done below for ernst.gnu.ai.mit.edu and douglas.gnu.ai.mit.edu. -mighost := ernst.gnu.ai.mit.edu - -# Set these options to the GCC compiler spec (the correct value -# can be found in /usr/local/lib/lib-gcc). -CCTARGET=i386-gnu -hostname := $(shell hostname) -CCVERSION=$(firstword $(CCVERSION-$(hostname)) 2.7.1) -CCTYPE=-b $(CCTARGET) -V $(CCVERSION) -CCVERSION-douglas.gnu.ai.mit.edu = 2.5.7 -CCVERSION-ernst.gnu.ai.mit.edu = 2.5.7 - -ccdir = /usr/local/lib/gcc-lib/$(CCTARGET)/$(CCVERSION) -crossdir := /usr/local/$(CCTARGET) - -ifndef BUILD_CC -export BUILD_CC := $(CC) -endif -CC=$(CCTARGET)-gcc $(CCTYPE) -O2 -ifeq (,$(wildcard /usr/local/lib/migcom)) -MIGCOM=$(crossdir)/lib/migcom -MIG=$(tooldir)/mig -else -MIGCOM=/usr/local/lib/migcom -MIG=mig -endif -CPP=$(CC) -E -x c -export CPP -AR=$(tooldir)/ar -RANLIB=$(tooldir)/ranlib -LD=$(tooldir)/ld -L$(ccdir) -OBJCOPY=$(CCTARGET)-objcopy - -startup := $(crossdir)/lib/crt0.o -libc := $(crossdir)/lib/libc.a -crossheaders := $(crossdir)/include - -INSTALL = install -c -INSTALL_DATA = $(INSTALL) -m 644 -INSTALL_PROGRAM = $(INSTALL) -m 755 - -machine := i386 -- cgit v1.2.3 From fd1e1883cb5f8cc23c3f92529c3edc41db5ed2bf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Jul 1996 04:35:29 +0000 Subject: *** empty log message *** --- SOURCES.0.0 | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 SOURCES.0.0 diff --git a/SOURCES.0.0 b/SOURCES.0.0 new file mode 100644 index 00000000..a601ee19 --- /dev/null +++ b/SOURCES.0.0 @@ -0,0 +1,196 @@ +Sources for binaries in Hurd version 0.0. + +STILL TO CATEGORIZE: XXX +* fileutils (3.13) [rebuild for df after libc install] +* gperf (cperf 2.1a) [hacked src/Makefile and src/stderr.c slightly] + [substitute with libg++ version?] +libc +mach + + + +The following packages were built from the sources of the indicated +version in ftp://prep.gnu.ai.edu/pub.gnu according to the provided +instructions without modification: + +* autoconf (2.10) +* automake (1.0) +* bc (1.03) +* binutils (2.7) +* bison (1.25) +* cpio (2.4.2) +* cvs (1.8.1, in cvs-1.8.tar.gz) +* diffutils (2.7) +* doschk (1.1) +* ed (0.2) +* emacs lisp manual (19-2.4) +* flex (2.5.3) +* gawk (3.0.0) +* gcal (1.01) +* gcc (2.7.2) +* gdbm (1.7.3) +* gettext (0.10) +* gmp (2.0.2) +* grep (2.0) +* hello (1.3) +hurd (0.0) +* indent (1.9.1) +* inetutils (1.0) +* less (320) +* m4 (1.4) +* miscfiles (1.0) +* nvi (1.71) +* ptx (0.4) +* readline (2.0) +* recode (3.4) +* sed (2.05) +* sharutils (4.2) +* termcap (1.3) [manual only] +* termutils (2.0) +* textutils (1.19) +* time (1.7) +* wdiff (0.5) + + + +The following packages were built from the sources of the indicated +version in ftp://prep.gnu.ai.mit.edu/pub/gnu according to the provided +instructions, after making the indicated minor modifications: + +* emacs (19.31) + [comment out definition of tparam in src/terminfo.c.] + [add to src/s/gnu.h the following five lines] + #ifdef HAVE_LIBNCURSES + #define TERMINFO + #define LIBS_TERMCAP -lncurses + #endif + #define setpgrp(a,b) setpgrp() +* findutils (4.1) + [Comment out decl of basename in defs.h and defn in util.c] +* gzip (1.2.4) + [commented out basename from gzip.h and util.c] +* ncurses (1.9.9e) + [In read_entry.c, change second arg of call to open from `0' to O_RDONLY] + [In lib_tparm.c:tparam, add the following before the call to tparam_internal] + if (!buffer) + buffer = malloc (256); +* patch (2.1) + [comment out basename in backupfile.c.] +* rcs (5.7) + [Put `#undef ED' before #define ED in conf.h.] + [Add `#define SYMLOOP_MAX 8' to conf.h.] +* tar (1.11.8) + [add `strerror' to AC_CHECK_FUNCS in configure.in] +* texinfo (3.7) + [info/terminal.c -- add `#define B9600 9600'] + + + + +The following were compiled from the sources found in +ftp://prep.gnu.ai.mit.edu/pub/gnu/gnu-0.0/hurd-special-src: + +* bash (1.14.4 patchlevel 10, with some additional local bugfixes) +e2fsprogs (e2fsprogs-0.5c-hurd1.tar.gz) [1.04 doesn't have hurd patches] +serverboot +* from +(*) grub + [ Requires changes for ELF: avoid generating 16-bit relocations. + Requires other changes to deal with ELF; makefiles only work for + mach3-a.out object file format. ] +* sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) +* make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) +gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] + + + + + +Give up: +finger (1.37) +mtools (3.0) [comment out decl of sys_errlist in sysincludes.h.] + [Uses of MAXPATHLEN] +oleo (1.6) [utterly fails to build] +gnuplot (3.5) [has old old version of readline] +es (0.84 from ftp.white.toronto.edu) + (-DEVFD=1 -DGETGROUPS_USES_GID_T=1 -DREADLINE=1 + -DUSE_SIGACTION=1 -DUSE_SIG_ATOMIC_T=1) + [ Errors for longjmp in access.c and parse errors besides] +regex (0.12) [Expects TeX to be present] +screen (3.7.1) [Wants utmpx.h]?? +ispell (3.1.20) [hacked for bison; builds zero-length dictionary] +rx (1.0) [ wants `tsort' to configure ] +perl (5.003) [configure script fails in shlib frobnication] + + +Secondary: +* from (from.tar.gz) +X libraries +X utilities +TeX +METAFONT +libg++ +calc +chess +clisp +csh +dld +gcl +dejagnu +elib +elisp archive +f2c +ffcall +g77 +fontutils +ghostscript +ghostview +git +gnugo +graphics +groff +hp2xx +hyperbole +id-utils +jacal +lily +mkisofs +nethack (3.2.1) + [3.2.0 + nethack-3.2.0-3.2.1.patch + define BSD & linux, frob paths in config.h & unixconf.h & root Makefile + comment out declaration of random in system.h] +nih classes +oaklisp +libobjects +mm +obst +octave + [See ftp://ftp.che.wisc.edu/pub/octave/README-GCC-2.7.0] + [See ftp://ftp.che.wisc.edu/pub/octave/README-GCC-2.7.1] +p2c +pcl +pine +rc +scheme +shogi +sipp +smalltalk +sneps +superopt +tile forth +ucblogo +uucp +vh +vm +xboard +xinfo +xshogi + + +Tertiary: +X server +ae +cfengine +enscript +gnat +mc -- cgit v1.2.3 From f8fc13b6a88559aeb28d0957444873dd5975e5ba Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Jul 1996 19:11:03 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 5 +++++ ufs-fsck/pass2.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 1ea09c4a..cebead0c 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 18 14:55:14 1996 Michael I. Bushnell, p/BSG + + * pass2.c (pass2): If an entire directory block is null, allow + preen to patch it into a normal empty directory entry. + Sat Jul 6 19:59:27 1996 Miles Bader * main.c (argp_program_version): New variable. diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 69331946..db63abd7 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -60,6 +60,30 @@ pass2 () if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) { + /* Perhaps the entire dir block is zero. UFS does that + when extending directories. So allow preening + to safely patch up all-null dir blocks. */ + if (dp == buf) + { + char *bp; + for (bp = (char *)buf; bp < (char *)buf + DIRBLKSIZ; bp++) + if (*bp) + goto reclen_problem; + + problem (0, "NULL BLOCK IN DIRECTORY"); + if (preen || reply ("PATCH")) + { + /* Mark this entry free, and return. */ + dp->d_ino = 0; + dp->d_reclen = DIRBLKSIZ; + pfix ("PATCHED"); + return 1; + } + else + return mod; + } + + reclen_problem: problem (1, "BAD RECLEN IN DIRECTORY"); if (reply ("SALVAGE")) { -- cgit v1.2.3 From 8804a7f3e75beee4caf728a45c9b62f1d00ec2e1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 18 Jul 1996 22:34:34 +0000 Subject: Add "com[0-9]". --- devio/MAKEDEV | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devio/MAKEDEV b/devio/MAKEDEV index 1ef7a780..7d13fe3b 100644 --- a/devio/MAKEDEV +++ b/devio/MAKEDEV @@ -24,8 +24,8 @@ for I; do std) $0 console tty null zero fd time ;; - console|tty[0-9]?|tty[0-9a-f]) - st $I root 666 /hurd/term $_CWD/$I device $I;; + console|tty[0-9][0-9a-f]|tty[0-9a-f]|com[0-9]) + st $I root 600 /hurd/term $_CWD/$I device $I;; null) st $I root 666 /hurd/null;; zero) -- cgit v1.2.3 From 3c80bfedb33b6f7e2c6abc8a9f4a0a4643b4fda6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 18 Jul 1996 22:36:06 +0000 Subject: . --- devio/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devio/ChangeLog b/devio/ChangeLog index 98362b44..87520b70 100644 --- a/devio/ChangeLog +++ b/devio/ChangeLog @@ -1,3 +1,7 @@ +Thu Jul 18 18:33:49 1996 Miles Bader + + * MAKEDEV: Add "com[0-9]". + Wed Jul 17 10:00:04 1996 Miles Bader * MAKEDEV (st): New function. -- cgit v1.2.3 From 0e931fd5c853188775bab3679a16f0a3b4ed4021 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 19 Jul 1996 00:13:00 +0000 Subject: (trivfs_S_file_get_storage_info): Fill in the array-length return values. --- devio/io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devio/io.c b/devio/io.c index 1c7a3298..07ae8586 100644 --- a/devio/io.c +++ b/devio/io.c @@ -362,16 +362,20 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, (*ints)[3] = 2; /* num_runs */ (*ints)[4] = strlen (dev->name) + 1; /* name_len */ (*ints)[5] = 0; /* misc_len */ + *num_ints = 6; (*offsets)[0] = 0; (*offsets)[1] = dev->size / dev->dev_block_size; + *num_offsets = 1; strcpy (*data, dev->name); + *data_len = strlen (dev->name) + 1; if (cred->isroot) (*ports)[0] = dev->port; else (*ports)[0] = MACH_PORT_NULL; + *num_ports = 1; *ports_type = MACH_MSG_TYPE_COPY_SEND; } else -- cgit v1.2.3 From b5a8a48ef9b9aba0dd5efc302ae114d1d32a1d05 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 19 Jul 1996 00:13:14 +0000 Subject: . --- devio/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devio/ChangeLog b/devio/ChangeLog index 87520b70..fa826d17 100644 --- a/devio/ChangeLog +++ b/devio/ChangeLog @@ -1,5 +1,8 @@ Thu Jul 18 18:33:49 1996 Miles Bader + * io.c (trivfs_S_file_get_storage_info): Fill in the array-length + return values. + * MAKEDEV: Add "com[0-9]". Wed Jul 17 10:00:04 1996 Miles Bader -- cgit v1.2.3 From 4d5fcfbd2dea8603ef3e8fa3d09299e3513851be Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 19 Jul 1996 19:57:24 +0000 Subject: (trivfs_S_file_get_storage_info): Return correct values for NUM_RUNS and NUM_OFFSETS. --- devio/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devio/io.c b/devio/io.c index 07ae8586..61f655d2 100644 --- a/devio/io.c +++ b/devio/io.c @@ -359,14 +359,14 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred, (*ints)[0] = STORAGE_DEVICE; /* type */ (*ints)[1] = 0; /* flags */ (*ints)[2] = dev->dev_block_size; /* block_size */ - (*ints)[3] = 2; /* num_runs */ + (*ints)[3] = 1; /* num_runs */ (*ints)[4] = strlen (dev->name) + 1; /* name_len */ (*ints)[5] = 0; /* misc_len */ *num_ints = 6; (*offsets)[0] = 0; (*offsets)[1] = dev->size / dev->dev_block_size; - *num_offsets = 1; + *num_offsets = 2; strcpy (*data, dev->name); *data_len = strlen (dev->name) + 1; -- cgit v1.2.3 From 368b200265dc0ee05744eb23cf0ff6dd194a2ac5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 19 Jul 1996 19:57:42 +0000 Subject: . --- devio/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devio/ChangeLog b/devio/ChangeLog index fa826d17..a38f283a 100644 --- a/devio/ChangeLog +++ b/devio/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 19 15:55:27 1996 Miles Bader + + * io.c (trivfs_S_file_get_storage_info): Return correct values for + NUM_RUNS and NUM_OFFSETS. + Thu Jul 18 18:33:49 1996 Miles Bader * io.c (trivfs_S_file_get_storage_info): Fill in the array-length -- cgit v1.2.3 From e8d80f821d71e6fc6c2c6ba319fb155854d22d6e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 20 Jul 1996 15:12:30 +0000 Subject: *** empty log message *** --- SOURCES.0.0 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index a601ee19..7667b68c 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -83,7 +83,12 @@ instructions, after making the indicated minor modifications: [add `strerror' to AC_CHECK_FUNCS in configure.in] * texinfo (3.7) [info/terminal.c -- add `#define B9600 9600'] - +nethack (3.2.1) + [3.2.0 + nethack-3.2.0-3.2.1.patch + define BSD & linux, frob paths in config.h & unixconf.h & root Makefile + comment out declaration of random in system.h + declare `int status' in files.c:decompress_file, and pass &status + as an arg to the call to `wait' in the same function. ] @@ -100,7 +105,7 @@ serverboot mach3-a.out object file format. ] * sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) * make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) -gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] +* gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] @@ -155,10 +160,6 @@ id-utils jacal lily mkisofs -nethack (3.2.1) - [3.2.0 + nethack-3.2.0-3.2.1.patch - define BSD & linux, frob paths in config.h & unixconf.h & root Makefile - comment out declaration of random in system.h] nih classes oaklisp libobjects -- cgit v1.2.3 From de493838b599af601b4eb33841b92188705788d1 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Sat, 20 Jul 1996 19:18:08 +0000 Subject: *** empty log message *** --- SOURCES.0.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 7667b68c..e2d9e4cf 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -5,7 +5,6 @@ STILL TO CATEGORIZE: XXX * gperf (cperf 2.1a) [hacked src/Makefile and src/stderr.c slightly] [substitute with libg++ version?] libc -mach @@ -106,6 +105,7 @@ serverboot * sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) * make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) * gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] +* mach4 (UK22, slighly hacked) -- cgit v1.2.3 From 48ac9a83398c4ef56b6b6c6562df9918cd28132d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 20 Jul 1996 23:55:09 +0000 Subject: . --- SOURCES.0.0 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index e2d9e4cf..1fb5a865 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -65,7 +65,8 @@ instructions, after making the indicated minor modifications: #endif #define setpgrp(a,b) setpgrp() * findutils (4.1) - [Comment out decl of basename in defs.h and defn in util.c] + [Comment out decl of basename in defs.h and defn in util.c + Add `#define ARG_MAX 20480' right after the includes] * gzip (1.2.4) [commented out basename from gzip.h and util.c] * ncurses (1.9.9e) @@ -86,6 +87,7 @@ nethack (3.2.1) [3.2.0 + nethack-3.2.0-3.2.1.patch define BSD & linux, frob paths in config.h & unixconf.h & root Makefile comment out declaration of random in system.h + Use `-lncurses' for WINTTYLIB in src/Makefile declare `int status' in files.c:decompress_file, and pass &status as an arg to the call to `wait' in the same function. ] -- cgit v1.2.3 From aa5d50e224137a28a075b3f3a6760d6397639f88 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 21 Jul 1996 00:54:33 +0000 Subject: . --- SOURCES.0.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 1fb5a865..9a9a0bbf 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -66,7 +66,7 @@ instructions, after making the indicated minor modifications: #define setpgrp(a,b) setpgrp() * findutils (4.1) [Comment out decl of basename in defs.h and defn in util.c - Add `#define ARG_MAX 20480' right after the includes] + Add `#define ARG_MAX 20480' in xargs/xargs.c, right after the includes] * gzip (1.2.4) [commented out basename from gzip.h and util.c] * ncurses (1.9.9e) -- cgit v1.2.3 From a904d903276ac928bd18f33a3fbef1fbb372ac63 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 20:07:04 +0000 Subject: . --- ufs/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 368a2f59..2ccd6c11 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 23 15:58:28 1996 Miles Bader + + * inode.c (write_node, read_disknode): `struct timespec' now uses + a field prefix of `tv_'. + Sat Jul 6 16:14:10 1996 Miles Bader * main.c (ufs_version): Variable removed. -- cgit v1.2.3 From dd7ab33b151f5f710e4a8d41a35a73fb0a771a07 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 20:08:16 +0000 Subject: (write_node, read_disknode): `struct timespec' now uses a field prefix of `tv_'. --- ufs/inode.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index aa2f3a8c..640e6b6f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -240,12 +240,12 @@ read_disknode (struct node *np) st->st_mtimespec = di->di_mtime; st->st_ctimespec = di->di_ctime; #else - st->st_atime = read_disk_entry (di->di_atime.ts_sec); - st->st_atime_usec = read_disk_entry (di->di_atime.ts_nsec) / 1000; - st->st_mtime = read_disk_entry (di->di_mtime.ts_sec); - st->st_mtime_usec = read_disk_entry (di->di_mtime.ts_nsec) / 1000; - st->st_ctime = read_disk_entry (di->di_ctime.ts_sec); - st->st_ctime_usec = read_disk_entry (di->di_ctime.ts_nsec) / 1000; + st->st_atime = read_disk_entry (di->di_atime.tv_sec); + st->st_atime_usec = read_disk_entry (di->di_atime.tv_nsec) / 1000; + st->st_mtime = read_disk_entry (di->di_mtime.tv_sec); + st->st_mtime_usec = read_disk_entry (di->di_mtime.tv_nsec) / 1000; + st->st_ctime = read_disk_entry (di->di_ctime.tv_sec); + st->st_ctime_usec = read_disk_entry (di->di_ctime.tv_nsec) / 1000; #endif st->st_blksize = sblock->fs_bsize; st->st_blocks = read_disk_entry (di->di_blocks); @@ -353,12 +353,12 @@ write_node (struct node *np) di->di_mtime = st->st_mtimespec; di->di_ctime = st->st_ctimespec; #else - write_disk_entry (di->di_atime.ts_sec, st->st_atime); - write_disk_entry (di->di_atime.ts_nsec, st->st_atime_usec * 1000); - write_disk_entry (di->di_mtime.ts_sec, st->st_mtime); - write_disk_entry (di->di_mtime.ts_nsec, st->st_mtime_usec * 1000); - write_disk_entry (di->di_ctime.ts_sec, st->st_ctime); - write_disk_entry (di->di_ctime.ts_nsec, st->st_ctime_usec * 1000); + write_disk_entry (di->di_atime.tv_sec, st->st_atime); + write_disk_entry (di->di_atime.tv_nsec, st->st_atime_usec * 1000); + write_disk_entry (di->di_mtime.tv_sec, st->st_mtime); + write_disk_entry (di->di_mtime.tv_nsec, st->st_mtime_usec * 1000); + write_disk_entry (di->di_ctime.tv_sec, st->st_ctime); + write_disk_entry (di->di_ctime.tv_nsec, st->st_ctime_usec * 1000); #endif write_disk_entry (di->di_blocks, st->st_blocks); write_disk_entry (di->di_flags, st->st_flags); -- cgit v1.2.3 From 28dd72181b35fabd5016b89cf4d19e49fa03b154 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:33:38 +0000 Subject: (allocino): `struct timespec' now uses a field prefix of `tv_'. --- ufs-fsck/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/inode.c b/ufs-fsck/inode.c index 7c81f39a..df4b880e 100644 --- a/ufs-fsck/inode.c +++ b/ufs-fsck/inode.c @@ -147,8 +147,8 @@ allocino (ino_t request, mode_t mode) dino.di_modeh = (mode & 0xffff0000) >> 16; dino.di_model = (mode & 0x0000ffff); gettimeofday (&tv, 0); - dino.di_atime.ts_sec = tv.tv_sec; - dino.di_atime.ts_nsec = tv.tv_usec * 1000; + dino.di_atime.tv_sec = tv.tv_sec; + dino.di_atime.tv_nsec = tv.tv_usec * 1000; dino.di_mtime = dino.di_ctime = dino.di_atime; dino.di_size = 0; dino.di_blocks = 0; -- cgit v1.2.3 From 003a2be618cbd0f4ca6e08aec735ebdb65f7c751 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:34:07 +0000 Subject: (pinode): `struct timespec' now uses a field prefix of `tv_'. --- ufs-fsck/utilities.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 34da1e3d..4c515f61 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -373,7 +373,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) pextend (" M=0%o", DI_MODE (&dino)); pextend (" SZ=%llu", dino.di_size); - p = ctime (&dino.di_mtime.ts_sec); + p = ctime (&dino.di_mtime.tv_sec); pextend (" MT=%12.12s %4.4s", &p[4], &p[20]); } -- cgit v1.2.3 From 8196e6da612bf543c0969d4a737f42d31250ff02 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:34:17 +0000 Subject: . --- ufs-fsck/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index cebead0c..8fcde4b2 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,9 @@ +Tue Jul 23 19:32:09 1996 Miles Bader + + * inode.c (allocino): `struct timespec' now uses a field prefix + of `tv_'. + * utilities.c (pinode): Likewise. + Thu Jul 18 14:55:14 1996 Michael I. Bushnell, p/BSG * pass2.c (pass2): If an entire directory block is null, allow -- cgit v1.2.3 From 171c541e8ad43741fb06f3cc35c88feea3075c5a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:37:21 +0000 Subject: (fsinit): `struct timespec' now uses a field prefix of `tv_'. --- ufs-utils/mkfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 37c34ac3..43093b9b 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.12 1996/07/07 01:14:44 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.13 1996/07/23 23:37:21 miles Exp $"; #endif /* not lint */ #include @@ -1122,9 +1122,9 @@ fsinit(utime) /* * initialize the node */ - node.di_atime.ts_sec = utime; - node.di_mtime.ts_sec = utime; - node.di_ctime.ts_sec = utime; + node.di_atime.tv_sec = utime; + node.di_mtime.tv_sec = utime; + node.di_ctime.tv_sec = utime; #ifdef LOSTDIR /* * create the lost+found directory -- cgit v1.2.3 From f85c152b29aa3a157ebe433bbf5aa961f0eb2883 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:39:56 +0000 Subject: (timespec_rep): `struct timespec' now uses a field prefix of `tv_'. --- ufs-utils/stati.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs-utils/stati.c b/ufs-utils/stati.c index 699d8f5c..2c0147d0 100644 --- a/ufs-utils/stati.c +++ b/ufs-utils/stati.c @@ -110,16 +110,16 @@ timespec_rep (struct timespec *ts) { static char buf[200]; char *p = buf; - if (ts->ts_sec || ts->ts_nsec) + if (ts->tv_sec || ts->tv_nsec) { - time_t time = ts->ts_sec; + time_t time = ts->tv_sec; strcpy (buf, ctime (&time)); p += strlen (buf); if (p[-1] == '\n') p--; *p++ = ' '; } - snprintf (p, buf + sizeof buf - p, "[%ld, %ld]", ts->ts_sec, ts->ts_nsec); + snprintf (p, buf + sizeof buf - p, "[%ld, %ld]", ts->tv_sec, ts->tv_nsec); return buf; } -- cgit v1.2.3 From 1840855d2e36a40b357197c6fa25cb62e5e5048c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 23 Jul 1996 23:40:07 +0000 Subject: . --- ufs-utils/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index d6d58f5d..9883880d 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 23 19:34:58 1996 Miles Bader + + * mkfs.c (fsinit): `struct timespec' now uses a field prefix of `tv_'. + * stati.c (timespec_rep): Likewise. + Fri Jun 21 02:12:16 1996 Miles Bader * dlabel.c (fd_get_device): Supply new args to store_create. -- cgit v1.2.3 From f2b93ae28eb21069c71c6ff12f094704f3517eb3 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 07:05:01 +0000 Subject: . --- SOURCES.0.0 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 9a9a0bbf..387addbd 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -1,5 +1,9 @@ Sources for binaries in Hurd version 0.0. +Key: +* = Native-compiled version installed in hurdinst ++ = Relinked to get libc.0.0 + STILL TO CATEGORIZE: XXX * fileutils (3.13) [rebuild for df after libc install] * gperf (cperf 2.1a) [hacked src/Makefile and src/stderr.c slightly] @@ -12,17 +16,17 @@ The following packages were built from the sources of the indicated version in ftp://prep.gnu.ai.edu/pub.gnu according to the provided instructions without modification: -* autoconf (2.10) -* automake (1.0) -* bc (1.03) -* binutils (2.7) -* bison (1.25) -* cpio (2.4.2) -* cvs (1.8.1, in cvs-1.8.tar.gz) -* diffutils (2.7) -* doschk (1.1) -* ed (0.2) -* emacs lisp manual (19-2.4) +*+ autoconf (2.10) +*+ automake (1.0) +*+ bc (1.03) +*+ binutils (2.7) +*+ bison (1.25) +*+ cpio (2.4.2) +*+ cvs (1.8.1, in cvs-1.8.tar.gz) +*+ diffutils (2.7) +*+ doschk (1.1) +*+ ed (0.2) +*+ emacs lisp manual (19-2.4) * flex (2.5.3) * gawk (3.0.0) * gcal (1.01) @@ -32,7 +36,7 @@ instructions without modification: * gmp (2.0.2) * grep (2.0) * hello (1.3) -hurd (0.0) ++ hurd (0.0) * indent (1.9.1) * inetutils (1.0) * less (320) @@ -83,7 +87,7 @@ instructions, after making the indicated minor modifications: [add `strerror' to AC_CHECK_FUNCS in configure.in] * texinfo (3.7) [info/terminal.c -- add `#define B9600 9600'] -nethack (3.2.1) +* nethack (3.2.1) [3.2.0 + nethack-3.2.0-3.2.1.patch define BSD & linux, frob paths in config.h & unixconf.h & root Makefile comment out declaration of random in system.h @@ -106,7 +110,7 @@ serverboot mach3-a.out object file format. ] * sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) * make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) -* gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] +*+ gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] * mach4 (UK22, slighly hacked) -- cgit v1.2.3 From 147782cc4ac2266fc7ff5adf4f8edf084a164ec1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 15:25:30 +0000 Subject: . --- SOURCES.0.0 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 387addbd..b1b6fc20 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -27,10 +27,10 @@ instructions without modification: *+ doschk (1.1) *+ ed (0.2) *+ emacs lisp manual (19-2.4) -* flex (2.5.3) -* gawk (3.0.0) -* gcal (1.01) -* gcc (2.7.2) +*+ flex (2.5.3) +*+ gawk (3.0.0) +*+ gcal (1.01) +*+ gcc (2.7.2) * gdbm (1.7.3) * gettext (0.10) * gmp (2.0.2) -- cgit v1.2.3 From 58018431e8ef2a7e30014397dfb353303d7344fa Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 16:54:16 +0000 Subject: . --- SOURCES.0.0 | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index b1b6fc20..75e1516f 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -31,28 +31,28 @@ instructions without modification: *+ gawk (3.0.0) *+ gcal (1.01) *+ gcc (2.7.2) -* gdbm (1.7.3) -* gettext (0.10) -* gmp (2.0.2) -* grep (2.0) -* hello (1.3) -+ hurd (0.0) -* indent (1.9.1) -* inetutils (1.0) -* less (320) -* m4 (1.4) -* miscfiles (1.0) -* nvi (1.71) -* ptx (0.4) -* readline (2.0) -* recode (3.4) -* sed (2.05) -* sharutils (4.2) -* termcap (1.3) [manual only] -* termutils (2.0) -* textutils (1.19) -* time (1.7) -* wdiff (0.5) +*+ gdbm (1.7.3) +*+ gettext (0.10) +*+ gmp (2.0.2) +*+ grep (2.0) +*+ hello (1.3) + + hurd (0.0) +*+ indent (1.9.1) +* inetutils (1.0) +*+ less (320) +*+ m4 (1.4) +*+ miscfiles (1.0) +*+ nvi (1.71) +*+ ptx (0.4) +*+ readline (2.0) +*+ recode (3.4) +*+ sed (2.05) +*+ sharutils (4.2) +* termcap (1.3) [manual only] +*+ termutils (2.0) +*+ textutils (1.19) +*+ time (1.7) +*+ wdiff (0.5) @@ -60,7 +60,7 @@ The following packages were built from the sources of the indicated version in ftp://prep.gnu.ai.mit.edu/pub/gnu according to the provided instructions, after making the indicated minor modifications: -* emacs (19.31) +*+ emacs (19.31) [comment out definition of tparam in src/terminfo.c.] [add to src/s/gnu.h the following five lines] #ifdef HAVE_LIBNCURSES @@ -87,7 +87,7 @@ instructions, after making the indicated minor modifications: [add `strerror' to AC_CHECK_FUNCS in configure.in] * texinfo (3.7) [info/terminal.c -- add `#define B9600 9600'] -* nethack (3.2.1) +*+ nethack (3.2.1) [3.2.0 + nethack-3.2.0-3.2.1.patch define BSD & linux, frob paths in config.h & unixconf.h & root Makefile comment out declaration of random in system.h -- cgit v1.2.3 From 5821b3a5fb9ad31898dc42b450c277cec0ad4de8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 17:27:45 +0000 Subject: . --- SOURCES.0.0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 75e1516f..842c2335 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -68,10 +68,10 @@ instructions, after making the indicated minor modifications: #define LIBS_TERMCAP -lncurses #endif #define setpgrp(a,b) setpgrp() -* findutils (4.1) +*+ findutils (4.1) [Comment out decl of basename in defs.h and defn in util.c Add `#define ARG_MAX 20480' in xargs/xargs.c, right after the includes] -* gzip (1.2.4) +*+ gzip (1.2.4) [commented out basename from gzip.h and util.c] * ncurses (1.9.9e) [In read_entry.c, change second arg of call to open from `0' to O_RDONLY] -- cgit v1.2.3 From 78944e39c7fd8e4924222fb3fdfea711d52e4395 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 18:02:42 +0000 Subject: . --- SOURCES.0.0 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 842c2335..dcab36e2 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -73,19 +73,19 @@ instructions, after making the indicated minor modifications: Add `#define ARG_MAX 20480' in xargs/xargs.c, right after the includes] *+ gzip (1.2.4) [commented out basename from gzip.h and util.c] -* ncurses (1.9.9e) +*+ ncurses (1.9.9e) [In read_entry.c, change second arg of call to open from `0' to O_RDONLY] [In lib_tparm.c:tparam, add the following before the call to tparam_internal] if (!buffer) buffer = malloc (256); -* patch (2.1) +*+ patch (2.1) [comment out basename in backupfile.c.] -* rcs (5.7) +*+ rcs (5.7) [Put `#undef ED' before #define ED in conf.h.] [Add `#define SYMLOOP_MAX 8' to conf.h.] -* tar (1.11.8) +*+ tar (1.11.8) [add `strerror' to AC_CHECK_FUNCS in configure.in] -* texinfo (3.7) +*+ texinfo (3.7) [info/terminal.c -- add `#define B9600 9600'] *+ nethack (3.2.1) [3.2.0 + nethack-3.2.0-3.2.1.patch -- cgit v1.2.3 From f02f3f9d72ef4c31727b05e80843b60ac0a42a46 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 29 Jul 1996 18:15:48 +0000 Subject: . --- SOURCES.0.0 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index dcab36e2..930c1944 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -103,13 +103,13 @@ ftp://prep.gnu.ai.mit.edu/pub/gnu/gnu-0.0/hurd-special-src: * bash (1.14.4 patchlevel 10, with some additional local bugfixes) e2fsprogs (e2fsprogs-0.5c-hurd1.tar.gz) [1.04 doesn't have hurd patches] serverboot -* from +*+ from (*) grub [ Requires changes for ELF: avoid generating 16-bit relocations. Requires other changes to deal with ELF; makefiles only work for mach3-a.out object file format. ] -* sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) -* make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) +*+ sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) +*+ make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified) *+ gdb (Modified from Cygnus snapshot of 960526) [wait for Mach to get migcom] * mach4 (UK22, slighly hacked) -- cgit v1.2.3 From 3b2dc769268932089dfaa758785f17136318e20b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 31 Jul 1996 00:35:40 +0000 Subject: Update inetutils to 1.1. --- SOURCES.0.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 930c1944..a7a3da57 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -38,7 +38,7 @@ instructions without modification: *+ hello (1.3) + hurd (0.0) *+ indent (1.9.1) -* inetutils (1.0) +*+ inetutils (1.1) *+ less (320) *+ m4 (1.4) *+ miscfiles (1.0) -- cgit v1.2.3 From 65039f15a23900595cb0fc1120d6ae804c4a6c88 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 1 Aug 1996 19:51:07 +0000 Subject: . --- SOURCES.0.0 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index a7a3da57..3ad593b3 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -108,7 +108,8 @@ serverboot [ Requires changes for ELF: avoid generating 16-bit relocations. Requires other changes to deal with ELF; makefiles only work for mach3-a.out object file format. ] -*+ sh-utils (1.12m from alpha.gnu.ai.mit.edu; unmodified) +*+ 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) [wait for Mach to get migcom] * mach4 (UK22, slighly hacked) -- cgit v1.2.3 From 249eca952d03dfaaa3c745810e149e19cf63501c Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 1 Aug 1996 20:18:45 +0000 Subject: *** empty log message *** --- SOURCES.0.0 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/SOURCES.0.0 b/SOURCES.0.0 index 3ad593b3..d4b115ba 100644 --- a/SOURCES.0.0 +++ b/SOURCES.0.0 @@ -5,9 +5,6 @@ Key: + = Relinked to get libc.0.0 STILL TO CATEGORIZE: XXX -* fileutils (3.13) [rebuild for df after libc install] -* gperf (cperf 2.1a) [hacked src/Makefile and src/stderr.c slightly] - [substitute with libg++ version?] libc @@ -27,6 +24,7 @@ instructions without modification: *+ doschk (1.1) *+ ed (0.2) *+ emacs lisp manual (19-2.4) +*+ fileutils (3.13) *+ flex (2.5.3) *+ gawk (3.0.0) *+ gcal (1.01) @@ -48,7 +46,7 @@ instructions without modification: *+ recode (3.4) *+ sed (2.05) *+ sharutils (4.2) -* termcap (1.3) [manual only] +*+ termcap (1.3) [manual only] *+ termutils (2.0) *+ textutils (1.19) *+ time (1.7) @@ -71,6 +69,8 @@ instructions, after making the indicated minor modifications: *+ findutils (4.1) [Comment out decl of basename in defs.h and defn in util.c Add `#define ARG_MAX 20480' in xargs/xargs.c, right after the includes] +*+ gperf (cperf 2.1a) + [hacked src/Makefile and src/stderr.c slightly] *+ gzip (1.2.4) [commented out basename from gzip.h and util.c] *+ ncurses (1.9.9e) @@ -100,9 +100,12 @@ instructions, after making the indicated minor modifications: The following were compiled from the sources found in ftp://prep.gnu.ai.mit.edu/pub/gnu/gnu-0.0/hurd-special-src: -* bash (1.14.4 patchlevel 10, with some additional local bugfixes) -e2fsprogs (e2fsprogs-0.5c-hurd1.tar.gz) [1.04 doesn't have hurd patches] -serverboot +*+ bash (1.14.4 patchlevel 10, with some additional local bugfixes) +*+ e2fsprogs (e2fsprogs-0.5c-hurd1.tar.gz) [1.04 doesn't have hurd patches] +*+ serverboot (serverboot.tar.gz) + [ Unpack into the mach4 source directory, and rename it to be `bootstrap'; + you won't need the existing mach4 bootstrap. Then build in the bootstrap + subdir of the build directory, and install as /boot/serverboot. ] *+ from (*) grub [ Requires changes for ELF: avoid generating 16-bit relocations. -- cgit v1.2.3 From a1682a2df9be303a47e351aeb693499d3a79b954 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 2 Aug 1996 15:16:18 +0000 Subject: *** empty log message *** --- SOURCES.0.0 | 207 ------------------------------------------------------------ 1 file changed, 207 deletions(-) delete mode 100644 SOURCES.0.0 diff --git a/SOURCES.0.0 b/SOURCES.0.0 deleted file mode 100644 index d4b115ba..00000000 --- a/SOURCES.0.0 +++ /dev/null @@ -1,207 +0,0 @@ -Sources for binaries in Hurd version 0.0. - -Key: -* = Native-compiled version installed in hurdinst -+ = Relinked to get libc.0.0 - -STILL TO CATEGORIZE: XXX -libc - - - -The following packages were built from the sources of the indicated -version in ftp://prep.gnu.ai.edu/pub.gnu according to the provided -instructions without modification: - -*+ autoconf (2.10) -*+ automake (1.0) -*+ bc (1.03) -*+ binutils (2.7) -*+ bison (1.25) -*+ cpio (2.4.2) -*+ cvs (1.8.1, in cvs-1.8.tar.gz) -*+ diffutils (2.7) -*+ doschk (1.1) -*+ ed (0.2) -*+ emacs lisp manual (19-2.4) -*+ fileutils (3.13) -*+ flex (2.5.3) -*+ gawk (3.0.0) -*+ gcal (1.01) -*+ gcc (2.7.2) -*+ gdbm (1.7.3) -*+ gettext (0.10) -*+ gmp (2.0.2) -*+ grep (2.0) -*+ hello (1.3) - + hurd (0.0) -*+ indent (1.9.1) -*+ inetutils (1.1) -*+ less (320) -*+ m4 (1.4) -*+ miscfiles (1.0) -*+ nvi (1.71) -*+ ptx (0.4) -*+ readline (2.0) -*+ recode (3.4) -*+ sed (2.05) -*+ sharutils (4.2) -*+ termcap (1.3) [manual only] -*+ termutils (2.0) -*+ textutils (1.19) -*+ time (1.7) -*+ wdiff (0.5) - - - -The following packages were built from the sources of the indicated -version in ftp://prep.gnu.ai.mit.edu/pub/gnu according to the provided -instructions, after making the indicated minor modifications: - -*+ emacs (19.31) - [comment out definition of tparam in src/terminfo.c.] - [add to src/s/gnu.h the following five lines] - #ifdef HAVE_LIBNCURSES - #define TERMINFO - #define LIBS_TERMCAP -lncurses - #endif - #define setpgrp(a,b) setpgrp() -*+ findutils (4.1) - [Comment out decl of basename in defs.h and defn in util.c - Add `#define ARG_MAX 20480' in xargs/xargs.c, right after the includes] -*+ gperf (cperf 2.1a) - [hacked src/Makefile and src/stderr.c slightly] -*+ gzip (1.2.4) - [commented out basename from gzip.h and util.c] -*+ ncurses (1.9.9e) - [In read_entry.c, change second arg of call to open from `0' to O_RDONLY] - [In lib_tparm.c:tparam, add the following before the call to tparam_internal] - if (!buffer) - buffer = malloc (256); -*+ patch (2.1) - [comment out basename in backupfile.c.] -*+ rcs (5.7) - [Put `#undef ED' before #define ED in conf.h.] - [Add `#define SYMLOOP_MAX 8' to conf.h.] -*+ tar (1.11.8) - [add `strerror' to AC_CHECK_FUNCS in configure.in] -*+ texinfo (3.7) - [info/terminal.c -- add `#define B9600 9600'] -*+ nethack (3.2.1) - [3.2.0 + nethack-3.2.0-3.2.1.patch - define BSD & linux, frob paths in config.h & unixconf.h & root Makefile - comment out declaration of random in system.h - Use `-lncurses' for WINTTYLIB in src/Makefile - declare `int status' in files.c:decompress_file, and pass &status - as an arg to the call to `wait' in the same function. ] - - - -The following were compiled from the sources found in -ftp://prep.gnu.ai.mit.edu/pub/gnu/gnu-0.0/hurd-special-src: - -*+ bash (1.14.4 patchlevel 10, with some additional local bugfixes) -*+ e2fsprogs (e2fsprogs-0.5c-hurd1.tar.gz) [1.04 doesn't have hurd patches] -*+ serverboot (serverboot.tar.gz) - [ Unpack into the mach4 source directory, and rename it to be `bootstrap'; - you won't need the existing mach4 bootstrap. Then build in the bootstrap - subdir of the build directory, and install as /boot/serverboot. ] -*+ from -(*) grub - [ Requires changes for ELF: avoid generating 16-bit relocations. - Requires other changes to deal with ELF; makefiles only work for - mach3-a.out object file format. ] -*+ 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) [wait for Mach to get migcom] -* mach4 (UK22, slighly hacked) - - - - - -Give up: -finger (1.37) -mtools (3.0) [comment out decl of sys_errlist in sysincludes.h.] - [Uses of MAXPATHLEN] -oleo (1.6) [utterly fails to build] -gnuplot (3.5) [has old old version of readline] -es (0.84 from ftp.white.toronto.edu) - (-DEVFD=1 -DGETGROUPS_USES_GID_T=1 -DREADLINE=1 - -DUSE_SIGACTION=1 -DUSE_SIG_ATOMIC_T=1) - [ Errors for longjmp in access.c and parse errors besides] -regex (0.12) [Expects TeX to be present] -screen (3.7.1) [Wants utmpx.h]?? -ispell (3.1.20) [hacked for bison; builds zero-length dictionary] -rx (1.0) [ wants `tsort' to configure ] -perl (5.003) [configure script fails in shlib frobnication] - - -Secondary: -* from (from.tar.gz) -X libraries -X utilities -TeX -METAFONT -libg++ -calc -chess -clisp -csh -dld -gcl -dejagnu -elib -elisp archive -f2c -ffcall -g77 -fontutils -ghostscript -ghostview -git -gnugo -graphics -groff -hp2xx -hyperbole -id-utils -jacal -lily -mkisofs -nih classes -oaklisp -libobjects -mm -obst -octave - [See ftp://ftp.che.wisc.edu/pub/octave/README-GCC-2.7.0] - [See ftp://ftp.che.wisc.edu/pub/octave/README-GCC-2.7.1] -p2c -pcl -pine -rc -scheme -shogi -sipp -smalltalk -sneps -superopt -tile forth -ucblogo -uucp -vh -vm -xboard -xinfo -xshogi - - -Tertiary: -X server -ae -cfengine -enscript -gnat -mc -- cgit v1.2.3 From 23f405001b6d3dff8607115c5d731126c54f4b9e Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 7 Aug 1996 19:03:53 +0000 Subject: *** empty log message *** --- ufs/ChangeLog | 13 +++++++ ufs/inode.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 2ccd6c11..c541523e 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,16 @@ +Wed Aug 7 13:00:30 1996 Thomas Bushnell, n/BSG + + * inode.c (struct ufs_fhandle): Layout filehandle more like Unixy + NFSD. + (diskfs_S_file_getfh): Bother to clear unused parts of a + file handle so that they always compare equal. + +Tue Aug 6 12:19:38 1996 Thomas Bushnell, n/BSG + + * inode.c: Include . + (struct ufs_fhandle): New type. + (diskfs_S_fsys_getfile, diskfs_S_file_getfh): New functions. + Tue Jul 23 15:58:28 1996 Miles Bader * inode.c (write_node, read_disknode): `struct timespec' now uses diff --git a/ufs/inode.c b/ufs/inode.c index 640e6b6f..27f7c3bb 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -20,6 +20,7 @@ #include #include #include +#include #define INOHSZ 512 #if ((INOHSZ&(INOHSZ-1)) == 0) @@ -723,4 +724,125 @@ diskfs_S_file_get_storage_info (struct protid *cred, return 0; } +/* Must be exactly 28 bytes long */ +struct ufs_fhandle +{ + int filler1; + ino_t inum; + long gen; + int filler2[4]; +}; + +/* Return an NFS file handle */ + +error_t +diskfs_S_file_getfh (struct protid *cred, + char **fh, + u_int *fh_len) +{ + struct node *np; + error_t err; + struct ufs_fhandle *f; + + if (!cred) + return EOPNOTSUPP; + + if (!diskfs_isuid (0, cred)) + return EPERM; + + np = cred->po->np; + + mutex_lock (&np->lock); + + if (*fh_len < sizeof (struct ufs_fhandle)) + vm_allocate (mach_task_self (), (vm_address_t *) fh, + sizeof (struct ufs_fhandle), 1); + *fh_len = sizeof (struct ufs_fhandle); + + f = (struct ufs_fhandle *) *fh; + f->inum = np->dn->number; + f->gen = np->dn_stat.st_gen; + f->filler1 = 0; + f->filler2[0] = f->filler2[1] = f->filler2[2] = f->filler2[3] = 0; + mutex_unlock (&np->lock); + return 0; +} + +/* Lookup an NFS file handle */ +error_t +diskfs_S_fsys_getfile (mach_port_t fsys, + mach_port_t reply, + mach_msg_type_name_t replytype, + uid_t *uids, + u_int nuids, + uid_t *gids, + u_int ngids, + char *handle, + u_int handlelen, + mach_port_t *file, + mach_msg_type_name_t *filetype) +{ + struct port_info *pt = ports_lookup_port (diskfs_port_bucket, fsys, + diskfs_control_class); + struct node *np; + struct ufs_fhandle *f; + error_t err; + int flags; + struct protid fakecred, *newpi; + + if (!pt) + return EOPNOTSUPP; + + if (handlelen != sizeof (struct ufs_fhandle)) + { + ports_port_deref (pt); + return EINVAL; + } + + f = (struct ufs_fhandle *) handle; + + err = diskfs_cached_lookup (f->inum, &np); + if (err) + { + ports_port_deref (pt); + return err; + } + + if (np->dn_stat.st_gen != f->gen) + { + diskfs_nput (np); + ports_port_deref (pt); + return ESTALE; + } + + /* This call should have a flags arg, but until then... */ + fakecred.uids = uids; + fakecred.gids = gids; + fakecred.nuids = nuids; + fakecred.ngids = ngids; + + flags = 0; + if (!diskfs_access (np, S_IREAD, &fakecred)) + flags |= O_READ; + if (!diskfs_access (np, S_IEXEC, &fakecred)) + flags |= O_EXEC; + if (!diskfs_access (np, S_IWRITE, &fakecred) + && !S_ISDIR (np->dn_stat.st_mode) + && !diskfs_check_readonly ()) + flags |= O_WRITE; + + err = diskfs_create_protid (diskfs_make_peropen (np, flags, MACH_PORT_NULL), + uids, nuids, gids, ngids, &newpi); + + diskfs_nput (np); + ports_port_deref (pt); + + if (!err) + { + *file = ports_get_right (newpi); + *filetype = MACH_MSG_TYPE_MAKE_SEND; + } + return err; +} + -- cgit v1.2.3 From 0512f4f1bf65799408fcb0df596d5226f95b9445 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 8 Aug 1996 18:54:36 +0000 Subject: *** empty log message *** --- configure.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 01c41005..1492baca 100644 --- a/configure.in +++ b/configure.in @@ -1,10 +1,13 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.5 1996/05/01 02:19:03 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.6 1996/08/08 18:54:32 thomas Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local. +test "x$install_prefix" = xNONE && install_prefix='$prefix' +AC_SUBST(install_prefix) + AC_CANONICAL_HOST case "$host_os" in gnu*) ;; -- cgit v1.2.3 From 9bcf73b12b79ee9c321a27338677942f6faa05d5 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 12 Aug 1996 18:31:04 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 4 ++++ ufs-fsck/Makefile | 2 +- ufs/ChangeLog | 11 +++++++++ ufs/devio.c | 70 ------------------------------------------------------ ufs/hyper.c | 25 ++++++++++++------- ufs/inode.c | 4 ++-- 6 files changed, 34 insertions(+), 82 deletions(-) delete mode 100644 ufs/devio.c diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 8fcde4b2..615e6458 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 12 11:39:12 1996 Thomas Bushnell, n/BSG + + * Makefile (dir): Now ufs-fsck. + Tue Jul 23 19:32:09 1996 Miles Bader * inode.c (allocino): `struct timespec' now uses a field prefix diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index f68fe52a..8725de8e 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -dir := fsck +dir := ufs-fsck makemode := utility SRCS = dir.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ diff --git a/ufs/ChangeLog b/ufs/ChangeLog index c541523e..2b964cf9 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,5 +1,16 @@ +Mon Aug 12 13:43:46 1996 Thomas Bushnell, n/BSG + + * hyper.c (diskfs_set_hypermetadata): Bother to return 0 at end of + function. + Wed Aug 7 13:00:30 1996 Thomas Bushnell, n/BSG + * inode.c (diskfs_set_statfs): Compute st->f_blocks correctly; set + bsize to be fs_fsize, not fs_bsize. + + * hyper.c (diskfs_set_hypermetadata): Return an error as + appropriate. + * inode.c (struct ufs_fhandle): Layout filehandle more like Unixy NFSD. (diskfs_S_file_getfh): Bother to clear unused parts of a diff --git a/ufs/devio.c b/ufs/devio.c deleted file mode 100644 index 2e5cc332..00000000 --- a/ufs/devio.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Device input and output - Copyright (C) 1992, 1993, 1994 Free Software Foundation - -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. */ - -/* Written by Michael I. Bushnell. */ - -#include "ufs.h" -#include -#include - -/* Write disk block ADDR with DATA of LEN bytes, waiting for completion. */ -error_t -dev_write_sync (daddr_t addr, - vm_address_t data, - long len) -{ - int foo; - assert (!diskfs_readonly); - if (device_write (ufs_device, 0, addr, (io_buf_ptr_t) data, len, &foo) - || foo != len) - return EIO; - return 0; -} - -/* Write diskblock ADDR with DATA of LEN bytes; don't bother waiting - for completion. */ -error_t -dev_write (daddr_t addr, - vm_address_t data, - long len) -{ - assert (!diskfs_readonly); - if (device_write_request (ufs_device, MACH_PORT_NULL, 0, addr, - (io_buf_ptr_t) data, len)) - return EIO; - return 0; -} - -static int deverr; - -/* Read disk block ADDR; put the address of the data in DATA; read LEN - bytes. Always *DATA should be a full page no matter what. */ -error_t -dev_read_sync (daddr_t addr, - vm_address_t *data, - long len) -{ - int foo; - deverr = device_read (ufs_device, 0, addr, len, (io_buf_ptr_t *)data, - (u_int *)&foo); - if (deverr || foo != len) - return EIO; - return 0; -} - diff --git a/ufs/hyper.c b/ufs/hyper.c index e4f58249..cb644797 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -276,7 +276,7 @@ get_hypermetadata (void) taken from ordinary data blocks and might not be an even number of pages; in that case writing it through the pager would nuke whatever pages came after it on the disk and were backed by file pagers. */ -void +error_t diskfs_set_hypermetadata (int wait, int clean) { vm_address_t buf; @@ -294,16 +294,22 @@ diskfs_set_hypermetadata (int wait, int clean) err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), &buf, bufsize); - if (!err) + if (err) + return err; + + bcopy (csum, (void *) buf, sblock->fs_cssize); + if (swab_disk) + swab_csums ((struct csum *)buf); + err = diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), + buf, bufsize); + vm_deallocate (mach_task_self (), buf, bufsize); + + if (err) { - bcopy (csum, (void *) buf, sblock->fs_cssize); - if (swab_disk) - swab_csums ((struct csum *)buf); - diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), - buf, bufsize); - csum_dirty = 0; - vm_deallocate (mach_task_self (), buf, bufsize); + spin_unlock (&alloclock); + return err; } + csum_dirty = 0; } if (clean && ufs_clean && !sblock->fs_clean) @@ -326,6 +332,7 @@ diskfs_set_hypermetadata (int wait, int clean) copy_sblock (); sync_disk (wait); + return 0; } /* Copy the sblock into the disk */ diff --git a/ufs/inode.c b/ufs/inode.c index 27f7c3bb..ae323a8c 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -498,8 +498,8 @@ error_t diskfs_set_statfs (struct statfs *st) { st->f_type = FSTYPE_UFS; - st->f_bsize = sblock->fs_bsize; - st->f_blocks = sblock->fs_dsize * sblock->fs_frag; + st->f_bsize = sblock->fs_fsize; + st->f_blocks = sblock->fs_dsize; st->f_bfree = (sblock->fs_cstotal.cs_nbfree * sblock->fs_frag + sblock->fs_cstotal.cs_nffree); st->f_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) -- cgit v1.2.3 From 94d2a5e5906e540b5bf72211772f10a4ea3a5744 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 13 Aug 1996 18:10:31 +0000 Subject: *** empty log message *** --- configure.in | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 1492baca..2546be9b 100644 --- a/configure.in +++ b/configure.in @@ -1,13 +1,10 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.6 1996/08/08 18:54:32 thomas Exp $]) +AC_REVISION([$Id: configure.in,v 1.7 1996/08/13 18:10:06 thomas Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local. -test "x$install_prefix" = xNONE && install_prefix='$prefix' -AC_SUBST(install_prefix) - AC_CANONICAL_HOST case "$host_os" in gnu*) ;; -- cgit v1.2.3 From 90d17ea4884b272cdc59748eef5024e2c4e7b69a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 16 Aug 1996 14:32:55 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 8 ++++++++ ufs-fsck/dir.c | 2 +- ufs-fsck/pass2.c | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 615e6458..c8def0d7 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,11 @@ +Fri Aug 16 10:25:37 1996 Thomas Bushnell, n/BSG + + * dir.c (record_directory): Maximum number of block pointers to + record is NDADDR + NIADDR, not NDADDR * NIADDR. + * pass2.c: Include . + (pass2): Before copying block addresses to DINO in basic + integrity check, assert that DNP->i_numblks isn't too big. + Mon Aug 12 11:39:12 1996 Thomas Bushnell, n/BSG * Makefile (dir): Now ufs-fsck. diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index d4f05858..b058fe9e 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -31,7 +31,7 @@ record_directory (struct dinode *dp, ino_t number) blks = howmany (dp->di_size, sblock->fs_bsize); if (blks > NDADDR) - blks = NDADDR * NIADDR; + blks = NDADDR + NIADDR; blks *= sizeof (daddr_t); dnp = malloc (sizeof (struct dirinfo) + blks); diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index db63abd7..a2d5996c 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "fsck.h" +#include /* Verify root inode's allocation and check all directories for viability. Set DIRSORTED array fully and check to make sure @@ -307,6 +308,7 @@ pass2 () } bzero (&dino, sizeof (struct dinode)); dino.di_size = dnp->i_isize; + assert (dnp->i_numblks <= (NDADDR + NIADDR) * sizeof (daddr_t)); bcopy (dnp->i_blks, dino.di_db, dnp->i_numblks); datablocks_iterate (&dino, checkdirblock); -- cgit v1.2.3 From 6fb92de89d398e0b69da4251fcd67b203a3f887d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 27 Aug 1996 18:24:17 +0000 Subject: . --- ufs-utils/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 9883880d..201a2958 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 19 15:18:30 1996 Miles Bader + + * mkfs.c (doc): Supply a useful value. + Tue Jul 23 19:34:58 1996 Miles Bader * mkfs.c (fsinit): `struct timespec' now uses a field prefix of `tv_'. -- cgit v1.2.3 From e2b96cec147bc4258e019bb3f16d6ca9d03234ab Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 27 Aug 1996 18:24:31 +0000 Subject: (doc): Supply a useful value. --- ufs-utils/mkfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 43093b9b..48a5a688 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.13 1996/07/23 23:37:21 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.14 1996/08/27 18:24:31 miles Exp $"; #endif /* not lint */ #include @@ -219,7 +219,7 @@ static const struct argp_option options[] = { {0, 0} }; static char *args_doc = "DEVICE"; -static char *doc = 0; +static char *doc = "Write a ufs filesystem image onto DEVICE."; struct amark { void *addr; struct amark *next; }; -- cgit v1.2.3 From 2729a2406f00c668611d0151b142d97d3607e599 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 29 Aug 1996 20:14:18 +0000 Subject: *** empty log message *** --- ufs/ChangeLog | 21 +++++++++++++++++++++ ufs/dir.c | 53 +++++++++++++++++++++++++++++++++++++++++------------ ufs/inode.c | 1 + ufs/ufs.h | 2 ++ 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 2b964cf9..934c9856 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,24 @@ +Thu Aug 29 16:07:07 1996 Thomas Bushnell, n/BSG + + * dir.c (diskfs_lookup_hard): When setting ds->stat to EXTEND, set + ds->idx by looking at the size of the file. (IDX itself is no + longer at the end because of the change on Aug 16 1996.) + +Wed Aug 28 12:15:15 1996 Thomas Bushnell, n/BSG + + * dir.c (dirscanblock): Size dirents correctly when mallocing it. + (diskfs_direnter_hard): Be more careful when sizing or resizing + dirents. Correctly set to -1 all the new entries we create after + realloc call. + +Fri Aug 16 18:51:31 1996 Thomas Bushnell, n/BSG + + * ufs.h (struct disknode): New member `dir_idx'. + * inode.c (diskfs_cached_lookup): Initialize DN->dir_idx. + * dir.c (diskfs_lookup_hard): After successful dirscanblock, + record index where we finished in DP->dn->dir_idx. Start searches + at that index. + Mon Aug 12 13:43:46 1996 Thomas Bushnell, n/BSG * hyper.c (diskfs_set_hypermetadata): Bother to return 0 at end of diff --git a/ufs/dir.c b/ufs/dir.c index d015a6c6..397481d0 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -111,7 +111,8 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, vm_address_t buf = 0; vm_size_t buflen = 0; int blockaddr; - int idx; + int idx, lastidx; + int looped; if ((type == REMOVE) || (type == RENAME)) assert (npp); @@ -156,18 +157,39 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; - for (blockaddr = buf, idx = 0; - blockaddr - buf < dp->dn_stat.st_size; - blockaddr += DIRBLKSIZ, idx++) + /* Start the lookup at DP->dn->dir_idx. */ + idx = dp->dn->dir_idx; + if (idx * DIRBLKSIZ > dp->dn_stat.st_size) + idx = 0; /* just in case */ + blockaddr = buf + idx * DIRBLKSIZ; + looped = (idx == 0); + lastidx = idx; + if (lastidx == 0) + lastidx = dp->dn_stat.st_size / DIRBLKSIZ; + + while (!looped || idx < lastidx) { err = dirscanblock (blockaddr, dp, idx, name, namelen, type, ds, &inum); if (!err) - break; + { + dp->dn->dir_idx = idx; + break; + } if (err != ENOENT) { vm_deallocate (mach_task_self (), buf, buflen); return err; } + + blockaddr += DIRBLKSIZ; + idx++; + if (blockaddr - buf >= dp->dn_stat.st_size && !looped) + { + /* We've gotten to the end; start back at the beginning */ + looped = 1; + blockaddr = buf; + idx = 0; + } } if (!diskfs_check_readonly ()) @@ -258,7 +280,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, /* We didn't find any room, so mark ds to extend the dir */ ds->type = CREATE; ds->stat = EXTEND; - ds->idx = idx; + ds->idx = dp->dn_stat.st_size / DIRBLKSIZ; } /* Return to the user; if we can't, release the reference @@ -422,8 +444,8 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, down how many entries there were. */ if (!dp->dn->dirents) { - dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ + 1) - * sizeof (int)); + dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ) + * sizeof (int)); for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; } @@ -595,19 +617,26 @@ diskfs_direnter_hard(struct node *dp, } else { + int i; /* It's cheap, so start a count here even if we aren't counting anything at all. */ if (dp->dn->dirents) { dp->dn->dirents = realloc (dp->dn->dirents, - (ds->idx + 1) * sizeof (int)); + (dp->dn_stat.st_size / DIRBLKSIZ + * sizeof (int))); + for (i = oldsize / DIRBLKSIZ; + i < dp->dn_stat.st_size / DIRBLKSIZ; + i++) + dp->dn->dirents[i] = -1; + dp->dn->dirents[ds->idx] = 1; } else { - int i; - dp->dn->dirents = malloc ((ds->idx + 1) * sizeof (int)); - for (i = 0; i < ds->idx; i++) + dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ + * sizeof (int)); + for (i = 0; i < dp->dn_stat.st_size / DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; dp->dn->dirents[ds->idx] = 1; } diff --git a/ufs/inode.c b/ufs/inode.c index ae323a8c..b06cb8d4 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -69,6 +69,7 @@ diskfs_cached_lookup (int inum, struct node **npp) dn->number = inum; dn->dirents = 0; + dn->dir_idx = 0; rwlock_init (&dn->allocptrlock); dn->dirty = 0; diff --git a/ufs/ufs.h b/ufs/ufs.h index ea13475e..f4b36ea5 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -36,6 +36,8 @@ struct disknode { ino_t number; + int dir_idx; + /* For a directory, this array holds the number of directory entries in each DIRBLKSIZE piece of the directory. */ int *dirents; -- cgit v1.2.3 From d2cfdaa0dc8916218d18271be9a9215920f12674 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 5 Sep 1996 14:14:07 +0000 Subject: *** empty log message *** --- configure.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 2546be9b..f42f6e6e 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.7 1996/08/13 18:10:06 thomas Exp $]) +AC_REVISION([$Id: configure.in,v 1.8 1996/09/05 14:14:01 thomas Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -11,6 +11,14 @@ gnu*) ;; *) AC_MSG_ERROR([sorry, this is the gnu os, not $host_os]) ;; esac +case "$host_cpu" in +i[[3456]]86) + asm_syntax=i386 + ;; +*) AC_MSG_ERROR([unspported CPU type]) ;; +esac +AC_SUBST(asm_syntax) + AC_PROG_INSTALL AC_CHECK_TOOL(CC, gcc) -- cgit v1.2.3 From c9df70bb8bd1cfbc683deab1b0e517c73d445b87 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 5 Sep 1996 16:59:37 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 5 +++++ ufs-fsck/main.c | 3 ++- ufs-utils/ChangeLog | 5 +++++ ufs-utils/mkfs.c | 5 +++-- version.h | 30 ++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 version.h diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index c8def0d7..d4e404b2 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 5 11:42:21 1996 Thomas Bushnell, n/BSG + + * main.c: Include . + (argp_program_version): Define with STANDARD_HURD_VERSION. + Fri Aug 16 10:25:37 1996 Thomas Bushnell, n/BSG * dir.c (record_directory): Maximum number of block pointers to diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index b5af2d88..c159b170 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -21,10 +21,11 @@ #include #include #include +#include #include "fsck.h" -char *argp_program_version = "fsck.ufs 1.0 (GNU " HURD_RELEASE ")"; +char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs) char *lfname = "lost+found"; mode_t lfmode = 0755; diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 201a2958..7f892351 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 5 11:44:38 1996 Thomas Bushnell, n/BSG + + * mkfs.c: Include . + (argp_program_version): Define with STANDARD_HURD_VERSION. + Mon Aug 19 15:18:30 1996 Miles Bader * mkfs.c (doc): Supply a useful value. diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 48a5a688..de8c712e 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.14 1996/08/27 18:24:31 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.15 1996/09/05 16:59:14 thomas Exp $"; #endif /* not lint */ #include @@ -54,6 +54,7 @@ static char *rcsid = "$Id: mkfs.c,v 1.14 1996/08/27 18:24:31 miles Exp $"; #include #include #include +#include #include #include @@ -163,7 +164,7 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; int fsi, fso; daddr_t alloc(); -char *argp_program_version = "mkfs.ufs 1.0 (GNU " HURD_RELEASE ")"; +char *argp_program_version = STANDARD_HURD_VERSION (mkfs.ufs); #define _STRINGIFY(arg) #arg #define STRINGIFY(arg) _STRINGIFY (arg) diff --git a/version.h b/version.h new file mode 100644 index 00000000..b8f63ac0 --- /dev/null +++ b/version.h @@ -0,0 +1,30 @@ +/* Hurd version + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Thomas Bushnell, n/BSG. + + 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. */ + +/* See sh-version.sed for duplicates of this information. */ + +#ifndef HURD_VERSION +#define HURD_VERSION "0.1" +#endif + +/* The standard way to print versions for --version */ +#define STANDARD_HURD_VERSION(s) #s " - GNU Hurd-" HURD_VERSION + + -- cgit v1.2.3 From fa7a1850df5b233ac58e9ab4110a94601319fdea Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 6 Sep 1996 22:19:58 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 4 ++++ ufs-fsck/main.c | 2 +- ufs/ChangeLog | 7 +++++++ ufs/consts.c | 7 +++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index d4e404b2..6c1e84a2 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +Fri Sep 6 16:44:07 1996 Thomas Bushnell, n/BSG + + * main.c (argp_program_version): Fix typo. + Thu Sep 5 11:42:21 1996 Thomas Bushnell, n/BSG * main.c: Include . diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index c159b170..ed651795 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -25,7 +25,7 @@ #include "fsck.h" -char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs) +char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs); char *lfname = "lost+found"; mode_t lfmode = 0755; diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 934c9856..896297d4 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +Fri Sep 6 16:00:42 1996 Thomas Bushnell, n/BSG + + * consts.c: Include . + (diskfs_major_version, diskfs_minor_version, diskfs_edit_version): + Deleted variables. + (diskfs_server_version): New variable. + Thu Aug 29 16:07:07 1996 Thomas Bushnell, n/BSG * dir.c (diskfs_lookup_hard): When setting ds->stat to EXTEND, set diff --git a/ufs/consts.c b/ufs/consts.c index 6698c5f4..1e855fba 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -1,5 +1,5 @@ /* Various constants wanted by the diskfs library - Copyright (C) 1994, 1995 Free Software Foundation + Copyright (C) 1994, 1995, 1996 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 @@ -16,6 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" +#include int diskfs_link_max = LINK_MAX; int diskfs_maxsymlinks = 8; @@ -25,7 +26,5 @@ int diskfs_shortcut_blkdev = 1; int diskfs_shortcut_fifo = 1; int diskfs_shortcut_ifsock = 1; char *diskfs_server_name = "ufs"; -int diskfs_major_version = 0; -int diskfs_minor_version = 0; -int diskfs_edit_version = 0; +char *diskfs_server_version = HURD_VERSION; int diskfs_synchronous = 0; -- cgit v1.2.3 From 1b9286318e9e079a06299de14b3563f5d14a06dc Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 8 Sep 1996 22:12:01 +0000 Subject: (DIST_FILES): Variable removed. (install, $(prefix)/dev/MAKEDEV): Targets removed. --- devio/Makefile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/devio/Makefile b/devio/Makefile index a1494a55..1dda469d 100644 --- a/devio/Makefile +++ b/devio/Makefile @@ -22,15 +22,9 @@ makemode := server target = devio SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h -DIST_FILES = MAKEDEV OBJS = $(SRCS:.c=.o) include ../Makeconf devio: $(OBJS) ../libtrivfs/libtrivfs.a ../libpager/libpager.a ../libports/libports.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a - -install: $(prefix)/dev/MAKEDEV - -$(prefix)/dev/MAKEDEV: MAKEDEV - $(INSTALL_PROGRAM) $(srcdir)/MAKEDEV $(prefix)/dev/MAKEDEV -- cgit v1.2.3 From ad3d97d916a5ced0720f4de084736003bea36407 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sun, 8 Sep 1996 22:12:09 +0000 Subject: . --- devio/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devio/ChangeLog b/devio/ChangeLog index a38f283a..07f59609 100644 --- a/devio/ChangeLog +++ b/devio/ChangeLog @@ -1,3 +1,8 @@ +Sun Sep 8 18:10:57 1996 Miles Bader + + * Makefile (DIST_FILES): Variable removed. + (install, $(prefix)/dev/MAKEDEV): Targets removed. + Fri Jul 19 15:55:27 1996 Miles Bader * io.c (trivfs_S_file_get_storage_info): Return correct values for -- cgit v1.2.3 From 447352af2fb7582f49e0efaf48d5b2360be8c514 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 17 Sep 1996 16:43:48 +0000 Subject: *** empty log message *** --- ufs-fsck/ChangeLog | 8 ++++++++ ufs-fsck/Makefile | 6 +++--- ufs/ChangeLog | 6 ++++++ ufs/Makefile | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 6c1e84a2..096d8c07 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,11 @@ +Thu Sep 12 16:40:10 1996 Thomas Bushnell, n/BSG + + * Makefile (HURDLIBS): New variable. + ($(target)): Delete special depedency. + + * Makefile (vpath tables.c): Put after Makeconf inclusion to catch + setting of $(top_srcdir). + Fri Sep 6 16:44:07 1996 Thomas Bushnell, n/BSG * main.c (argp_program_version): Fix typo. diff --git a/ufs-fsck/Makefile b/ufs-fsck/Makefile index 8725de8e..a484428e 100644 --- a/ufs-fsck/Makefile +++ b/ufs-fsck/Makefile @@ -27,9 +27,9 @@ OBJS = $(subst .c,.o,$(SRCS)) tables.o LCLHDRS = fsck.h target = fsck.ufs installationdir = $(sbindir) +HURDLIBS=shouldbeinlibc -vpath tables.c $(top_srcdir)/ufs +include ../Makeconf -$(target): ../libshouldbeinlibc/libshouldbeinlibc.a +vpath tables.c $(top_srcdir)/ufs -include ../Makeconf diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 896297d4..e74328ce 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 12 16:36:19 1996 Thomas Bushnell, n/BSG + + * Makefile (HURDLIBS): New variable. + (ufs.static ufs): Depend on $(library_deps) instead of long list + of libraries. + Fri Sep 6 16:00:42 1996 Thomas Bushnell, n/BSG * consts.c: Include . diff --git a/ufs/Makefile b/ufs/Makefile index d9375989..8d99925b 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -24,10 +24,11 @@ SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) +HURDLIBS = diskfs ports pager iohelp fshelp threads ihash shouldbeinlibc ufs.static-LDFLAGS += -static include ../Makeconf -ufs.static ufs: $(OBJS) ../libdiskfs/libdiskfs.a ../libports/libports.a ../libpager/libpager.a ../libiohelp/libiohelp.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a +ufs.static ufs: $(OBJS) $(library_deps) -- cgit v1.2.3 From d10f718cd6855ba4e683577836e45663b065ff8c Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 19 Sep 1996 16:56:46 +0000 Subject: *** empty log message *** --- sh-version.sed | 1 + 1 file changed, 1 insertion(+) create mode 100644 sh-version.sed diff --git a/sh-version.sed b/sh-version.sed new file mode 100644 index 00000000..a644fd64 --- /dev/null +++ b/sh-version.sed @@ -0,0 +1 @@ +s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 - GNU Hurd-0.1/ -- cgit v1.2.3 From e4ecfc6a5c7636050767f285f3f8cf26bfca11bf Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:24:53 +0000 Subject: (diskfs_extra_version): New variable. --- ufs/consts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/consts.c b/ufs/consts.c index 1e855fba..8806049e 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -27,4 +27,5 @@ int diskfs_shortcut_fifo = 1; int diskfs_shortcut_ifsock = 1; char *diskfs_server_name = "ufs"; char *diskfs_server_version = HURD_VERSION; +char *diskfs_extra_version = "GNU Hurd"; int diskfs_synchronous = 0; -- cgit v1.2.3 From 39eaa6a47b81c641181528a1c31e9e01cfffecca Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:24:57 +0000 Subject: (diskfs_direnter_hard): Initialize OLDSIZE to shut up gcc. --- ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index 397481d0..6c44932d 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -494,7 +494,7 @@ diskfs_direnter_hard(struct node *dp, vm_address_t fromoff, tooff; int totfreed; error_t err; - off_t oldsize; + off_t oldsize = 0; assert (ds->type == CREATE); -- cgit v1.2.3 From d1fe71f88f6f38fab0bb482cb600eea2e3afe26b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:01 +0000 Subject: (zeroblock): Change type to `void *'. (diskfs_set_hypermetadata): Use store_{read,write} instead of diskfs_device_{read,write}_sync. (get_hypermetadata): Cast ZEROBLOCK when vm_{de,}allocating. Use DISKFS_DISK_NAME instead of DISKFS_DEVICE_ARG. (get_hypermetadata, diskfs_readonly_changed): Use fields in STORE instead of DISKFS_DEVICE_* variables. --- ufs/hyper.c | 58 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index cb644797..052bc220 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -19,12 +19,13 @@ #include #include #include +#include static int ufs_clean; /* fs clean before we started writing? */ static int oldformat; -vm_address_t zeroblock; +void *zeroblock; struct fs *sblock; struct csum *csum; @@ -137,7 +138,8 @@ get_hypermetadata (void) /* Free previous values. */ if (zeroblock) - vm_deallocate (mach_task_self (), zeroblock, sblock->fs_bsize); + vm_deallocate (mach_task_self(), + (vm_address_t)zeroblock, sblock->fs_bsize); if (csum) free (csum); @@ -190,13 +192,13 @@ get_hypermetadata (void) { error (0, 0, "%s: warning: FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck", - diskfs_device_arg); + diskfs_disk_name); if (! diskfs_readonly) { diskfs_readonly = 1; error (0, 0, "%s: MOUNTED READ-ONLY; MUST USE `fsysopts --writable'", - diskfs_device_arg); + diskfs_disk_name); } } @@ -247,18 +249,17 @@ get_hypermetadata (void) if (swab_disk) swab_csums (csum); - if ((diskfs_device_size << diskfs_log2_device_block_size) - < sblock->fs_size * sblock->fs_fsize) + if (store->size < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size (%ld) less than necessary " + "Disk size (%Zd) less than necessary " "(superblock says we need %ld)\n", - diskfs_device_size << diskfs_log2_device_block_size, - sblock->fs_size * sblock->fs_fsize); + store->size, sblock->fs_size * sblock->fs_fsize); exit (1); } - vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1); + vm_allocate (mach_task_self (), + (vm_address_t *)&zeroblock, sblock->fs_bsize, 1); /* If the filesystem has new features in it, don't pay attention to the user's request not to use them. */ @@ -279,8 +280,6 @@ get_hypermetadata (void) error_t diskfs_set_hypermetadata (int wait, int clean) { - vm_address_t buf; - vm_size_t bufsize; error_t err; spin_lock (&alloclock); @@ -289,26 +288,36 @@ diskfs_set_hypermetadata (int wait, int clean) { /* Copy into a page-aligned buffer to avoid bugs in kernel device code. */ + void *buf = 0; + size_t read = 0; + size_t bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); - bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); - - err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr), - &buf, bufsize); + err = store_read (store, fsbtodb (sblock, sblock->fs_csaddr), bufsize, + &buf, &read); if (err) return err; - - bcopy (csum, (void *) buf, sblock->fs_cssize); - if (swab_disk) - swab_csums ((struct csum *)buf); - err = diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr), - buf, bufsize); - vm_deallocate (mach_task_self (), buf, bufsize); + else if (read != bufsize) + err = EIO; + else + { + size_t wrote; + bcopy (csum, buf, sblock->fs_cssize); + if (swab_disk) + swab_csums ((struct csum *)buf); + err = store_write (store, fsbtodb (sblock, sblock->fs_csaddr), + buf, bufsize, &wrote); + if (!err && wrote != bufsize) + err = EIO; + } + + vm_deallocate (mach_task_self (), (vm_address_t)buf, read); if (err) { spin_unlock (&alloclock); return err; } + csum_dirty = 0; } @@ -384,8 +393,7 @@ void diskfs_readonly_changed (int readonly) { vm_protect (mach_task_self (), - (vm_address_t)disk_image, - diskfs_device_size << diskfs_log2_device_block_size, + (vm_address_t)disk_image, store->size, 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE)); if (readonly) -- cgit v1.2.3 From f866671014ce5015022af04defaac3000c8f0be3 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:05 +0000 Subject: (diskfs_S_file_getfh): Variable ERR removed. (diskfs_S_file_get_storage_info): Narrow scope of RUN. Coalesce adjacent blocks when constructing RUNS. Set *PORTS_TYPE, not *STORAGE_PORT_TYPE. Use fields in STORE instead of DISKFS_DEVICE_* variables. Rewrite to use libstore functions (still has NDADDR block limit, though). --- ufs/inode.c | 134 +++++++++++++++++++++++------------------------------------- 1 file changed, 50 insertions(+), 84 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index b06cb8d4..47aa6ac9 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -21,6 +21,7 @@ #include #include #include +#include #define INOHSZ 512 #if ((INOHSZ&(INOHSZ-1)) == 0) @@ -621,108 +622,76 @@ diskfs_shutdown_soft_ports () offset into inode block holding inode (4 bytes) */ error_t diskfs_S_file_get_storage_info (struct protid *cred, - int *class, - off_t **addresses, - u_int *naddresses, - size_t *block_size, - char *storage_name, - mach_port_t *storage_port, - mach_msg_type_name_t *storage_port_type, - char **storage_data, - u_int *storage_data_len, - int *flags) + mach_port_t **ports, + mach_msg_type_name_t *ports_type, + mach_msg_type_number_t *num_ports, + int **ints, mach_msg_type_number_t *num_ints, + off_t **offsets, + mach_msg_type_number_t *num_offsets, + char **data, mach_msg_type_number_t *data_len) { error_t err; struct node *np; - int i; - struct dinode *di; - void *cp; + struct store *file_store; + struct store_run runs[NDADDR]; + size_t num_runs = 0; + if (! cred) + return EOPNOTSUPP; + np = cred->po->np; mutex_lock (&np->lock); /* See if this file fits in the direct block pointers. If not, punt for now. (Reading indir blocks is a pain, and I'm postponing pain.) XXX */ - if (np->allocsize > NDADDR * sblock->fs_bsize) { mutex_unlock (&np->lock); return EINVAL; } - - if (*naddresses < NDADDR * 2) - vm_allocate (mach_task_self (), (vm_address_t *) addresses, - sizeof (int) * NDADDR * 2, 1); - else - bzero (addresses, *naddresses * 2 * sizeof (int)); - *naddresses = NDADDR * 2; - if (*storage_data_len < 4 * sizeof (int)) - vm_allocate (mach_task_self (), (vm_address_t *) storage_data, - sizeof (int) * 4, 1); - *storage_data_len = 4 * sizeof (int); - - di = dino (np->dn->number); - err = diskfs_catch_exception (); - if (err) - { - mutex_unlock (&np->lock); - return err; - } - - /* Copy the block pointers */ - - if (!direct_symlink_extension - || np->dn_stat.st_size >= sblock->fs_maxsymlinklen - || !S_ISLNK (np->dn_stat.st_mode)) - { - for (i = 0; i < NDADDR; i++) - { - (*addresses)[2 * i] = fsbtodb (sblock, - read_disk_entry (di->di_db[i])); - if ((i + 1) * sblock->fs_bsize > np->allocsize) - (*addresses)[2 * i + 1] = np->allocsize - i * sblock->fs_bsize; - else - (*addresses)[2 * i + 1] = sblock->fs_bsize; - } - } - - /* Fill in the aux data */ - cp = *storage_data; - - *(int *)cp = htonl (np->dn->number); - cp += sizeof (int); - - *(int *)cp = htonl (di->di_trans); - cp += sizeof (int); - - *(int *)cp = htonl (fsbtodb (sblock, ino_to_fsba (sblock, np->dn->number))); - cp += sizeof (int); - - *(int *)cp = htonl (ino_to_fsbo (sblock, np->dn->number) - * sizeof (struct dinode)); - - + if (! err) + if (!direct_symlink_extension + || np->dn_stat.st_size >= sblock->fs_maxsymlinklen + || !S_ISLNK (np->dn_stat.st_mode)) + /* Copy the block pointers */ + { + int i; + struct store_run *run = runs; + struct dinode *di = dino (np->dn->number); + + for (i = 0; i < NDADDR; i++) + { + off_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); + off_t length = + (((i + 1) * sblock->fs_bsize > np->allocsize) + ? np->allocsize - i * sblock->fs_bsize + : sblock->fs_bsize); + if (num_runs == 0 || run->start + run->length != start) + *run++ = (struct store_run){ start, length }; + else + run->length += length; + } + } diskfs_end_catch_exception (); - - *class = STORAGE_DEVICE; - *flags = 0; - *block_size = DEV_BSIZE; - if (diskfs_device_name) - strcpy (storage_name, diskfs_device_name); - - if (diskfs_isuid (0, cred)) - *storage_port = diskfs_device; - else - *storage_port = MACH_PORT_NULL; - *storage_port_type = MACH_MSG_TYPE_COPY_SEND; - mutex_unlock (&np->lock); - return 0; + if (! err) + err = store_clone (store, &file_store); + if (! err) + { + err = store_remap (file_store, runs, num_runs, &file_store); + if (! err) + err = store_return (file_store, ports, num_ports, ints, num_ints, + offsets, num_offsets, data, data_len); + store_free (file_store); + } + *ports_type = MACH_MSG_TYPE_COPY_SEND; + + return err; } /* Must be exactly 28 bytes long */ @@ -742,7 +711,6 @@ diskfs_S_file_getfh (struct protid *cred, u_int *fh_len) { struct node *np; - error_t err; struct ufs_fhandle *f; if (!cred) @@ -845,5 +813,3 @@ diskfs_S_fsys_getfile (mach_port_t fsys, } return err; } - - -- cgit v1.2.3 From 2209a97405c148f8a6a6d02950d0c7c738b1f332 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:09 +0000 Subject: (parse_opt): Propagate our input to the first child parser. (diskfs_append_args): New function. (diskfs_get_options): Function removed. (diskfs_reload_global_state): Use DISKFS_DISK_PAGER instead of DISK_PAGER. (startup_parents): Use DISKFS_STORE_STARTUP_ARGP instead of DISKFS_STD_DEVICE_STARTUP_ARGP. (store, store_parsed, diskfs_disk_name): New variables. (main): Remove CLASSES argument to store_parsed_open. Use STORE_PARAMS variable to get result from parsing STORE_ARGP. Don't force COMPAT_GNU on bootstrap filesystems (it's the default anyway). Don't set DISKFS_USE_MACH_DEVICE (which is no longer). Use DISKFS_DISK_NAME instead of DISKFS_DEVICE_ARG. Use fields in STORE instead of DISKFS_DEVICE_* variables. , : New includes. --- ufs/main.c | 66 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 353a1852..a42f8158 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -26,9 +26,16 @@ #include #include #include +#include +#include struct node *diskfs_root_node; +struct store *store = 0; +struct store_parsed *store_parsed = 0; + +char *diskfs_disk_name = 0; + /* Set diskfs_root_node to the root inode. */ static void warp_root (void) @@ -66,7 +73,7 @@ options[] = {0} }; -/* Parse a command line option. */ +/* Parse a ufs-specific command line option. */ static error_t parse_opt (int key, char *arg, struct argp_state *state) { @@ -101,6 +108,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case ARGP_KEY_INIT: + state->child_inputs[0] = state->input; state->hook = (void *)compat_mode; break; case ARGP_KEY_SUCCESS: compat_mode = (enum compat_mode)state->hook; break; @@ -112,7 +120,7 @@ parse_opt (int key, char *arg, struct argp_state *state) } /* Add our startup arguments to the standard diskfs set. */ -static const struct argp *startup_parents[] = { &diskfs_std_device_startup_argp, 0}; +static const struct argp *startup_parents[] = { &diskfs_store_startup_argp, 0}; static struct argp startup_argp = {options, parse_opt, 0, 0, startup_parents}; /* Similarly at runtime. */ @@ -123,26 +131,21 @@ struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; /* Override the standard diskfs routine so we can add our own output. */ error_t -diskfs_get_options (char **argz, unsigned *argz_len) +diskfs_append_args (char **argz, unsigned *argz_len) { error_t err; - *argz = 0; - *argz_len = 0; - /* Get the standard things. */ err = diskfs_append_std_options (argz, argz_len); if (!err && compat_mode != COMPAT_GNU) - { - err = - argz_add (argz, argz_len, - ((compat_mode == COMPAT_BSD42) - ? "--compat=4.2" - : "--compat=4.4")); - if (err) - free (argz); /* Deallocate what diskfs returned. */ - } + err = argz_add (argz, argz_len, + ((compat_mode == COMPAT_BSD42) + ? "--compat=4.2" + : "--compat=4.4")); + + if (! err) + err = store_parsed_append_args (store_parsed, argz, argz_len); return err; } @@ -151,22 +154,23 @@ int main (int argc, char **argv) { error_t err; - off_t disk_size; mach_port_t bootstrap; + struct store_argp_params store_params = { 0 }; + + argp_parse (&startup_argp, argc, argv, 0, 0, &store_params); + store_parsed = store_params.result; - argp_parse (&startup_argp, argc, argv, 0, 0, 0); + err = store_parsed_name (store_parsed, &diskfs_disk_name); + if (err) + error (2, err, "store_parsed_name"); /* This must come after the args have been parsed, as this is where the host priv ports are set for booting. */ diskfs_console_stdio (); if (diskfs_boot_flags) - { /* We are the bootstrap filesystem. */ - bootstrap = MACH_PORT_NULL; - diskfs_use_mach_device = 1; - compat_mode = COMPAT_GNU; - } + bootstrap = MACH_PORT_NULL; else { task_get_bootstrap_port (mach_task_self (), &bootstrap); @@ -179,19 +183,19 @@ main (int argc, char **argv) if (err) error (4, err, "init"); - err = diskfs_device_open (); + err = store_parsed_open (store_parsed, diskfs_readonly ? STORE_READONLY : 0, + &store); if (err) - error (3, err, "%s", diskfs_device_arg); + error (3, err, "%s", diskfs_disk_name); - if (diskfs_device_block_size != DEV_BSIZE) + if (store->block_size != DEV_BSIZE) error (4, err, "%s: Bad device record size %d (should be %d)", - diskfs_device_arg, diskfs_device_block_size, DEV_BSIZE); - if (diskfs_log2_device_block_size == 0) + diskfs_disk_name, store->block_size, DEV_BSIZE); + if (store->log2_block_size == 0) error (4, err, "%s: Device block size (%d) not a power of 2", - diskfs_device_arg, diskfs_device_block_size); + diskfs_disk_name, store->block_size); - disk_size = diskfs_device_size << diskfs_log2_device_block_size; - assert (disk_size >= SBSIZE + SBOFF); + assert (store->size >= SBSIZE + SBOFF); /* Map the entire disk. */ create_disk_pager (); @@ -221,7 +225,7 @@ error_t diskfs_reload_global_state () { flush_pokes (); - pager_flush (disk_pager, 1); + pager_flush (diskfs_disk_pager, 1); get_hypermetadata (); return 0; } -- cgit v1.2.3 From cf859f986749059fbd818d487dac638eb4ca4f43 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:13 +0000 Subject: (pager_report_extent): Use fields in STORE instead of DISKFS_DEVICE_* variables. (pager_read_page, pager_write_page, pager_unlock_page): Use store_{read,write} instead of diskfs_device_{read,write}_sync. (create_disk_pager): Create PAGER_BUCKET. Use diskfs_start_disk_pager instead of disk_pager_setup. (thread_function): Function removed. (disk_image): New variable. (create_disk_pager, diskfs_shutdown_pager, diskfs_sync_everything): Use DISKFS_DISK_PAGER instead of DISK_PAGER. --- ufs/pager.c | 57 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index bea290ab..11d5eade 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -19,6 +19,7 @@ #include #include #include +#include spin_lock_t node2pagelock = SPIN_LOCK_INITIALIZER; @@ -32,6 +33,9 @@ spin_lock_t unlocked_pagein_lock = SPIN_LOCK_INITIALIZER; struct port_bucket *pager_bucket; +/* Mapped image of the disk. */ +void *disk_image; + /* Find the location on disk of page OFFSET in pager UPI. Return the disk address (in disk block) in *ADDR. If *NPLOCK is set on return, then release that mutex after I/O on the data has @@ -161,7 +165,10 @@ pager_read_page (struct user_pager_info *pager, if (addr) { - err = diskfs_device_read_sync (addr, (void *)buf, disksize); + size_t read = 0; + err = store_read (store, addr, disksize, (void **)buf, &read); + if (read != disksize) + err = EIO; if (!err && disksize != __vm_page_size) bzero ((void *)(*buf + disksize), __vm_page_size - disksize); *writelock = 0; @@ -199,7 +206,12 @@ pager_write_page (struct user_pager_info *pager, return err; if (addr) - err = diskfs_device_write_sync (addr, buf, disksize); + { + size_t wrote; + err = store_write (store, addr, (void *)buf, disksize, &wrote); + if (wrote != disksize) + err = EIO; + } else { printf ("Attempt to write unallocated disk\n."); @@ -286,6 +298,8 @@ pager_unlock_page (struct user_pager_info *pager, /* Check to see if this block is allocated. */ if (indirs[0].bno == 0) { + size_t wrote; + if (indirs[0].offset == -1) { err = ffs_alloc (np, lblkno (sblock, address), @@ -294,9 +308,15 @@ pager_unlock_page (struct user_pager_info *pager, sblock->fs_bsize, &bno, 0); if (err) goto out; + assert (lblkno (sblock, address) < NDADDR); - diskfs_device_write_sync (fsbtodb (sblock, bno), - zeroblock, sblock->fs_bsize); + err = store_write (store, fsbtodb (sblock, bno), + zeroblock, sblock->fs_bsize, &wrote); + if (!err && wrote != sblock->fs_bsize) + err = EIO; + if (err) + goto out; + indirs[0].bno = bno; write_disk_entry (di->di_db[lblkno (sblock, address)], bno); record_poke (di, sizeof (struct dinode)); @@ -378,8 +398,12 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; - diskfs_device_write_sync (fsbtodb (sblock, bno), - zeroblock, sblock->fs_bsize); + err = store_write (store, fsbtodb (sblock, bno), + zeroblock, sblock->fs_bsize, &wrote); + if (!err && wrote != sblock->fs_bsize) + err = EIO; + if (err) + goto out; indirs[0].bno = bno; write_disk_entry (siblock[indirs[0].offset], bno); @@ -405,7 +429,7 @@ pager_report_extent (struct user_pager_info *pager, *offset = 0; if (pager->type == DISK) - *size = diskfs_device_size << diskfs_log2_device_block_size; + *size = store->size; else *size = pager->np->allocsize; @@ -436,15 +460,6 @@ pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) -static void -thread_function (any_t foo __attribute__ ((unused))) -{ - for (;;) - ports_manage_port_operations_multithread (pager_bucket, pager_demuxer, - 1000 * 60 * 2, 0, - 1, MACH_PORT_NULL); -} - /* Create the DISK pager. */ void create_disk_pager (void) @@ -453,8 +468,10 @@ create_disk_pager (void) upi->type = DISK; upi->np = 0; - disk_pager_setup (upi, MAY_CACHE); - upi->p = disk_pager; + pager_bucket = ports_create_bucket (); + diskfs_start_disk_pager (upi, pager_bucket, MAY_CACHE, store->size, + &disk_image); + upi->p = diskfs_disk_pager; } /* This syncs a single file (NP) to disk. Wait for all I/O to complete @@ -743,7 +760,7 @@ diskfs_shutdown_pager () { struct pager *p = arg; /* Don't ever shut down the disk pager. */ - if (p != disk_pager) + if (p != diskfs_disk_pager) pager_shutdown (p); return 0; } @@ -762,7 +779,7 @@ diskfs_sync_everything (int wait) { struct pager *p = arg; /* Make sure the disk pager is done last. */ - if (p != disk_pager) + if (p != diskfs_disk_pager) pager_sync (p, wait); return 0; } -- cgit v1.2.3 From c4668bbf0c8caa00875a701673fc26d4623ff9cc Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:16 +0000 Subject: (sync_disk): Use DISKFS_DISK_PAGER instead of DISK_PAGER. --- ufs/pokeloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/pokeloc.c b/ufs/pokeloc.c index d09942e8..267aa106 100644 --- a/ufs/pokeloc.c +++ b/ufs/pokeloc.c @@ -75,7 +75,7 @@ sync_disk (int wait) spin_lock (&pokelistlock); for (pl = pokelist; pl; pl = tmp) { - pager_sync_some (disk_pager, pl->offset, pl->length, wait); + pager_sync_some (diskfs_disk_pager, pl->offset, pl->length, wait); tmp = pl->next; free (pl); } -- cgit v1.2.3 From 606962e7195f975c6e8506dd7008b99e4624edf6 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:20 +0000 Subject: (block_extended, diskfs_grow): Do cast it to offer_data. (diskfs_truncate): Don't cast ZEROBLOCK to diskfs_node_rw. (indir_release): Use DISKFS_DISK_PAGER instead of DISK_PAGER. --- ufs/sizes.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index a0b090d3..84c2493d 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -82,8 +82,7 @@ diskfs_truncate (struct node *np, np->allocsize = length; /* temporary */ bsize = blksize (sblock, np, lblkno (sblock, length)); np->allocsize = savesize; - diskfs_node_rdwr (np, (void *) zeroblock, length, - bsize - offset, 1, 0, 0); + diskfs_node_rdwr (np, zeroblock, length, bsize - offset, 1, 0, 0); diskfs_file_update (np, 1); } @@ -321,7 +320,7 @@ indir_release (struct node *np, daddr_t bno, int level) the block from the kernel's memory, making sure we do it synchronously--and BEFORE we attach it to the free list with ffs_blkfree. */ - pager_flush_some (disk_pager, fsaddr (sblock, bno), sblock->fs_bsize, 1); + pager_flush_some (diskfs_disk_pager, fsaddr (sblock, bno), sblock->fs_bsize, 1); /* We should also take this block off the inode's list of dirty indirect blocks if it's there. */ @@ -389,7 +388,8 @@ block_extended (struct node *np, don't get paged in from disk. */ if (round_page (old_size) < round_page (new_size)) offer_data (np, lbn * sblock->fs_bsize + round_page (old_size), - round_page (new_size) - round_page (old_size), zeroblock); + round_page (new_size) - round_page (old_size), + (vm_address_t)zeroblock); if (old_pbn != new_pbn) { @@ -553,7 +553,8 @@ diskfs_grow (struct node *np, goto out; - offer_data (np, lbn * sblock->fs_bsize, size, zeroblock); + offer_data (np, lbn * sblock->fs_bsize, size, + (vm_address_t)zeroblock); write_disk_entry (di->di_db[lbn], bno); record_poke (di, sizeof (struct dinode)); np->dn_set_ctime = 1; @@ -647,7 +648,8 @@ diskfs_grow (struct node *np, sblock->fs_bsize, &bno, 0); if (err) goto out; - offer_data (np, lbn * sblock->fs_bsize, sblock->fs_bsize, zeroblock); + offer_data (np, lbn * sblock->fs_bsize, sblock->fs_bsize, + (vm_address_t)zeroblock); indirs[0].bno = bno; write_disk_entry (siblock[indirs[0].offset], bno); record_poke (siblock, sblock->fs_bsize); -- cgit v1.2.3 From 3171166730cc3532b4099a0030c463ec7c8e6b3b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:25:24 +0000 Subject: (store, store_parsed, disk_image): New declarations. (zeroblock): Change type to `void *'. (sync_disk_blocks): Use DISKFS_DISK_PAGER instead of DISK_PAGER. --- ufs/ufs.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index f4b36ea5..db2cf12b 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -88,7 +88,15 @@ struct user_pager_info #include -extern vm_address_t zeroblock; +/* The physical media. */ +extern struct store *store; +/* What the user specified. */ +extern struct store_parsed *store_parsed; + +/* Mapped image of the disk. */ +extern void *disk_image; + +extern void *zeroblock; extern struct fs *sblock; extern struct csum *csum; @@ -166,7 +174,7 @@ cg_locate (int ncg) extern inline void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait) { - pager_sync_some (disk_pager, fsaddr (sblock, blkno), nbytes, wait); + pager_sync_some (diskfs_disk_pager, fsaddr (sblock, blkno), nbytes, wait); } /* Sync an disk inode */ -- cgit v1.2.3 From 6c96cc2fe98de6e03786a211ce89e6925cffba54 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:26:21 +0000 Subject: (HURDLIBS): Add store. --- ufs/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 8d99925b..202316f8 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -24,11 +24,10 @@ SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) -HURDLIBS = diskfs ports pager iohelp fshelp threads ihash shouldbeinlibc +HURDLIBS = diskfs iohelp fshelp store pager ports threads ihash shouldbeinlibc ufs.static-LDFLAGS += -static include ../Makeconf ufs.static ufs: $(OBJS) $(library_deps) - -- cgit v1.2.3 From db7941c146278cd195b850b659d8ec82e5aa8347 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 17:26:31 +0000 Subject: . --- ufs/ChangeLog | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index e74328ce..40d03163 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,80 @@ +Thu Sep 19 18:02:40 1996 Miles Bader + + * Makefile (HURDLIBS): Add store. + +Wed Sep 18 15:30:00 1996 Miles Bader + + * inode.c (diskfs_S_file_get_storage_info): Narrow scope of RUN. + + * consts.c (diskfs_extra_version): New variable. + + * main.c (main): Remove CLASSES argument to store_parsed_open. + Use STORE_PARAMS variable to get result from parsing STORE_ARGP. + Don't force COMPAT_GNU on bootstrap filesystems (it's the default + anyway). + +Mon Sep 16 13:27:38 1996 Miles Bader + + * Makefile (ufs.static ufs): Add ../libstore/libstore.a. + + * hyper.c (zeroblock): Change type to `void *'. + (get_hypermetadata): Cast ZEROBLOCK when vm_{de,}allocating. + * ufs.h (zeroblock): Change type to `void *'. + * sizes.c (diskfs_truncate): Don't cast ZEROBLOCK to diskfs_node_rw. + (block_extended, diskfs_grow): Do cast it to offer_data. + + * main.c (main): Don't set DISKFS_USE_MACH_DEVICE (which is no longer). + + * inode.c (diskfs_S_file_get_storage_info): Coalesce adjacent + blocks when constructing RUNS. + Set *PORTS_TYPE, not *STORAGE_PORT_TYPE. + * inode.c (diskfs_S_file_getfh): Variable ERR removed. + + * sizes.c (indir_release): Use DISKFS_DISK_PAGER instead of DISK_PAGER. + * ufs.h (sync_disk_blocks): Likewise. + * pokeloc.c (sync_disk): Likewise. + * main.c (diskfs_reload_global_state): Likewise. + * pager.c (create_disk_pager, diskfs_shutdown_pager, + diskfs_sync_everything): Likewise. + * main.c , : New includes. + * hyper.c, pager.c, inode.c : New include. + (get_hypermetadata): Use %Zd for printfing size_t. + (diskfs_set_hypermetadata): Return EIO for incomplete writes. + Cast BUF when calling vm_deallocate. + + * dir.c (diskfs_direnter_hard): Initialize OLDSIZE to shut up gcc. + +Sat Sep 14 20:38:47 1996 Miles Bader + + * ufs.h (store, store_parsed, disk_image): New declarations. + + * pager.c (thread_function): Function removed. + (create_disk_pager): Create PAGER_BUCKET. + Use diskfs_start_disk_pager instead of disk_pager_setup. + (disk_image): New variable. + + * main.c (store, store_parsed, diskfs_disk_name): New variables. + (parse_opt): Propagate our input to the first child parser. + (diskfs_append_args): New function. + (diskfs_get_options): Function removed. + (startup_parents): Use DISKFS_STORE_STARTUP_ARGP instead of + DISKFS_STD_DEVICE_STARTUP_ARGP. + + * hyper.c (get_hypermetadata): Use DISKFS_DISK_NAME instead of + DISKFS_DEVICE_ARG. + * main.c (main): Likewise. + + * hyper.c (get_hypermetadata, diskfs_readonly_changed): Use + fields in STORE instead of DISKFS_DEVICE_* variables. + * inode.c (diskfs_S_file_get_storage_info): Likewise. + * pager.c (pager_report_extent): Likewise. + * main.c (main): Likewise. + * pager.c (pager_read_page, pager_write_page, pager_unlock_page): + Use store_{read,write} instead of diskfs_device_{read,write}_sync. + * hyper.c (diskfs_set_hypermetadata): Likewise. + * inode.c (diskfs_S_file_get_storage_info): Rewrite to use + libstore functions (still has NDADDR block limit, though). + Thu Sep 12 16:36:19 1996 Thomas Bushnell, n/BSG * Makefile (HURDLIBS): New variable. -- cgit v1.2.3 From 4c28aad0e1bdd8267c2fdf74a5af06fc97185d6e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 19:55:19 +0000 Subject: Check for libcrypt. --- configure.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index f42f6e6e..e62038af 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.8 1996/09/05 14:14:01 thomas Exp $]) +AC_REVISION([$Id: configure.in,v 1.9 1996/09/23 19:55:19 miles Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -39,6 +39,10 @@ AC_CHECK_TOOL(MIG, mig) dnl Let these propagate from the environment. AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) +# See if there's a separate libcrypt (many systems put crypt there) +AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) +AC_SUBST(LIBCRYPT) + if test $srcdir = .; then # Configuring in source directory; don't create any Makefiles. makefiles= -- cgit v1.2.3 From 0e21a417a49947535f3465007ceba830958c9ab8 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 19:55:23 +0000 Subject: (_SHV_SEP): New macro. (STANDARD_HURD_VERSION): Change to use new format. Add EXTRA tail arg. --- version.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index b8f63ac0..c61c275e 100644 --- a/version.h +++ b/version.h @@ -24,7 +24,9 @@ #define HURD_VERSION "0.1" #endif -/* The standard way to print versions for --version */ -#define STANDARD_HURD_VERSION(s) #s " - GNU Hurd-" HURD_VERSION +/* The standard way to print versions for --version. */ +#define _SHV_SEP "; " +#define STANDARD_HURD_VERSION(s, extra...) \ + #s " (GNU Hurd" _SHV_SEP ##extra ") " HURD_VERSION -- cgit v1.2.3 From d862cb5dc7e38bf90ae307087de6c6e7ec20a386 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 23 Sep 1996 20:21:26 +0000 Subject: Change to use new version format. --- sh-version.sed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh-version.sed b/sh-version.sed index a644fd64..226cdaf4 100644 --- a/sh-version.sed +++ b/sh-version.sed @@ -1 +1 @@ -s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 - GNU Hurd-0.1/ +s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 (GNU Hurd) 0.1/ -- cgit v1.2.3 From d286c10634bb2a91e847b00ed778a1af439d0437 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 25 Sep 1996 01:49:10 +0000 Subject: Add check for crypt function. --- configure.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index e62038af..6afafb12 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.9 1996/09/23 19:55:19 miles Exp $]) +AC_REVISION([$Id: configure.in,v 1.10 1996/09/25 01:49:10 miles Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -42,6 +42,11 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) # See if there's a separate libcrypt (many systems put crypt there) AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) AC_SUBST(LIBCRYPT) +# Look for the crypt function itself (in libcrypt if possible) +_SAVE_LIBS="$LIBS" +LIBS="$LIBCRYPT $LIBS" +AC_CHECK_FUNCS(crypt) +LIBS="$_SAVE_LIBS" if test $srcdir = .; then # Configuring in source directory; don't create any Makefiles. -- cgit v1.2.3 From 771467d73865b27e02692a457e57c4000e820b3e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 24 Oct 1996 22:43:08 +0000 Subject: (startup_children, runtime_children): New variables. (startup_parents, runtime_parents): Variables removed. (startup_argp, runtime_argp): Use new *_CHILDREN variables instead of corresponding *_PARENT ones. --- ufs/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index a42f8158..f0ffa3f5 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -120,12 +120,14 @@ parse_opt (int key, char *arg, struct argp_state *state) } /* Add our startup arguments to the standard diskfs set. */ -static const struct argp *startup_parents[] = { &diskfs_store_startup_argp, 0}; -static struct argp startup_argp = {options, parse_opt, 0, 0, startup_parents}; +static const struct argp_child startup_children[] = + {{&diskfs_store_startup_argp}, {0}}; +static struct argp startup_argp = {options, parse_opt, 0, 0, startup_children}; /* Similarly at runtime. */ -static const struct argp *runtime_parents[] = {&diskfs_std_runtime_argp, 0}; -static struct argp runtime_argp = {options, parse_opt, 0, 0, runtime_parents}; +static const struct argp_child runtime_children[] = + {{&diskfs_std_runtime_argp}, {0}}; +static struct argp runtime_argp = {options, parse_opt, 0, 0, runtime_children}; struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; -- cgit v1.2.3 From 082a3a45cd55b33d05223b6942c804de8f844384 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 24 Oct 1996 22:43:50 +0000 Subject: . --- ufs/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 40d03163..2c81dbc3 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +Thu Oct 24 16:07:17 1996 Miles Bader + + * main.c (startup_children, runtime_children): New variables. + (startup_parents, runtime_parents): Variables removed. + (startup_argp, runtime_argp): Use new *_CHILDREN variables instead of + corresponding *_PARENT ones. + Thu Sep 19 18:02:40 1996 Miles Bader * Makefile (HURDLIBS): Add store. -- cgit v1.2.3 From 00b56b8817816a221ed49d07c14d5c93a079da4d Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 18 Nov 1996 23:59:08 +0000 Subject: Sat Nov 16 17:21:40 1996 Thomas Bushnell, n/BSG * inode.c (diskfs_S_fsys_getfile): Delete var `fakecred'. diskfs_access -> fshelp_access. * alloc.c (ffs_alloc): diskfs_isuid -> idvec_contains. (ffs_realloccg): Likewise. Thu Nov 14 16:43:36 1996 Thomas Bushnell, n/BSG * inode.c (diskfs_S_file_getfh): diskfs_isuid -> idvec_contains. (diskfs_S_fsys_getfile): Use idvecs and iousers. --- ufs/ChangeLog | 12 ++++++++++++ ufs/alloc.c | 5 +++-- ufs/inode.c | 27 ++++++++++++++++----------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 2c81dbc3..4ca29dee 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,15 @@ +Sat Nov 16 17:21:40 1996 Thomas Bushnell, n/BSG + + * inode.c (diskfs_S_fsys_getfile): Delete var `fakecred'. + diskfs_access -> fshelp_access. + * alloc.c (ffs_alloc): diskfs_isuid -> idvec_contains. + (ffs_realloccg): Likewise. + +Thu Nov 14 16:43:36 1996 Thomas Bushnell, n/BSG + + * inode.c (diskfs_S_file_getfh): diskfs_isuid -> idvec_contains. + (diskfs_S_fsys_getfile): Use idvecs and iousers. + Thu Oct 24 16:07:17 1996 Miles Bader * main.c (startup_children, runtime_children): New variables. diff --git a/ufs/alloc.c b/ufs/alloc.c index 90ce68f5..15d53180 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -247,7 +247,7 @@ ffs_alloc(register struct node *np, spin_lock (&alloclock); if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) goto nospace; - if (cred && !diskfs_isuid (0, cred) + if (cred && !idvec_contains (cred->user->uids, 0) && freespace(fs, fs->fs_minfree) <= 0) goto nospace; #ifdef QUOTA @@ -323,7 +323,8 @@ ffs_realloccg(register struct node *np, spin_lock (&alloclock); - if (!diskfs_isuid (0, cred) && freespace(fs, fs->fs_minfree) <= 0) + if (!idvec_contains (cred->user->uids, 0) + && freespace(fs, fs->fs_minfree) <= 0) goto nospace; error = diskfs_catch_exception (); if (error) diff --git a/ufs/inode.c b/ufs/inode.c index 47aa6ac9..a0f16642 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -716,7 +716,7 @@ diskfs_S_file_getfh (struct protid *cred, if (!cred) return EOPNOTSUPP; - if (!diskfs_isuid (0, cred)) + if (!idvec_contains (cred->user->uids, 0)) return EPERM; np = cred->po->np; @@ -757,7 +757,9 @@ diskfs_S_fsys_getfile (mach_port_t fsys, struct ufs_fhandle *f; error_t err; int flags; - struct protid fakecred, *newpi; + struct protid *newpi; + struct idvec *uvec, *gvec; + struct iouser *user; if (!pt) return EOPNOTSUPP; @@ -784,24 +786,27 @@ diskfs_S_fsys_getfile (mach_port_t fsys, return ESTALE; } - /* This call should have a flags arg, but until then... */ - fakecred.uids = uids; - fakecred.gids = gids; - fakecred.nuids = nuids; - fakecred.ngids = ngids; + uvec = make_idvec (); + gvec = make_idvec (); + idvec_set_ids (uvec, uids, nuids); + idvec_set_ids (gvec, gids, ngids); + user = iohelp_create_iouser (uvec, gvec); + flags = 0; - if (!diskfs_access (np, S_IREAD, &fakecred)) + if (!fshelp_access (&np->dn_stat, S_IREAD, user)) flags |= O_READ; - if (!diskfs_access (np, S_IEXEC, &fakecred)) + if (!fshelp_access (&np->dn_stat, S_IEXEC, user)) flags |= O_EXEC; - if (!diskfs_access (np, S_IWRITE, &fakecred) + if (!fshelp_access (&np->dn_stat, S_IWRITE, user) && !S_ISDIR (np->dn_stat.st_mode) && !diskfs_check_readonly ()) flags |= O_WRITE; err = diskfs_create_protid (diskfs_make_peropen (np, flags, MACH_PORT_NULL), - uids, nuids, gids, ngids, &newpi); + user, &newpi); + + iohelp_free_iouser (user); diskfs_nput (np); ports_port_deref (pt); -- cgit v1.2.3 From 44015af36f54d4d34fe15a2c8f34179acb979def Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 19 Nov 1996 23:18:20 +0000 Subject: (ffs_alloc): Use S_IPTRANS in NP->dn_stat.st_mode instead of NP->istranslated. --- ufs/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index 15d53180..ac72c928 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -683,7 +683,7 @@ diskfs_alloc_node (struct node *dir, goto noinodes; error = diskfs_cached_lookup (ino, &np); assert ("duplicate allocation" && !np->dn_stat.st_mode); - assert (!np->istranslated); + assert (! (np->dn_stat.st_mode & S_IPTRANS)); if (np->dn_stat.st_blocks) { printf("free inode %d had %d blocks\n", ino, np->dn_stat.st_blocks); -- cgit v1.2.3 From a8e78f4ac4b6b40ebf6879c8ba92cc864e80d7dd Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 19 Nov 1996 23:19:03 +0000 Subject: (diskfs_set_translator): Frob S_IPTRANS bit in mode bits instead of NP->istranslated. (write_node): Don't write any bits in S_ITRANS to disk. (read_disknode): When setting ST->st_mode, Clear S_ITRANS bits, and set S_IPTRANS if necessary. Don't set NP->istranslated anymore. --- ufs/inode.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index a0f16642..006d595a 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -221,9 +221,7 @@ read_disknode (struct node *np) if (err) return err; - np->istranslated = !! di->di_trans; - - if (!fsidset) + if (! fsidset) { fsid = getpid (); fsidset = 1; @@ -234,8 +232,10 @@ read_disknode (struct node *np) st->st_ino = np->dn->number; st->st_gen = read_disk_entry (di->di_gen); st->st_rdev = read_disk_entry(di->di_rdev); - st->st_mode = (read_disk_entry (di->di_model) - | (read_disk_entry (di->di_modeh) << 16)); + st->st_mode = (((read_disk_entry (di->di_model) + | (read_disk_entry (di->di_modeh) << 16)) + & ~S_ITRANS) + | (di->di_trans ? S_IPTRANS : 0)); st->st_nlink = read_disk_entry (di->di_nlink); st->st_size = read_disk_entry (di->di_size); #ifdef notyet @@ -326,12 +326,13 @@ write_node (struct node *np) if (compat_mode == COMPAT_GNU) { - write_disk_entry (di->di_model, st->st_mode & 0xffff); - write_disk_entry (di->di_modeh, (st->st_mode >> 16) & 0xffff); + mode_t mode = st->st_mode & ~S_ITRANS; + write_disk_entry (di->di_model, mode & 0xffff); + write_disk_entry (di->di_modeh, (mode >> 16) & 0xffff); } else { - write_disk_entry (di->di_model, st->st_mode & 0xffff); + write_disk_entry (di->di_model, st->st_mode & 0xffff & ~S_ITRANS); di->di_modeh = 0; } @@ -557,7 +558,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, di->di_trans = 0; record_poke (di, sizeof (struct dinode)); np->dn_stat.st_blocks -= btodb (sblock->fs_bsize); - np->istranslated = 0; + np->dn_stat.st_mode &= ~S_IPTRANS; np->dn_set_ctime = 1; } @@ -569,7 +570,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, bcopy (buf, disk_image + fsaddr (sblock, blkno), sblock->fs_bsize); sync_disk_blocks (blkno, sblock->fs_bsize, 1); - np->istranslated = 1; + np->dn_stat.st_mode |= S_IPTRANS; np->dn_set_ctime = 1; } -- cgit v1.2.3 From 7eaadcab20d3580b4248be866188786cb0536d8c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 19 Nov 1996 23:19:17 +0000 Subject: . --- ufs/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 4ca29dee..20921669 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,14 @@ +Mon Nov 18 17:10:00 1996 Miles Bader + + * inode.c (read_disknode): When setting ST->st_mode, Clear + S_ITRANS bits, and set S_IPTRANS if necessary. Don't set + NP->istranslated anymore. + (diskfs_set_translator): Frob S_IPTRANS bit in mode bits instead + of NP->istranslated. + (write_node): Don't write any bits in S_ITRANS to disk. + * alloc.c (ffs_alloc): Use S_IPTRANS in NP->dn_stat.st_mode + instead of NP->istranslated. + Sat Nov 16 17:21:40 1996 Thomas Bushnell, n/BSG * inode.c (diskfs_S_fsys_getfile): Delete var `fakecred'. -- cgit v1.2.3 From 56ef5d5b431c08037e09849debfe9ea001b5e481 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 20 Nov 1996 02:54:01 +0000 Subject: (read_disknode): If SBLOCK->fs_inodefmt < FS_44INODEFMT, set ST->st_author to st->st_uid, and NP->author_tracks_uid to true. (diskfs_validate_author_change): New function. --- ufs/inode.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 006d595a..286cfafc 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -258,7 +258,8 @@ read_disknode (struct node *np) { st->st_uid = read_disk_entry (di->di_ouid); st->st_gid = read_disk_entry (di->di_ogid); - st->st_author = 0; + st->st_author = st->st_uid; + np->author_tracks_uid = 1; } else { @@ -300,6 +301,18 @@ error_t diskfs_node_reload (struct node *node) return 0; } +/* Return 0 if NP's author can be changed to AUTHOR; otherwise return an + error code. */ +error_t +diskfs_validate_author_change (struct node *np, uid_t author) +{ + if (compat_mode == COMPAT_GNU) + return 0; + else + /* For non-hurd filesystems, the author & owner are the same. */ + return (author == np->dn_stat.st_uid) ? 0 : EINVAL; +} + static void write_node (struct node *np) { -- cgit v1.2.3 From 34accef1c2f1d27a3af0de37ce67a16dc5a1a5ca Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 20 Nov 1996 02:54:47 +0000 Subject: . --- ufs/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 20921669..41f2347c 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +Tue Nov 19 18:28:26 1996 Miles Bader + + * inode.c (read_disknode): If SBLOCK->fs_inodefmt < FS_44INODEFMT, + set ST->st_author to st->st_uid, and NP->author_tracks_uid to true. + (diskfs_validate_author_change): New function. + Mon Nov 18 17:10:00 1996 Miles Bader * inode.c (read_disknode): When setting ST->st_mode, Clear -- cgit v1.2.3 From 894448bcc1aff693009298da900c27431f09c5a5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 6 Feb 1997 06:58:33 +0000 Subject: (diskfs_S_fsys_getfile): Pass new DEPTH argument to diskfs_make_peropen. --- ufs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 286cfafc..dc870525 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -817,7 +817,8 @@ diskfs_S_fsys_getfile (mach_port_t fsys, && !diskfs_check_readonly ()) flags |= O_WRITE; - err = diskfs_create_protid (diskfs_make_peropen (np, flags, MACH_PORT_NULL), + err = diskfs_create_protid (diskfs_make_peropen (np, flags, + MACH_PORT_NULL, 0), user, &newpi); iohelp_free_iouser (user); -- cgit v1.2.3 From 55e4665ab4ed09db57a533a08d63d376a4fc8b88 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 6 Feb 1997 07:41:21 +0000 Subject: (diskfs_S_file_getfh, diskfs_S_fsys_getfile): Functions removed. --- ufs/inode.c | 126 ------------------------------------------------------------ 1 file changed, 126 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index dc870525..2965114f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -707,129 +707,3 @@ diskfs_S_file_get_storage_info (struct protid *cred, return err; } - -/* Must be exactly 28 bytes long */ -struct ufs_fhandle -{ - int filler1; - ino_t inum; - long gen; - int filler2[4]; -}; - -/* Return an NFS file handle */ - -error_t -diskfs_S_file_getfh (struct protid *cred, - char **fh, - u_int *fh_len) -{ - struct node *np; - struct ufs_fhandle *f; - - if (!cred) - return EOPNOTSUPP; - - if (!idvec_contains (cred->user->uids, 0)) - return EPERM; - - np = cred->po->np; - - mutex_lock (&np->lock); - - if (*fh_len < sizeof (struct ufs_fhandle)) - vm_allocate (mach_task_self (), (vm_address_t *) fh, - sizeof (struct ufs_fhandle), 1); - *fh_len = sizeof (struct ufs_fhandle); - - f = (struct ufs_fhandle *) *fh; - f->inum = np->dn->number; - f->gen = np->dn_stat.st_gen; - f->filler1 = 0; - f->filler2[0] = f->filler2[1] = f->filler2[2] = f->filler2[3] = 0; - mutex_unlock (&np->lock); - return 0; -} - -/* Lookup an NFS file handle */ -error_t -diskfs_S_fsys_getfile (mach_port_t fsys, - mach_port_t reply, - mach_msg_type_name_t replytype, - uid_t *uids, - u_int nuids, - uid_t *gids, - u_int ngids, - char *handle, - u_int handlelen, - mach_port_t *file, - mach_msg_type_name_t *filetype) -{ - struct port_info *pt = ports_lookup_port (diskfs_port_bucket, fsys, - diskfs_control_class); - struct node *np; - struct ufs_fhandle *f; - error_t err; - int flags; - struct protid *newpi; - struct idvec *uvec, *gvec; - struct iouser *user; - - if (!pt) - return EOPNOTSUPP; - - if (handlelen != sizeof (struct ufs_fhandle)) - { - ports_port_deref (pt); - return EINVAL; - } - - f = (struct ufs_fhandle *) handle; - - err = diskfs_cached_lookup (f->inum, &np); - if (err) - { - ports_port_deref (pt); - return err; - } - - if (np->dn_stat.st_gen != f->gen) - { - diskfs_nput (np); - ports_port_deref (pt); - return ESTALE; - } - - uvec = make_idvec (); - gvec = make_idvec (); - - idvec_set_ids (uvec, uids, nuids); - idvec_set_ids (gvec, gids, ngids); - user = iohelp_create_iouser (uvec, gvec); - - flags = 0; - if (!fshelp_access (&np->dn_stat, S_IREAD, user)) - flags |= O_READ; - if (!fshelp_access (&np->dn_stat, S_IEXEC, user)) - flags |= O_EXEC; - if (!fshelp_access (&np->dn_stat, S_IWRITE, user) - && !S_ISDIR (np->dn_stat.st_mode) - && !diskfs_check_readonly ()) - flags |= O_WRITE; - - err = diskfs_create_protid (diskfs_make_peropen (np, flags, - MACH_PORT_NULL, 0), - user, &newpi); - - iohelp_free_iouser (user); - - diskfs_nput (np); - ports_port_deref (pt); - - if (!err) - { - *file = ports_get_right (newpi); - *filetype = MACH_MSG_TYPE_MAKE_SEND; - } - return err; -} -- cgit v1.2.3 From 606fe786cb5782808b18e14e9f925a813d8b8a61 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 6 Feb 1997 07:42:34 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 41f2347c..323da685 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +Thu Feb 6 01:56:27 1997 Miles Bader + + (diskfs_S_file_getfh, diskfs_S_fsys_getfile): Functions removed. + Tue Nov 19 18:28:26 1996 Miles Bader * inode.c (read_disknode): If SBLOCK->fs_inodefmt < FS_44INODEFMT, -- cgit v1.2.3 From 087aab921f45c4bb235aef3d4aaaa3c97672fa0c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 20 Feb 1997 04:19:53 +0000 Subject: (argp_program_version): Make const. --- ufs-fsck/main.c | 4 ++-- ufs-utils/mkfs.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs-fsck/main.c b/ufs-fsck/main.c index ed651795..34c32a67 100644 --- a/ufs-fsck/main.c +++ b/ufs-fsck/main.c @@ -1,5 +1,5 @@ /* Main program for GNU fsck - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -25,7 +25,7 @@ #include "fsck.h" -char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs); +const char *argp_program_version = STANDARD_HURD_VERSION (fsck.ufs); char *lfname = "lost+found"; mode_t lfmode = 0755; diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index de8c712e..b6303e86 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.15 1996/09/05 16:59:14 thomas Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.16 1997/02/20 04:15:02 miles Exp $"; #endif /* not lint */ #include @@ -164,7 +164,7 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; int fsi, fso; daddr_t alloc(); -char *argp_program_version = STANDARD_HURD_VERSION (mkfs.ufs); +const char *argp_program_version = STANDARD_HURD_VERSION (mkfs.ufs); #define _STRINGIFY(arg) #arg #define STRINGIFY(arg) _STRINGIFY (arg) -- cgit v1.2.3 From 8c95742ba430bc6421559b6671a95a534c92008a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 20 Feb 1997 04:20:49 +0000 Subject: . --- ufs-fsck/ChangeLog | 4 ++++ ufs-utils/ChangeLog | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 096d8c07..7df8d5c0 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +Wed Feb 19 23:10:39 1997 Miles Bader + + * main.c (argp_program_version): Make const. + Thu Sep 12 16:40:10 1996 Thomas Bushnell, n/BSG * Makefile (HURDLIBS): New variable. diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 7f892351..71d92548 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,7 @@ +Wed Feb 19 23:10:54 1997 Miles Bader + + * mkfs.c (argp_program_version): Make const. + Thu Sep 5 11:44:38 1996 Thomas Bushnell, n/BSG * mkfs.c: Include . -- cgit v1.2.3 From 2059697c29c926c3ad42efb61993baf2723f0b0e Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 3 Apr 1997 23:28:32 +0000 Subject: Initial Revision --- serverboot/ChangeLog | 53 + serverboot/Makefile | 43 + serverboot/assert.h | 50 + serverboot/bootstrap.c | 408 +++++ serverboot/def_pager_setup.c | 136 ++ serverboot/default_pager.c | 3536 +++++++++++++++++++++++++++++++++++++++++ serverboot/defs.h | 95 ++ serverboot/dir.h | 142 ++ serverboot/disk_inode.h | 101 ++ serverboot/disk_inode_ffs.h | 99 ++ serverboot/elf-load.c | 88 + serverboot/exec.c | 88 + serverboot/ext2_file_io.c | 1099 +++++++++++++ serverboot/ext2_fs.h | 451 ++++++ serverboot/ffs_compat.c | 63 + serverboot/ffs_compat.h | 54 + serverboot/ffs_file_io.c | 1085 +++++++++++++ serverboot/file_io.c | 225 +++ serverboot/file_io.h | 174 ++ serverboot/fs.h | 455 ++++++ serverboot/gets.c | 90 ++ serverboot/kalloc.c | 274 ++++ serverboot/load.c | 406 +++++ serverboot/minix_ffs_compat.c | 62 + serverboot/minix_ffs_compat.h | 43 + serverboot/minix_file_io.c | 966 +++++++++++ serverboot/minix_fs.h | 107 ++ serverboot/minix_super.h | 49 + serverboot/panic.c | 59 + serverboot/queue.h | 316 ++++ serverboot/strfcns.c | 117 ++ serverboot/translate_root.c | 124 ++ serverboot/translate_root.h | 41 + serverboot/wiring.c | 140 ++ serverboot/wiring.h | 35 + 35 files changed, 11274 insertions(+) create mode 100644 serverboot/ChangeLog create mode 100644 serverboot/Makefile create mode 100644 serverboot/assert.h create mode 100644 serverboot/bootstrap.c create mode 100644 serverboot/def_pager_setup.c create mode 100644 serverboot/default_pager.c create mode 100644 serverboot/defs.h create mode 100644 serverboot/dir.h create mode 100644 serverboot/disk_inode.h create mode 100644 serverboot/disk_inode_ffs.h create mode 100644 serverboot/elf-load.c create mode 100644 serverboot/exec.c create mode 100644 serverboot/ext2_file_io.c create mode 100644 serverboot/ext2_fs.h create mode 100644 serverboot/ffs_compat.c create mode 100644 serverboot/ffs_compat.h create mode 100644 serverboot/ffs_file_io.c create mode 100644 serverboot/file_io.c create mode 100644 serverboot/file_io.h create mode 100644 serverboot/fs.h create mode 100644 serverboot/gets.c create mode 100644 serverboot/kalloc.c create mode 100644 serverboot/load.c create mode 100644 serverboot/minix_ffs_compat.c create mode 100644 serverboot/minix_ffs_compat.h create mode 100644 serverboot/minix_file_io.c create mode 100644 serverboot/minix_fs.h create mode 100644 serverboot/minix_super.h create mode 100644 serverboot/panic.c create mode 100644 serverboot/queue.h create mode 100644 serverboot/strfcns.c create mode 100644 serverboot/translate_root.c create mode 100644 serverboot/translate_root.h create mode 100644 serverboot/wiring.c create mode 100644 serverboot/wiring.h diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog new file mode 100644 index 00000000..52f60f35 --- /dev/null +++ b/serverboot/ChangeLog @@ -0,0 +1,53 @@ +Wed Mar 19 14:45:27 1997 Thomas Bushnell, n/BSG + + * panic.c (panic): Clear possible errors on stdout before printing + panic string. + +Mon Mar 17 13:13:50 1997 Thomas Bushnell, n/BSG + + * wiring.c (wire_all_memory): Don't attempt wire if PROTECTION is + VM_PROT_NONE. + + * panic.c (panic): Be more informative about where the error is + coming from. + + * default_pager.c (create_paging_partition): Don't print + gratuitous output noise. + * load.c (boot_script_exec_cmd): Likewise. + +Wed Mar 12 10:53:00 1997 Thomas Bushnell, n/BSG + + * ext2_file_io.c (ext2_open_file): Clear FP before beginning + work. + * ffs_file_io.c (ffs_open_file): Likewise. + * minix_file_io.c (minix_open_file): Likewise. + + * bootstrap.c (printf_init, safe_gets): New functions. + * console.c: Deleted file. + * Makefile (SRCS): Omit console.c and gets.c. + + * load.c (read_symtab_from_file): Comment out body of function. + We don't want this. + + * defs.h: Comment out redefinitions of common types. + + * default_pager.c: Include instead of + . + * file_io.h: Likewise. + * kalloc.c: Likewise. + + * panic.c: Include instead of . + + * default_pager.c (pager_read_offset): Cast return of NO_BLOCK + properly. + +Mon Mar 10 17:07:50 1997 Thomas Bushnell, n/BSG + + * load.c: Find boot_script.h in ../boot. + * bootstrap.c: Likewise. + + * bootstrap.c (boot_panic): Repair syntax. + + * strfcns.c: Include instead of . + * load.c: Likewise. + diff --git a/serverboot/Makefile b/serverboot/Makefile new file mode 100644 index 00000000..05a07d58 --- /dev/null +++ b/serverboot/Makefile @@ -0,0 +1,43 @@ +# Copyright (C) 1997 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 def_pager_setup.c \ + ffs_file_io.c minix_ffs_compat.c default_pager.c file_io.c\ + minix_file_io.c ext2_file_io.c kalloc.c strfcns.c exec.c \ + translate_root.c panic.c elf-load.c +OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ + default_pagerServer.o excServer.o bootstrapServer.o \ + memory_object_defaultServer.o +LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.h \ + minix_ffs_compat.h wiring.h dir.h ffs_compat.h minix_fs.h \ + disk_inode.h file_io.h minix_super.h translate_root.h +target = serverboot +HURDLIBS = threads + +vpath boot_script.c $(srcdir)/../boot + +MIGSFLAGS = -DSEQNOS + +LDFLAGS += -static + +include ../Makeconf + +# Don't even bother. +CFLAGS := $(filter-out -Wall,$(CFLAGS)) \ No newline at end of file diff --git a/serverboot/assert.h b/serverboot/assert.h new file mode 100644 index 00000000..9bcab69e --- /dev/null +++ b/serverboot/assert.h @@ -0,0 +1,50 @@ +/* + * 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 new file mode 100644 index 00000000..b603a55f --- /dev/null +++ b/serverboot/bootstrap.c @@ -0,0 +1,408 @@ +/* + * 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 +#include + +#include + +#include + +#include "../boot/boot_script.h" +#include "translate_root.h" + +/* + * 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 + +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(); + +/* initialized in default_pager_initialize */ +extern mach_port_t default_pager_exception_port; +extern mach_port_t default_pager_bootstrap_port; + +/* + * 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; + c = index (fgets (str, maxlen, stdin), '\n'); + *c = '\0'; +} + +printf_init (device_t master) +{ + mach_port_t cons; + device_open (master, D_READ|D_WRITE, "console", &cons); + 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 doing_default_pager = 0; + int script_paging_file (const struct cmd *cmd, int *val) + { + if (add_paging_file (bootstrap_master_device_port, cmd->path)) + { + printf ("(bootstrap): %s: Cannot add paging file\n", cmd->path); + return BOOT_SCRIPT_MACH_ERROR; + } + return 0; + } + int script_default_pager (const struct cmd *cmd, int *val) + { + default_pager_initialize(bootstrap_master_host_port); + doing_default_pager = 1; + return 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; + + static char new_root[16]; + + /* + * Use 4Kbyte cthread wait stacks. + */ + cthread_wait_stack_size = 4 * 1024; + + /* + * Parse the arguments. + */ + if (argc < 5) + panic("bootstrap: not enough arguments"); + + /* + * Arg 0 is program name + */ + + /* + * Arg 1 is flags + */ + if (argv[1][0] != '-') + panic("bootstrap: no flags"); + + flag_string = argv[1]; + + /* + * 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]; + + printf_init(bootstrap_master_device_port); +#ifdef pleasenoXXX + panic_init(bootstrap_master_host_port); +#endif + + if (root_name[0] == '\0') + root_name = DEFAULT_ROOT; + + /* + * If the '-a' (ask) switch was specified, ask for + * the root device. + */ + + if (index(flag_string, 'a')) { + printf("root device? [%s] ", root_name); + safe_gets(new_root, sizeof(new_root)); + } + + if (new_root[0] == '\0') + strcpy(new_root, root_name); + + root_name = translate_root(new_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_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 != 0) { + printf("Can't open server boot script %s: %d\n", + boot_script_name, + 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; + } + + /* + * Set up the default pager. + */ + partition_init(); + + { + /* Initialize boot script variables. */ + if (boot_script_set_variable ("host-port", VAL_PORT, + (int) bootstrap_master_host_port) + || boot_script_set_variable ("device-port", VAL_PORT, + (int) bootstrap_master_device_port) + || boot_script_set_variable ("root-device", VAL_STR, + (int) root_name) + || boot_script_set_variable ("boot-args", VAL_STR, + (int) flag_string) + || boot_script_define_function ("add-paging-file", VAL_NONE, + &script_paging_file) + || boot_script_define_function ("default-pager", VAL_NONE, + &script_default_pager) + ) + panic ("bootstrap: error setting boot script variables"); + + parse_script (&scriptf); + close_file (&scriptf); + } + + if (index (flag_string, 'd')) + { + char c; + printf ("Hit return to boot..."); + safe_gets (&c, 1); + } + + /* + * task_set_exception_port and task_set_bootstrap_port + * both require a send right. + */ + (void) mach_port_insert_right(my_task, default_pager_bootstrap_port, + default_pager_bootstrap_port, + MACH_MSG_TYPE_MAKE_SEND); + (void) mach_port_insert_right(my_task, default_pager_exception_port, + default_pager_exception_port, + MACH_MSG_TYPE_MAKE_SEND); + + /* + * Change our exception port. + */ + (void) task_set_exception_port(my_task, default_pager_exception_port); + + 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 + + if (! doing_default_pager) + task_terminate (mach_task_self ()); + + /* + * Become the default pager + */ + default_pager(); + /*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); + if (read_file (f, 0, buf, f->f_size, 0)) + panic ("bootstrap: error reading boot script file"); + + line = p = buf; + while (1) + { + while (p < buf + f->f_size && *p != '\n') + p++; + *p = '\0'; + err = boot_script_parse_line (line); + if (err) + boot_panic (err); + if (p == buf + f->f_size) + break; + line = ++p; + + } +} diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c new file mode 100644 index 00000000..fe6b33ab --- /dev/null +++ b/serverboot/def_pager_setup.c @@ -0,0 +1,136 @@ +/* + * 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 + +#include + +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) + mach_port_t master_device_port; + char *file_name; +{ + 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\n", file_name); + + result = add_file_direct(fdp, &pfile); + if (result) + panic("Can't read disk addresses: %d\n", result); + + close_file(&pfile); + + /* + * Set up the default paging partition + */ + create_paging_partition(file_name, fdp, isa_file); + + 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; +} + +/* + * 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; +} diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c new file mode 100644 index 00000000..6c44bd0d --- /dev/null +++ b/serverboot/default_pager.c @@ -0,0 +1,3536 @@ +/* + * 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. + */ +/* + * Default pager. Pages to paging partition. + * + * MUST BE ABLE TO ALLOCATE WIRED-DOWN MEMORY!!! + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include "file_io.h" + +#define debug 1 + +extern void *kalloc(); + +static char my_name[] = "(default pager):"; + +/* + * parallel vs serial switch + */ +#define PARALLEL 1 + +#if 0 +#define CHECKSUM 1 +#endif + +#define USE_PRECIOUS 1 + +#define ptoa(p) ((p)*vm_page_size) +#define atop(a) ((a)/vm_page_size) + +/* + + */ +/* + * Bitmap allocation. + */ +typedef unsigned int bm_entry_t; +#define NB_BM 32 +#define BM_MASK 0xffffffff + +#define howmany(a,b) (((a) + (b) - 1)/(b)) + +/* + * Value to indicate no block assigned + */ +#define NO_BLOCK ((vm_offset_t)-1) + +/* + * 'Partition' structure for each paging area. + * Controls allocation of blocks within paging area. + */ +struct part { + struct mutex p_lock; /* for bitmap/free */ + vm_size_t total_size; /* total number of blocks */ + vm_size_t free; /* number of blocks free */ + unsigned int id; /* named lookup */ + bm_entry_t *bitmap; /* allocation map */ + boolean_t going_away; /* destroy attempt in progress */ + struct file_direct *file; /* file paged to */ +}; +typedef struct part *partition_t; + +struct { + struct mutex lock; + int n_partitions; + partition_t *partition_list;/* array, for quick mapping */ +} all_partitions; /* list of all such */ + +typedef unsigned char p_index_t; + +#define P_INDEX_INVALID ((p_index_t)-1) + +#define no_partition(x) ((x) == P_INDEX_INVALID) + +partition_t partition_of(x) + int x; +{ + if (x >= all_partitions.n_partitions || x < 0) + panic("partition_of x%x", x); + return all_partitions.partition_list[x]; +} + +void set_partition_of(x, p) + int x; + partition_t p; +{ + if (x >= all_partitions.n_partitions || x < 0) + panic("set_partition_of x%x", x); + all_partitions.partition_list[x] = p; +} + +/* + * Simple mapping from (file)NAME to id + * Saves space, filenames can be long. + */ +unsigned int +part_id(name) + unsigned char *name; +{ + register unsigned int len, id, xorid; + + len = strlen(name); + id = xorid = 0; + while (len--) { + xorid ^= *name; + id += *name++; + } + return (id << 8) | xorid; +} + +partition_init() +{ + mutex_init(&all_partitions.lock); + all_partitions.n_partitions = 0; +} + +static partition_t +new_partition (const char *name, struct file_direct *fdp) +{ + register partition_t part; + register vm_size_t size, bmsize; + + size = atop(fdp->fd_size * fdp->fd_bsize); + bmsize = howmany(size, NB_BM) * sizeof(bm_entry_t); + + part = (partition_t) kalloc(sizeof(struct part)); + mutex_init(&part->p_lock); + part->total_size = size; + part->free = size; + part->id = part_id(name); + part->bitmap = (bm_entry_t *)kalloc(bmsize); + part->going_away= FALSE; + part->file = fdp; + + bzero((char *)part->bitmap, bmsize); + + return part; +} + +/* + * Create a partition descriptor, + * add it to the list of all such. + * size is in BYTES. + */ +void +create_paging_partition(const char *name, + struct file_direct *fdp, int isa_file) +{ + register partition_t part; + + part = new_partition (name, fdp); + + mutex_lock(&all_partitions.lock); + { + register int i; + + for (i = 0; i < all_partitions.n_partitions; i++) + if (partition_of(i) == 0) break; + + if (i == all_partitions.n_partitions) { + register partition_t *new_list, *old_list; + register int n; + + n = i ? (i<<1) : 2; + new_list = (partition_t *) + kalloc( n * sizeof(partition_t) ); + if (new_list == 0) no_paging_space(TRUE); + bzero(new_list, n*sizeof(partition_t)); + if (i) { + old_list = all_partitions.partition_list; + bcopy(old_list, new_list, i*sizeof(partition_t)); + } + all_partitions.partition_list = new_list; + all_partitions.n_partitions = n; + if (i) kfree(old_list, i*sizeof(partition_t)); + } + set_partition_of(i, part); + } + mutex_unlock(&all_partitions.lock); + +#if 0 + printf("%s Added paging %s %s\n", my_name, + (isa_file) ? "file" : "device", name); +#endif + overcommitted(TRUE, part->free); +} + +/* + * Choose the most appropriate default partition + * for an object of SIZE bytes. + * Return the partition locked, unless + * the object has no CUR_PARTition. + */ +p_index_t +choose_partition(size, cur_part) + unsigned int size; + register p_index_t cur_part; +{ + register partition_t part; + register boolean_t found = FALSE; + register int i; + + mutex_lock(&all_partitions.lock); + for (i = 0; i < all_partitions.n_partitions; i++) { + + /* the undesireable one ? */ + if (i == cur_part) + continue; + + /* one that was removed ? */ + if ((part = partition_of(i)) == 0) + continue; + + /* one that is being removed ? */ + if (part->going_away) + continue; + + /* is it big enough ? */ + mutex_lock(&part->p_lock); + if (ptoa(part->free) >= size) { + if (cur_part != P_INDEX_INVALID) { + mutex_unlock(&all_partitions.lock); + return (p_index_t)i; + } else + found = TRUE; + } + mutex_unlock(&part->p_lock); + + if (found) break; + } + mutex_unlock(&all_partitions.lock); + return (found) ? (p_index_t)i : P_INDEX_INVALID; +} + +/* + * Allocate a page in a paging partition + * The partition is returned unlocked. + */ +vm_offset_t +pager_alloc_page(pindex, lock_it) + p_index_t pindex; +{ + register int bm_e; + register int bit; + register int limit; + register bm_entry_t *bm; + partition_t part; + static char here[] = "%spager_alloc_page"; + + if (no_partition(pindex)) + return (NO_BLOCK); + part = partition_of(pindex); + + /* unlikely, but possible deadlock against destroy_partition */ + if (!part || part->going_away) + return (NO_BLOCK); + + if (lock_it) + mutex_lock(&part->p_lock); + + if (part->free == 0) { + /* out of paging space */ + mutex_unlock(&part->p_lock); + return (NO_BLOCK); + } + + limit = howmany(part->total_size, NB_BM); + bm = part->bitmap; + for (bm_e = 0; bm_e < limit; bm_e++, bm++) + if (*bm != BM_MASK) + break; + + if (bm_e == limit) + panic(here,my_name); + + /* + * Find and set the proper bit + */ + { + register bm_entry_t b = *bm; + + for (bit = 0; bit < NB_BM; bit++) + if ((b & (1<free--; + + } + + mutex_unlock(&part->p_lock); + + return (bm_e*NB_BM+bit); +} + +/* + * Deallocate a page in a paging partition + */ +void +pager_dealloc_page(pindex, page, lock_it) + p_index_t pindex; + register vm_offset_t page; +{ + register partition_t part; + register int bit, bm_e; + + /* be paranoid */ + if (no_partition(pindex)) + panic("%sdealloc_page",my_name); + part = partition_of(pindex); + + if (page >= part->total_size) + panic("%sdealloc_page",my_name); + + bm_e = page / NB_BM; + bit = page % NB_BM; + + if (lock_it) + mutex_lock(&part->p_lock); + + part->bitmap[bm_e] &= ~(1<free++; + + if (lock_it) + mutex_unlock(&part->p_lock); +} + +/* + + */ +/* + * Allocation info for each paging object. + * + * Most operations, even pager_write_offset and pager_put_checksum, + * just need a read lock. Higher-level considerations prevent + * conflicting operations on a single page. The lock really protects + * the underlying size and block map memory, so pager_extend needs a + * write lock. + * + * An object can now span multiple paging partitions. The allocation + * info we keep is a pair (offset,p_index) where the index is in the + * array of all partition ptrs, and the offset is partition-relative. + * Size wise we are doing ok fitting the pair into a single integer: + * the offset really is in pages so we have vm_page_size bits available + * for the partition index. + */ +#define DEBUG_READER_CONFLICTS 0 + +#if DEBUG_READER_CONFLICTS +int default_pager_read_conflicts = 0; +#endif + +union dp_map { + + struct { + unsigned int p_offset : 24, + p_index : 8; + } block; + + union dp_map *indirect; +}; +typedef union dp_map *dp_map_t; + +/* quick check for part==block==invalid */ +#define no_block(e) ((e).indirect == (dp_map_t)NO_BLOCK) +#define invalidate_block(e) ((e).indirect = (dp_map_t)NO_BLOCK) + +struct dpager { + struct mutex lock; /* lock for extending block map */ + /* XXX should be read-write lock */ +#if DEBUG_READER_CONFLICTS + int readers; + boolean_t writer; +#endif + dp_map_t map; /* block map */ + vm_size_t size; /* size of paging object, in pages */ + p_index_t cur_partition; +#ifdef CHECKSUM + vm_offset_t *checksum; /* checksum - parallel to block map */ +#define NO_CHECKSUM ((vm_offset_t)-1) +#endif CHECKSUM +}; +typedef struct dpager *dpager_t; + +/* + * A paging object uses either a one- or a two-level map of offsets + * into a paging partition. + */ +#define PAGEMAP_ENTRIES 64 + /* number of pages in a second-level map */ +#define PAGEMAP_SIZE(npgs) ((npgs)*sizeof(vm_offset_t)) + +#define INDIRECT_PAGEMAP_ENTRIES(npgs) \ + ((((npgs)-1)/PAGEMAP_ENTRIES) + 1) +#define INDIRECT_PAGEMAP_SIZE(npgs) \ + (INDIRECT_PAGEMAP_ENTRIES(npgs) * sizeof(vm_offset_t *)) +#define INDIRECT_PAGEMAP(size) \ + (size > PAGEMAP_ENTRIES) + +#define ROUNDUP_TO_PAGEMAP(npgs) \ + (((npgs) + PAGEMAP_ENTRIES - 1) & ~(PAGEMAP_ENTRIES - 1)) + +/* + * Object sizes are rounded up to the next power of 2, + * unless they are bigger than a given maximum size. + */ +vm_size_t max_doubled_size = 4 * 1024 * 1024; /* 4 meg */ + +/* + * Attach a new paging object to a paging partition + */ +void +pager_alloc(pager, part, size) + register dpager_t pager; + p_index_t part; + register vm_size_t size; /* in BYTES */ +{ + register int i; + register dp_map_t mapptr, emapptr; + + mutex_init(&pager->lock); +#if DEBUG_READER_CONFLICTS + pager->readers = 0; + pager->writer = FALSE; +#endif + pager->cur_partition = part; + + /* + * Convert byte size to number of pages, then increase to the nearest + * power of 2. + */ + size = atop(size); + if (size <= atop(max_doubled_size)) { + i = 1; + while (i < size) + i <<= 1; + size = i; + } 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->size = size; + +#ifdef CHECKSUM + if (INDIRECT_PAGEMAP(size)) { + mapptr = (vm_offset_t *) + kalloc(INDIRECT_PAGEMAP_SIZE(size)); + for (i = INDIRECT_PAGEMAP_ENTRIES(size); --i >= 0;) + mapptr[i] = 0; + } else { + mapptr = (vm_offset_t *) kalloc(PAGEMAP_SIZE(size)); + for (i = 0; i < size; i++) + mapptr[i] = NO_CHECKSUM; + } + pager->checksum = mapptr; +#endif CHECKSUM +} + +/* + * Return size (in bytes) of space actually allocated to this pager. + * The pager is read-locked. + */ + +vm_size_t +pager_allocated(pager) + register dpager_t pager; +{ + vm_size_t size; + register dp_map_t map, emap; + vm_size_t asize; + + size = pager->size; /* in pages */ + asize = 0; /* allocated, in pages */ + map = pager->map; + + if (INDIRECT_PAGEMAP(size)) { + for (emap = &map[INDIRECT_PAGEMAP_ENTRIES(size)]; + map < emap; map++) { + + register dp_map_t map2, emap2; + + if ((map2 = map->indirect) == 0) + continue; + + for (emap2 = &map2[PAGEMAP_ENTRIES]; + map2 < emap2; map2++) + if ( ! no_block(*map2) ) + asize++; + + } + } else { + for (emap = &map[size]; map < emap; map++) + if ( ! no_block(*map) ) + asize++; + } + + return ptoa(asize); +} + +/* + * Find offsets (in the object) of pages actually allocated to this pager. + * Returns the number of allocated pages, whether or not they all fit. + * The pager is read-locked. + */ + +unsigned int +pager_pages(pager, pages, numpages) + dpager_t pager; + register default_pager_page_t *pages; + unsigned int numpages; +{ + vm_size_t size; + dp_map_t map, emap; + unsigned int actual; + vm_offset_t offset; + + size = pager->size; /* in pages */ + map = pager->map; + actual = 0; + offset = 0; + + if (INDIRECT_PAGEMAP(size)) { + for (emap = &map[INDIRECT_PAGEMAP_ENTRIES(size)]; + map < emap; map++) { + + register dp_map_t map2, emap2; + + if ((map2 = map->indirect) == 0) { + offset += vm_page_size * PAGEMAP_ENTRIES; + continue; + } + for (emap2 = &map2[PAGEMAP_ENTRIES]; + map2 < emap2; map2++) + if ( ! no_block(*map2) ) { + if (actual++ < numpages) + pages++->dpp_offset = offset; + } + offset += vm_page_size; + } + } else { + for (emap = &map[size]; map < emap; map++) + if ( ! no_block(*map) ) { + if (actual++ < numpages) + pages++->dpp_offset = offset; + } + offset += vm_page_size; + } + return actual; +} + +/* + * Extend the map for a paging object. + * + * XXX This implementation can allocate an arbitrary large amount + * of wired memory when extending a big block map. Because vm-privileged + * threads call pager_extend, this can crash the system by exhausting + * system memory. + */ +void +pager_extend(pager, new_size) + register dpager_t pager; + register vm_size_t new_size; /* in pages */ +{ + register dp_map_t new_mapptr; + register dp_map_t old_mapptr; + register int i; + register vm_size_t old_size; + + mutex_lock(&pager->lock); /* XXX lock_write */ +#if DEBUG_READER_CONFLICTS + pager->writer = TRUE; +#endif + /* + * Double current size until we cover new size. + * If object is 'too big' just use new size. + */ + old_size = pager->size; + + if (new_size <= atop(max_doubled_size)) { + i = old_size; + while (i < new_size) + i <<= 1; + new_size = i; + } else + new_size = ROUNDUP_TO_PAGEMAP(new_size); + + if (INDIRECT_PAGEMAP(old_size)) { + /* + * Pager already uses two levels. Allocate + * a larger indirect block. + */ + new_mapptr = (dp_map_t) + kalloc(INDIRECT_PAGEMAP_SIZE(new_size)); + old_mapptr = pager->map; + for (i = 0; i < INDIRECT_PAGEMAP_ENTRIES(old_size); i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++) + new_mapptr[i].indirect = (dp_map_t)0; + kfree((char *)old_mapptr, INDIRECT_PAGEMAP_SIZE(old_size)); + pager->map = new_mapptr; + pager->size = new_size; +#ifdef CHECKSUM + new_mapptr = (vm_offset_t *) + kalloc(INDIRECT_PAGEMAP_SIZE(new_size)); + old_mapptr = pager->checksum; + for (i = 0; i < INDIRECT_PAGEMAP_ENTRIES(old_size); i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++) + new_mapptr[i] = 0; + kfree((char *)old_mapptr, INDIRECT_PAGEMAP_SIZE(old_size)); + pager->checksum = new_mapptr; +#endif CHECKSUM +#if DEBUG_READER_CONFLICTS + pager->writer = FALSE; +#endif + mutex_unlock(&pager->lock); + return; + } + + if (INDIRECT_PAGEMAP(new_size)) { + /* + * Changing from direct map to indirect map. + * Allocate both indirect and direct map blocks, + * since second-level (direct) block must be + * full size (PAGEMAP_SIZE(PAGEMAP_ENTRIES)). + */ + + /* + * Allocate new second-level map first. + */ + new_mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + old_mapptr = pager->map; + for (i = 0; i < old_size; i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < PAGEMAP_ENTRIES; i++) + invalidate_block(new_mapptr[i]); + kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); + old_mapptr = new_mapptr; + + /* + * Now allocate indirect map. + */ + new_mapptr = (dp_map_t) + kalloc(INDIRECT_PAGEMAP_SIZE(new_size)); + new_mapptr[0].indirect = old_mapptr; + for (i = 1; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++) + new_mapptr[i].indirect = 0; + pager->map = new_mapptr; + pager->size = new_size; +#ifdef CHECKSUM + /* + * Allocate new second-level map first. + */ + new_mapptr = (vm_offset_t *)kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + old_mapptr = pager->checksum; + for (i = 0; i < old_size; i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < PAGEMAP_ENTRIES; i++) + new_mapptr[i] = NO_CHECKSUM; + kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); + old_mapptr = new_mapptr; + + /* + * Now allocate indirect map. + */ + new_mapptr = (vm_offset_t *) + kalloc(INDIRECT_PAGEMAP_SIZE(new_size)); + new_mapptr[0] = (vm_offset_t) old_mapptr; + for (i = 1; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++) + new_mapptr[i] = 0; + pager->checksum = new_mapptr; +#endif CHECKSUM +#if DEBUG_READER_CONFLICTS + pager->writer = FALSE; +#endif + mutex_unlock(&pager->lock); + return; + } + /* + * Enlarging a direct block. + */ + new_mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(new_size)); + old_mapptr = pager->map; + for (i = 0; i < old_size; i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < new_size; i++) + invalidate_block(new_mapptr[i]); + kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); + pager->map = new_mapptr; + pager->size = new_size; +#ifdef CHECKSUM + new_mapptr = (vm_offset_t *) + kalloc(PAGEMAP_SIZE(new_size)); + old_mapptr = pager->checksum; + for (i = 0; i < old_size; i++) + new_mapptr[i] = old_mapptr[i]; + for (; i < new_size; i++) + new_mapptr[i] = NO_CHECKSUM; + kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); + pager->checksum = new_mapptr; +#endif CHECKSUM +#if DEBUG_READER_CONFLICTS + pager->writer = FALSE; +#endif + mutex_unlock(&pager->lock); +} + +/* + * Given an offset within a paging object, find the + * corresponding block within the paging partition. + * Return NO_BLOCK if none allocated. + */ +union dp_map +pager_read_offset(pager, offset) + register dpager_t pager; + vm_offset_t offset; +{ + register vm_offset_t f_page; + union dp_map pager_offset; + + f_page = atop(offset); + +#if DEBUG_READER_CONFLICTS + if (pager->readers > 0) + default_pager_read_conflicts++; /* would have proceeded with + read/write lock */ +#endif + mutex_lock(&pager->lock); /* XXX lock_read */ +#if DEBUG_READER_CONFLICTS + pager->readers++; +#endif + if (f_page >= pager->size) + { + printf ("%spager_read_offset pager %x: bad page %d >= size %d", + my_name, pager, f_page, pager->size); + return (union dp_map *) NO_BLOCK; +#if 0 + panic("%spager_read_offset",my_name); +#endif + } + + 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]; + } + else { + pager_offset = pager->map[f_page]; + } + +#if DEBUG_READER_CONFLICTS + pager->readers--; +#endif + mutex_unlock(&pager->lock); + return (pager_offset); +} + +#if USE_PRECIOUS +/* + * Release a single disk block. + */ +pager_release_offset(pager, offset) + register dpager_t pager; + vm_offset_t offset; +{ + register union dp_map entry; + + offset = atop(offset); + + mutex_lock(&pager->lock); /* XXX lock_read */ + + if (INDIRECT_PAGEMAP(pager->size)) { + register dp_map_t mapptr; + + mapptr = pager->map[offset / PAGEMAP_ENTRIES].indirect; + entry = mapptr[offset % PAGEMAP_ENTRIES]; + invalidate_block(mapptr[offset % PAGEMAP_ENTRIES]); + } else { + entry = pager->map[offset]; + invalidate_block(pager->map[offset]); + } + + mutex_unlock(&pager->lock); + + pager_dealloc_page(entry.block.p_index, entry.block.p_offset, TRUE); +} +#endif /*USE_PRECIOUS*/ + + +/* + * Move a page from one partition to another + * New partition is locked, old partition is + * locked unless LOCK_OLD sez otherwise. + */ +union dp_map +pager_move_page(block) + union dp_map block; +{ + partition_t old_part, new_part; + p_index_t old_pindex, new_pindex; + union dp_map ret; + vm_size_t size; + vm_offset_t raddr, offset, new_offset; + kern_return_t rc; + static char here[] = "%spager_move_page"; + + old_pindex = block.block.p_index; + invalidate_block(ret); + + /* See if we have room to put it anywhere else */ + new_pindex = choose_partition( ptoa(1), old_pindex); + if (no_partition(new_pindex)) + return ret; + + /* this unlocks the new partition */ + new_offset = pager_alloc_page(new_pindex, FALSE); + if (new_offset == NO_BLOCK) + panic(here,my_name); + + /* + * Got the resources, now move the data + */ + old_part = partition_of(old_pindex); + offset = ptoa(block.block.p_offset); + rc = page_read_file_direct (old_part->file, + offset, + vm_page_size, + &raddr, + &size); + if (rc != 0) + panic(here,my_name); + + /* release old */ + pager_dealloc_page(old_pindex, block.block.p_offset, FALSE); + + new_part = partition_of(new_pindex); + offset = ptoa(new_offset); + rc = page_write_file_direct (new_part->file, + offset, + raddr, + size, + &size); + if (rc != 0) + panic(here,my_name); + + (void) vm_deallocate( mach_task_self(), raddr, size); + + ret.block.p_offset = new_offset; + ret.block.p_index = new_pindex; + + return ret; +} + +#ifdef CHECKSUM +/* + * Return the checksum for a block. + */ +int +pager_get_checksum(pager, offset) + register dpager_t pager; + vm_offset_t offset; +{ + register vm_offset_t f_page; + int checksum; + + f_page = atop(offset); + + mutex_lock(&pager->lock); /* XXX lock_read */ + if (f_page >= pager->size) + panic("%spager_get_checksum",my_name); + + if (INDIRECT_PAGEMAP(pager->size)) { + register vm_offset_t *mapptr; + + mapptr = (vm_offset_t *)pager->checksum[f_page/PAGEMAP_ENTRIES]; + if (mapptr == 0) + checksum = NO_CHECKSUM; + else + checksum = mapptr[f_page%PAGEMAP_ENTRIES]; + } + else { + checksum = pager->checksum[f_page]; + } + + mutex_unlock(&pager->lock); + return (checksum); +} + +/* + * Remember the checksum for a block. + */ +int +pager_put_checksum(pager, offset, checksum) + register dpager_t pager; + vm_offset_t offset; + int checksum; +{ + register vm_offset_t f_page; + static char here[] = "%spager_put_checksum"; + + f_page = atop(offset); + + mutex_lock(&pager->lock); /* XXX lock_read */ + if (f_page >= pager->size) + panic(here,my_name); + + if (INDIRECT_PAGEMAP(pager->size)) { + register vm_offset_t *mapptr; + + mapptr = (vm_offset_t *)pager->checksum[f_page/PAGEMAP_ENTRIES]; + if (mapptr == 0) + panic(here,my_name); + + mapptr[f_page%PAGEMAP_ENTRIES] = checksum; + } + else { + pager->checksum[f_page] = checksum; + } + mutex_unlock(&pager->lock); +} + +/* + * Compute a checksum - XOR each 32-bit word. + */ +int +compute_checksum(addr, size) + vm_offset_t addr; + vm_size_t size; +{ + register int checksum = NO_CHECKSUM; + register int *ptr; + register int count; + + ptr = (int *)addr; + count = size / sizeof(int); + + while (--count >= 0) + checksum ^= *ptr++; + + return (checksum); +} +#endif CHECKSUM + +/* + * Given an offset within a paging object, find the + * corresponding block within the paging partition. + * Allocate a new block if necessary. + * + * WARNING: paging objects apparently may be extended + * without notice! + */ +union dp_map +pager_write_offset(pager, offset) + register dpager_t pager; + vm_offset_t offset; +{ + register vm_offset_t f_page; + register dp_map_t mapptr; + register union dp_map block; + + invalidate_block(block); + + f_page = atop(offset); + +#if DEBUG_READER_CONFLICTS + if (pager->readers > 0) + default_pager_read_conflicts++; /* would have proceeded with + read/write lock */ +#endif + mutex_lock(&pager->lock); /* XXX lock_read */ +#if DEBUG_READER_CONFLICTS + pager->readers++; +#endif + + /* Catch the case where we had no initial fit partition + for this object, but one was added later on */ + if (no_partition(pager->cur_partition)) { + p_index_t new_part; + vm_size_t size; + + size = (f_page > pager->size) ? f_page : pager->size; + new_part = choose_partition(ptoa(size), P_INDEX_INVALID); + if (no_partition(new_part)) + new_part = choose_partition(ptoa(1), P_INDEX_INVALID); + if (no_partition(new_part)) + /* give up right now to avoid confusion */ + goto out; + else + pager->cur_partition = new_part; + } + + while (f_page >= pager->size) { + /* + * Paging object must be extended. + * Remember that offset is 0-based, but size is 1-based. + */ +#if DEBUG_READER_CONFLICTS + pager->readers--; +#endif + mutex_unlock(&pager->lock); + pager_extend(pager, f_page + 1); +#if DEBUG_READER_CONFLICTS + if (pager->readers > 0) + default_pager_read_conflicts++; /* would have proceeded with + read/write lock */ +#endif + mutex_lock(&pager->lock); /* XXX lock_read */ +#if DEBUG_READER_CONFLICTS + pager->readers++; +#endif + } + + if (INDIRECT_PAGEMAP(pager->size)) { + + mapptr = pager->map[f_page/PAGEMAP_ENTRIES].indirect; + if (mapptr == 0) { + /* + * Allocate the indirect block + */ + register int i; + + mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + if (mapptr == 0) { + /* out of space! */ + no_paging_space(TRUE); + goto out; + } + pager->map[f_page/PAGEMAP_ENTRIES].indirect = mapptr; + for (i = 0; i < PAGEMAP_ENTRIES; i++) + invalidate_block(mapptr[i]); +#ifdef CHECKSUM + { + register vm_offset_t *cksumptr; + register int j; + + cksumptr = (vm_offset_t *) + kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + if (cksumptr == 0) { + /* out of space! */ + no_paging_space(TRUE); + goto out; + } + pager->checksum[f_page/PAGEMAP_ENTRIES] + = (vm_offset_t)cksumptr; + for (j = 0; j < PAGEMAP_ENTRIES; j++) + cksumptr[j] = NO_CHECKSUM; + } +#endif CHECKSUM + } + f_page %= PAGEMAP_ENTRIES; + } + else { + mapptr = pager->map; + } + + block = mapptr[f_page]; + if (no_block(block)) { + vm_offset_t off; + + /* get room now */ + off = pager_alloc_page(pager->cur_partition, TRUE); + if (off == NO_BLOCK) { + /* + * Before giving up, try all other partitions. + */ + p_index_t new_part; + + /* returns it locked (if any one is non-full) */ + new_part = choose_partition( ptoa(1), pager->cur_partition); + if ( ! no_partition(new_part) ) { + +#if debug +printf("%s partition %x filled,", my_name, pager->cur_partition); +printf("extending object %x (size %x) to %x.\n", + pager, pager->size, new_part); +#endif + + /* this one tastes better */ + pager->cur_partition = new_part; + + /* this unlocks the partition too */ + off = pager_alloc_page(pager->cur_partition, FALSE); + + } + + if (off == NO_BLOCK) { + /* + * Oh well. + */ + overcommitted(FALSE, 1); + goto out; + } + } + block.block.p_offset = off; + block.block.p_index = pager->cur_partition; + mapptr[f_page] = block; + } + +out: + +#if DEBUG_READER_CONFLICTS + pager->readers--; +#endif + mutex_unlock(&pager->lock); + return (block); +} + +/* + * Deallocate all of the blocks belonging to a paging object. + * No locking needed because no other operations can be in progress. + */ +void +pager_dealloc(pager) + register dpager_t pager; +{ + register int i, j; + register dp_map_t mapptr; + register union dp_map block; + + if (INDIRECT_PAGEMAP(pager->size)) { + for (i = INDIRECT_PAGEMAP_ENTRIES(pager->size); --i >= 0; ) { + mapptr = pager->map[i].indirect; + if (mapptr != 0) { + for (j = 0; j < PAGEMAP_ENTRIES; j++) { + block = mapptr[j]; + if ( ! no_block(block) ) + pager_dealloc_page(block.block.p_index, + block.block.p_offset, TRUE); + } + kfree((char *)mapptr, PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + } + } + kfree((char *)pager->map, INDIRECT_PAGEMAP_SIZE(pager->size)); +#ifdef CHECKSUM + for (i = INDIRECT_PAGEMAP_ENTRIES(pager->size); --i >= 0; ) { + mapptr = (vm_offset_t *)pager->checksum[i]; + if (mapptr) { + kfree((char *)mapptr, PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + } + } + kfree((char *)pager->checksum, + INDIRECT_PAGEMAP_SIZE(pager->size)); +#endif CHECKSUM + } + else { + mapptr = pager->map; + for (i = 0; i < pager->size; i++ ) { + block = mapptr[i]; + if ( ! no_block(block) ) + pager_dealloc_page(block.block.p_index, + block.block.p_offset, TRUE); + } + kfree((char *)pager->map, PAGEMAP_SIZE(pager->size)); +#ifdef CHECKSUM + kfree((char *)pager->checksum, PAGEMAP_SIZE(pager->size)); +#endif CHECKSUM + } +} + +/* + * Move all the pages of a PAGER that live in a + * partition PINDEX somewhere else. + * Pager should be write-locked, partition too. + * Returns FALSE if it could not do it, but + * some pages might have been moved nonetheless. + */ +boolean_t +pager_realloc(pager, pindex) + register dpager_t pager; + p_index_t pindex; +{ + register dp_map_t map, emap; + vm_size_t size; + union dp_map block; + + size = pager->size; /* in pages */ + map = pager->map; + + if (INDIRECT_PAGEMAP(size)) { + for (emap = &map[INDIRECT_PAGEMAP_ENTRIES(size)]; + map < emap; map++) { + + register dp_map_t map2, emap2; + + if ((map2 = map->indirect) == 0) + continue; + + for (emap2 = &map2[PAGEMAP_ENTRIES]; + map2 < emap2; map2++) + if ( map2->block.p_index == pindex) { + + block = pager_move_page(*map2); + if (!no_block(block)) + *map2 = block; + else + return FALSE; + } + + } + goto ok; + } + + /* A small one */ + for (emap = &map[size]; map < emap; map++) + if (map->block.p_index == pindex) { + block = pager_move_page(*map); + if (!no_block(block)) + *map = block; + else + return FALSE; + } +ok: + pager->cur_partition = choose_partition(0, P_INDEX_INVALID); + return TRUE; +} + +/* + + */ + +/* + * Read/write routines. + */ +#define PAGER_SUCCESS 0 +#define PAGER_ABSENT 1 +#define PAGER_ERROR 2 + +/* + * Read data from a default pager. Addr is the address of a buffer + * to fill. Out_addr returns the buffer that contains the data; + * if it is different from , it must be deallocated after use. + */ +int +default_read(ds, addr, size, offset, out_addr, deallocate) + register dpager_t ds; + vm_offset_t addr; /* pointer to block to fill */ + register vm_size_t size; + register vm_offset_t offset; + vm_offset_t *out_addr; + /* returns pointer to data */ + boolean_t deallocate; +{ + register union dp_map block; + vm_offset_t raddr; + vm_size_t rsize; + register int rc; + boolean_t first_time; + register partition_t part; +#ifdef CHECKSUM + vm_size_t original_size = size; +#endif CHECKSUM + vm_offset_t original_offset = offset; + + /* + * Find the block in the paging partition + */ + block = pager_read_offset(ds, offset); + if ( no_block(block) ) + return (PAGER_ABSENT); + + /* + * Read it, trying for the entire page. + */ + offset = ptoa(block.block.p_offset); + part = partition_of(block.block.p_index); + first_time = TRUE; + *out_addr = addr; + + do { + rc = page_read_file_direct(part->file, + offset, + size, + &raddr, + &rsize); + if (rc != 0) + return (PAGER_ERROR); + + /* + * If we got the entire page on the first read, return it. + */ + if (first_time && rsize == size) { + *out_addr = raddr; + break; + } + /* + * Otherwise, copy the data into the + * buffer we were passed, and try for + * the next piece. + */ + first_time = FALSE; + bcopy((char *)raddr, (char *)addr, rsize); + addr += rsize; + offset += rsize; + size -= rsize; + } while (size != 0); + +#if USE_PRECIOUS + if (deallocate) + pager_release_offset(ds, original_offset); +#endif /*USE_PRECIOUS*/ + +#ifdef CHECKSUM + { + int write_checksum, + read_checksum; + + write_checksum = pager_get_checksum(ds, original_offset); + read_checksum = compute_checksum(*out_addr, original_size); + if (write_checksum != read_checksum) { + panic( + "PAGER CHECKSUM ERROR: offset 0x%x, written 0x%x, read 0x%x", + original_offset, write_checksum, read_checksum); + } + } +#endif CHECKSUM + return (PAGER_SUCCESS); +} + +int +default_write(ds, addr, size, offset) + register dpager_t ds; + register vm_offset_t addr; + register vm_size_t size; + register vm_offset_t offset; +{ + register union dp_map block; + partition_t part; + vm_size_t wsize; + register int rc; + + /* + * Find block in paging partition + */ + block = pager_write_offset(ds, offset); + if ( no_block(block) ) + return (PAGER_ERROR); + +#ifdef CHECKSUM + /* + * Save checksum + */ + { + int checksum; + + checksum = compute_checksum(addr, size); + pager_put_checksum(ds, offset, checksum); + } +#endif CHECKSUM + offset = ptoa(block.block.p_offset); + part = partition_of(block.block.p_index); + + /* + * There are various assumptions made here,we + * will not get into the next disk 'block' by + * accident. It might well be non-contiguous. + */ + do { + rc = page_write_file_direct(part->file, + offset, + addr, + size, + &wsize); + if (rc != 0) { + printf("*** PAGER ERROR: default_write: "); + printf("ds=0x%x addr=0x%x size=0x%x offset=0x%x resid=0x%x\n", + ds, addr, size, offset, wsize); + return (PAGER_ERROR); + } + addr += wsize; + offset += wsize; + size -= wsize; + } while (size != 0); + return (PAGER_SUCCESS); +} + +boolean_t +default_has_page(ds, offset) + dpager_t ds; + vm_offset_t offset; +{ + return ( ! no_block(pager_read_offset(ds, offset)) ); +} + +/* + + */ + +/* + * Mapping between pager port and paging object. + */ +struct dstruct { + queue_chain_t links; /* Link in pager-port list */ + + struct mutex lock; /* Lock for the structure */ + struct condition + waiting_seqno, /* someone waiting on seqno */ + waiting_read, /* someone waiting on readers */ + waiting_write, /* someone waiting on writers */ + waiting_refs; /* someone waiting on refs */ + + memory_object_t pager; /* Pager port */ + mach_port_seqno_t seqno; /* Pager port sequence number */ + mach_port_t pager_request; /* Request port */ + mach_port_urefs_t request_refs; /* Request port user-refs */ + mach_port_t pager_name; /* Name port */ + mach_port_urefs_t name_refs; /* Name port user-refs */ + + unsigned int readers; /* Reads in progress */ + unsigned int writers; /* Writes in progress */ + + unsigned int errors; /* Pageout error count */ + struct dpager dpager; /* Actual pager */ +}; +typedef struct dstruct * default_pager_t; +#define DEFAULT_PAGER_NULL ((default_pager_t)0) + +#if PARALLEL +#define dstruct_lock_init(ds) mutex_init(&ds->lock) +#define dstruct_lock(ds) mutex_lock(&ds->lock) +#define dstruct_unlock(ds) mutex_unlock(&ds->lock) +#else /* PARALLEL */ +#define dstruct_lock_init(ds) +#define dstruct_lock(ds) +#define dstruct_unlock(ds) +#endif /* PARALLEL */ + +/* + * List of all pagers. A specific pager is + * found directly via its port, this list is + * only used for monitoring purposes by the + * default_pager_object* calls + */ +struct pager_port { + queue_head_t queue; + struct mutex lock; + int count; /* saves code */ + queue_head_t leak_queue; +} all_pagers; + +#define pager_port_list_init() \ +{ \ + mutex_init(&all_pagers.lock); \ + queue_init(&all_pagers.queue); \ + queue_init(&all_pagers.leak_queue); \ + all_pagers.count = 0; \ +} + +void pager_port_list_insert(port, ds) + mach_port_t port; + default_pager_t ds; +{ + mutex_lock(&all_pagers.lock); + queue_enter(&all_pagers.queue, ds, default_pager_t, links); + all_pagers.count++; + mutex_unlock(&all_pagers.lock); +} + +/* given a data structure return a good port-name to associate it to */ +#define pnameof(_x_) (((vm_offset_t)(_x_))+1) +/* reverse, assumes no-odd-pointers */ +#define dnameof(_x_) (((vm_offset_t)(_x_))&~1) + +/* The magic typecast */ +#define pager_port_lookup(_port_) \ + ((! MACH_PORT_VALID(_port_) || \ + ((default_pager_t)dnameof(_port_))->pager != (_port_)) ? \ + DEFAULT_PAGER_NULL : (default_pager_t)dnameof(_port_)) + +void pager_port_list_delete(ds) + default_pager_t ds; +{ + mutex_lock(&all_pagers.lock); + queue_remove(&all_pagers.queue, ds, default_pager_t, links); + all_pagers.count--; + mutex_unlock(&all_pagers.lock); +} + +/* + * Destroy a paging partition. + * XXX this is not re-entrant XXX + */ +kern_return_t +destroy_paging_partition(name, pp_private) + char *name; + void **pp_private; +{ + register unsigned int id = part_id(name); + register partition_t part; + boolean_t all_ok = TRUE; + default_pager_t entry; + int pindex; + + /* + * Find and take partition out of list + * This prevents choose_partition from + * getting in the way. + */ + mutex_lock(&all_partitions.lock); + for (pindex = 0; pindex < all_partitions.n_partitions; pindex++) { + part = partition_of(pindex); + if (part && (part->id == id)) break; + } + if (pindex == all_partitions.n_partitions) { + mutex_unlock(&all_partitions.lock); + return KERN_INVALID_ARGUMENT; + } + part->going_away = TRUE; + mutex_unlock(&all_partitions.lock); + + /* + * This might take a while.. + */ +all_over_again: +#if debug +printf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok); +#endif + all_ok = TRUE; + mutex_lock(&part->p_lock); + + mutex_lock(&all_pagers.lock); + queue_iterate(&all_pagers.queue, entry, default_pager_t, links) { + + dstruct_lock(entry); + + if (!mutex_try_lock(&entry->dpager.lock)) { + + dstruct_unlock(entry); + mutex_unlock(&all_pagers.lock); + mutex_unlock(&part->p_lock); + + /* yield the processor */ + (void) thread_switch(MACH_PORT_NULL, + SWITCH_OPTION_NONE, 0); + + goto all_over_again; + + } + + /* + * See if we can relocate all the pages of this object + * currently on this partition on some other partition + */ + all_ok = pager_realloc(&entry->dpager, pindex); + + mutex_unlock(&entry->dpager.lock); + dstruct_unlock(entry); + + if (!all_ok) break; + + } + mutex_unlock(&all_pagers.lock); + + if (all_ok) { + /* No need to unlock partition, there are no refs left */ + + set_partition_of(pindex, 0); + *pp_private = part->file; + kfree(part->bitmap, howmany(part->total_size, NB_BM) * sizeof(bm_entry_t)); + kfree(part, sizeof(struct part)); + printf("%s Removed paging partition %s\n", my_name, name); + return KERN_SUCCESS; + } + + /* + * Put partition back in. + */ + part->going_away = FALSE; + + return KERN_FAILURE; +} + + +/* + * We use the sequence numbers on requests to regulate + * our parallelism. In general, we allow multiple reads and writes + * to proceed in parallel, with the exception that reads must + * wait for previous writes to finish. (Because the kernel might + * generate a data-request for a page on the heels of a data-write + * for the same page, and we must avoid returning stale data.) + * terminate requests wait for proceeding reads and writes to finish. + */ + +unsigned int default_pager_total = 0; /* debugging */ +unsigned int default_pager_wait_seqno = 0; /* debugging */ +unsigned int default_pager_wait_read = 0; /* debugging */ +unsigned int default_pager_wait_write = 0; /* debugging */ +unsigned int default_pager_wait_refs = 0; /* debugging */ + +#if PARALLEL +/* + * Waits for correct sequence number. Leaves pager locked. + */ +void pager_port_lock(ds, seqno) + default_pager_t ds; + mach_port_seqno_t seqno; +{ + default_pager_total++; + dstruct_lock(ds); + while (ds->seqno != seqno) { + default_pager_wait_seqno++; + condition_wait(&ds->waiting_seqno, &ds->lock); + } +} + +/* + * Increments sequence number and unlocks pager. + */ +void pager_port_unlock(ds) + default_pager_t ds; +{ + ds->seqno++; + dstruct_unlock(ds); + condition_broadcast(&ds->waiting_seqno); +} + +/* + * Start a read - one more reader. Pager must be locked. + */ +void pager_port_start_read(ds) + default_pager_t ds; +{ + ds->readers++; +} + +/* + * Wait for readers. Unlocks and relocks pager if wait needed. + */ +void pager_port_wait_for_readers(ds) + default_pager_t ds; +{ + while (ds->readers != 0) { + default_pager_wait_read++; + condition_wait(&ds->waiting_read, &ds->lock); + } +} + +/* + * Finish a read. Pager is unlocked and returns unlocked. + */ +void pager_port_finish_read(ds) + default_pager_t ds; +{ + dstruct_lock(ds); + if (--ds->readers == 0) { + dstruct_unlock(ds); + condition_broadcast(&ds->waiting_read); + } + else { + dstruct_unlock(ds); + } +} + +/* + * Start a write - one more writer. Pager must be locked. + */ +void pager_port_start_write(ds) + default_pager_t ds; +{ + ds->writers++; +} + +/* + * Wait for writers. Unlocks and relocks pager if wait needed. + */ +void pager_port_wait_for_writers(ds) + default_pager_t ds; +{ + while (ds->writers != 0) { + default_pager_wait_write++; + condition_wait(&ds->waiting_write, &ds->lock); + } +} + +/* + * Finish a write. Pager is unlocked and returns unlocked. + */ +void pager_port_finish_write(ds) + default_pager_t ds; +{ + dstruct_lock(ds); + if (--ds->writers == 0) { + dstruct_unlock(ds); + condition_broadcast(&ds->waiting_write); + } + else { + dstruct_unlock(ds); + } +} + +/* + * Wait for concurrent default_pager_objects. + * Unlocks and relocks pager if wait needed. + */ +void pager_port_wait_for_refs(ds) + default_pager_t ds; +{ + while (ds->name_refs == 0) { + default_pager_wait_refs++; + condition_wait(&ds->waiting_refs, &ds->lock); + } +} + +/* + * Finished creating name refs - wake up waiters. + */ +void pager_port_finish_refs(ds) + default_pager_t ds; +{ + condition_broadcast(&ds->waiting_refs); +} + +#else /* PARALLEL */ + +#define pager_port_lock(ds,seqno) +#define pager_port_unlock(ds) +#define pager_port_start_read(ds) +#define pager_port_wait_for_readers(ds) +#define pager_port_finish_read(ds) +#define pager_port_start_write(ds) +#define pager_port_wait_for_writers(ds) +#define pager_port_finish_write(ds) +#define pager_port_wait_for_refs(ds) +#define pager_port_finish_refs(ds) + +#endif /* PARALLEL */ + +/* + * Default pager. + */ +task_t default_pager_self; /* Our task port. */ + +mach_port_t default_pager_default_port; /* Port for memory_object_create. */ +thread_t default_pager_default_thread; /* Thread for default_port. */ + +/* We catch exceptions on ourself & startup using this port. */ +mach_port_t default_pager_exception_port; +/* We receive bootstrap requests on this port. */ +mach_port_t default_pager_bootstrap_port; + +mach_port_t default_pager_internal_set; /* Port set for internal objects. */ +mach_port_t default_pager_external_set; /* Port set for external objects. */ +mach_port_t default_pager_default_set; /* Port set for "default" thread. */ + +typedef struct default_pager_thread { + cthread_t dpt_thread; /* Server thread. */ + vm_offset_t dpt_buffer; /* Read buffer. */ + boolean_t dpt_internal; /* Do we handle internal objects? */ +} default_pager_thread_t; + +#if PARALLEL + /* determine number of threads at run time */ +#define DEFAULT_PAGER_INTERNAL_COUNT (0) + +#else /* PARALLEL */ +#define DEFAULT_PAGER_INTERNAL_COUNT (1) +#endif /* PARALLEL */ + +/* Memory created by default_pager_object_create should mostly be resident. */ +#define DEFAULT_PAGER_EXTERNAL_COUNT (1) + +unsigned int default_pager_internal_count = DEFAULT_PAGER_INTERNAL_COUNT; + /* Number of "internal" threads. */ +unsigned int default_pager_external_count = DEFAULT_PAGER_EXTERNAL_COUNT; + /* Number of "external" threads. */ + +default_pager_t pager_port_alloc(size) + vm_size_t size; +{ + default_pager_t ds; + p_index_t part; + + ds = (default_pager_t) kalloc(sizeof *ds); + if (ds == DEFAULT_PAGER_NULL) + panic("%spager_port_alloc",my_name); + bzero((char *) ds, sizeof *ds); + + dstruct_lock_init(ds); + + /* + * Get a suitable partition. If none big enough + * just pick one and overcommit. If no partitions + * at all.. well just fake one so that we will + * kill specific objects on pageouts rather than + * panicing the system now. + */ + part = choose_partition(size, P_INDEX_INVALID); + if (no_partition(part)) { + overcommitted(FALSE, atop(size)); + part = choose_partition(0,P_INDEX_INVALID); +#if debug + if (no_partition(part)) + printf("%s No paging space at all !!\n", my_name); +#endif + } + pager_alloc(&ds->dpager, part, size); + + return ds; +} + +mach_port_urefs_t default_pager_max_urefs = 10000; + +/* + * Check user reference count on pager_request port. + * Pager must be locked. + * Unlocks and re-locks pager if needs to call kernel. + */ +void pager_port_check_request(ds, pager_request) + default_pager_t ds; + mach_port_t pager_request; +{ + mach_port_delta_t delta; + kern_return_t kr; + + assert(ds->pager_request == pager_request); + + if (++ds->request_refs > default_pager_max_urefs) { + delta = 1 - ds->request_refs; + ds->request_refs = 1; + + dstruct_unlock(ds); + + /* + * Deallocate excess user references. + */ + + kr = mach_port_mod_refs(default_pager_self, pager_request, + MACH_PORT_RIGHT_SEND, delta); + if (kr != KERN_SUCCESS) + panic("%spager_port_check_request",my_name); + + dstruct_lock(ds); + } +} + +void default_pager_add(ds, internal) + default_pager_t ds; + boolean_t internal; +{ + mach_port_t pager = ds->pager; + mach_port_t pset; + mach_port_mscount_t sync; + mach_port_t previous; + kern_return_t kr; + static char here[] = "%sdefault_pager_add"; + + /* + * The port currently has a make-send count of zero, + * because either we just created the port or we just + * received the port in a memory_object_create request. + */ + + if (internal) { + /* possibly generate an immediate no-senders notification */ + sync = 0; + pset = default_pager_internal_set; + } else { + /* delay notification till send right is created */ + sync = 1; + pset = default_pager_external_set; + } + + kr = mach_port_request_notification(default_pager_self, pager, + MACH_NOTIFY_NO_SENDERS, sync, + pager, MACH_MSG_TYPE_MAKE_SEND_ONCE, + &previous); + if ((kr != KERN_SUCCESS) || (previous != MACH_PORT_NULL)) + panic(here,my_name); + + kr = mach_port_move_member(default_pager_self, pager, pset); + if (kr != KERN_SUCCESS) + panic(here,my_name); +} + +/* + * Routine: memory_object_create + * Purpose: + * Handle requests for memory objects from the + * kernel. + * Notes: + * Because we only give out the default memory + * manager port to the kernel, we don't have to + * be so paranoid about the contents. + */ +kern_return_t +seqnos_memory_object_create(old_pager, seqno, new_pager, new_size, + new_pager_request, new_pager_name, new_page_size) + mach_port_t old_pager; + mach_port_seqno_t seqno; + mach_port_t new_pager; + vm_size_t new_size; + mach_port_t new_pager_request; + mach_port_t new_pager_name; + vm_size_t new_page_size; +{ + register default_pager_t ds; + kern_return_t kr; + + assert(old_pager == default_pager_default_port); + assert(MACH_PORT_VALID(new_pager_request)); + assert(MACH_PORT_VALID(new_pager_name)); + assert(new_page_size == vm_page_size); + + ds = pager_port_alloc(new_size); +rename_it: + kr = mach_port_rename( default_pager_self, + new_pager, (mach_port_t)pnameof(ds)); + if (kr != KERN_SUCCESS) { + default_pager_t ds1; + + if (kr != KERN_NAME_EXISTS) + panic("%s m_o_create", my_name); + ds1 = (default_pager_t) kalloc(sizeof *ds1); + *ds1 = *ds; + mutex_lock(&all_pagers.lock); + queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links); + mutex_unlock(&all_pagers.lock); + ds = ds1; + goto rename_it; + } + + new_pager = (mach_port_t) pnameof(ds); + + /* + * Set up associations between these ports + * and this default_pager structure + */ + + ds->pager = new_pager; + ds->pager_request = new_pager_request; + ds->request_refs = 1; + ds->pager_name = new_pager_name; + ds->name_refs = 1; + + /* + * After this, other threads might receive requests + * for this memory object or find it in the port list. + */ + + pager_port_list_insert(new_pager, ds); + default_pager_add(ds, TRUE); + + return(KERN_SUCCESS); +} + +memory_object_copy_strategy_t default_pager_copy_strategy = + MEMORY_OBJECT_COPY_DELAY; + +kern_return_t +seqnos_memory_object_init(pager, seqno, pager_request, pager_name, + pager_page_size) + mach_port_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + mach_port_t pager_name; + vm_size_t pager_page_size; +{ + register default_pager_t ds; + kern_return_t kr; + static char here[] = "%sinit"; + + assert(MACH_PORT_VALID(pager_request)); + assert(MACH_PORT_VALID(pager_name)); + assert(pager_page_size == vm_page_size); + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here, my_name); + pager_port_lock(ds, seqno); + + if (ds->pager_request != MACH_PORT_NULL) + panic(here, my_name); + + ds->pager_request = pager_request; + ds->request_refs = 1; + ds->pager_name = pager_name; + ds->name_refs = 1; + + /* + * Even if the kernel immediately terminates the object, + * the pager_request port won't be destroyed until + * we process the terminate request, which won't happen + * until we unlock the object. + */ + + kr = memory_object_set_attributes(pager_request, + TRUE, + FALSE, /* do not cache */ + default_pager_copy_strategy); + if (kr != KERN_SUCCESS) + panic(here, my_name); + + pager_port_unlock(ds); + + return(KERN_SUCCESS); +} + +kern_return_t +seqnos_memory_object_terminate(pager, seqno, pager_request, pager_name) + mach_port_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + mach_port_t pager_name; +{ + register default_pager_t ds; + mach_port_urefs_t request_refs, name_refs; + kern_return_t kr; + static char here[] = "%sterminate"; + + /* + * pager_request and pager_name are receive rights, + * not send rights. + */ + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here, my_name); + pager_port_lock(ds, seqno); + + /* + * Wait for read and write requests to terminate. + */ + + pager_port_wait_for_readers(ds); + pager_port_wait_for_writers(ds); + + /* + * After memory_object_terminate both memory_object_init + * and a no-senders notification are possible, so we need + * to clean up the request and name ports but leave + * the pager port. + * + * A concurrent default_pager_objects might be allocating + * more references for the name port. In this case, + * we must first wait for it to finish. + */ + + pager_port_wait_for_refs(ds); + + ds->pager_request = MACH_PORT_NULL; + request_refs = ds->request_refs; + ds->request_refs = 0; + assert(ds->pager_name == pager_name); + ds->pager_name = MACH_PORT_NULL; + name_refs = ds->name_refs; + ds->name_refs = 0; + pager_port_unlock(ds); + + /* + * Now we deallocate our various 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); + + return (KERN_SUCCESS); +} + +void default_pager_no_senders(pager, seqno, mscount) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_mscount_t mscount; +{ + register default_pager_t ds; + kern_return_t kr; + static char here[] = "%sno_senders"; + + /* + * Because we don't give out multiple send rights + * for a memory object, there can't be a race + * between getting a no-senders notification + * and creating a new send right for the object. + * Hence we don't keep track of mscount. + */ + + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here,my_name); + pager_port_lock(ds, seqno); + + /* + * We shouldn't get a no-senders notification + * when the kernel has the object cached. + */ + + if (ds->pager_request != MACH_PORT_NULL) + panic(here,my_name); + + /* + * Unlock the pager (though there should be no one + * waiting for it). + */ + dstruct_unlock(ds); + + /* + * Remove the memory object port association, and then + * the destroy the port itself. We must remove the object + * from the port list before deallocating the pager, + * because of default_pager_objects. + */ + + pager_port_list_delete(ds); + pager_dealloc(&ds->dpager); + + kr = mach_port_mod_refs(default_pager_self, pager, + MACH_PORT_RIGHT_RECEIVE, -1); + if (kr != KERN_SUCCESS) + panic(here,my_name); + + /* + * Do this *after* deallocating the port name + */ + kfree((char *) ds, sizeof(*ds)); + + /* + * Recover memory that we might have wasted because + * of name conflicts + */ + mutex_lock(&all_pagers.lock); + + while (!queue_empty(&all_pagers.leak_queue)) { + + ds = (default_pager_t) queue_first(&all_pagers.leak_queue); + queue_remove_first(&all_pagers.leak_queue, ds, default_pager_t, links); + kfree((char *) ds, sizeof(*ds)); + } + + mutex_unlock(&all_pagers.lock); +} + +int default_pager_pagein_count = 0; +int default_pager_pageout_count = 0; + +kern_return_t +seqnos_memory_object_data_request(pager, seqno, reply_to, offset, + length, protection_required) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t reply_to; + vm_offset_t offset; + vm_size_t length; + vm_prot_t protection_required; +{ + default_pager_thread_t *dpt; + default_pager_t ds; + vm_offset_t addr; + unsigned int errors; + kern_return_t rc; + static char here[] = "%sdata_request"; + + dpt = (default_pager_thread_t *) cthread_data(cthread_self()); + + if (length != vm_page_size) + panic(here,my_name); + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here,my_name); + pager_port_lock(ds, seqno); + pager_port_check_request(ds, reply_to); + pager_port_wait_for_writers(ds); + pager_port_start_read(ds); + + /* + * Get error count while pager locked. + */ + errors = ds->errors; + + pager_port_unlock(ds); + + if (errors) { + printf("%s %s\n", my_name, + "dropping data_request because of previous paging errors"); + (void) memory_object_data_error(reply_to, + offset, vm_page_size, + KERN_FAILURE); + goto done; + } + + rc = default_read(&ds->dpager, dpt->dpt_buffer, + vm_page_size, offset, + &addr, protection_required & VM_PROT_WRITE); + + switch (rc) { + case PAGER_SUCCESS: + if (addr != dpt->dpt_buffer) { + /* + * Deallocates data buffer + */ + (void) memory_object_data_supply( + reply_to, offset, + addr, vm_page_size, TRUE, + VM_PROT_NONE, + FALSE, MACH_PORT_NULL); + } else { + (void) memory_object_data_provided( + reply_to, offset, + addr, vm_page_size, + VM_PROT_NONE); + } + break; + + case PAGER_ABSENT: + (void) memory_object_data_unavailable( + reply_to, + offset, + vm_page_size); + break; + + case PAGER_ERROR: + (void) memory_object_data_error( + reply_to, + offset, + vm_page_size, + KERN_FAILURE); + break; + } + + default_pager_pagein_count++; + + done: + pager_port_finish_read(ds); + return(KERN_SUCCESS); +} + +/* + * memory_object_data_initialize: check whether we already have each page, and + * write it if we do not. The implementation is far from optimized, and + * also assumes that the default_pager is single-threaded. + */ +kern_return_t +seqnos_memory_object_data_initialize(pager, seqno, pager_request, + offset, addr, data_cnt) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + register + vm_offset_t offset; + register + pointer_t addr; + vm_size_t data_cnt; +{ + vm_offset_t amount_sent; + default_pager_t ds; + static char here[] = "%sdata_initialize"; + +#ifdef lint + pager_request++; +#endif lint + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here,my_name); + pager_port_lock(ds, seqno); + pager_port_check_request(ds, pager_request); + pager_port_start_write(ds); + pager_port_unlock(ds); + + for (amount_sent = 0; + amount_sent < data_cnt; + amount_sent += vm_page_size) { + + if (!default_has_page(&ds->dpager, offset + amount_sent)) { + if (default_write(&ds->dpager, + addr + amount_sent, + vm_page_size, + offset + amount_sent) + != PAGER_SUCCESS) { + printf("%s%s write error\n", my_name, here); + dstruct_lock(ds); + ds->errors++; + dstruct_unlock(ds); + } + } + } + + pager_port_finish_write(ds); + if (vm_deallocate(default_pager_self, addr, data_cnt) != KERN_SUCCESS) + panic(here,my_name); + + return(KERN_SUCCESS); +} + +/* + * memory_object_data_write: 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_write(pager, seqno, pager_request, + offset, addr, data_cnt) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + register + vm_offset_t offset; + register + pointer_t addr; + vm_size_t data_cnt; +{ + register + vm_size_t amount_sent; + default_pager_t ds; + static char here[] = "%sdata_write"; + +#ifdef lint + pager_request++; +#endif lint + + if ((data_cnt % vm_page_size) != 0) + panic(here,my_name); + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + panic(here,my_name); + pager_port_lock(ds, seqno); + pager_port_check_request(ds, pager_request); + pager_port_start_write(ds); + pager_port_unlock(ds); + + for (amount_sent = 0; + amount_sent < data_cnt; + amount_sent += vm_page_size) { + + register int result; + + result = default_write(&ds->dpager, + addr + amount_sent, + vm_page_size, + offset + amount_sent); + if (result != KERN_SUCCESS) { +#if debug + printf("%s WRITE ERROR on default_pageout:", my_name); + printf(" 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); + } + default_pager_pageout_count++; + } + + pager_port_finish_write(ds); + if (vm_deallocate(default_pager_self, addr, data_cnt) != KERN_SUCCESS) + panic(here,my_name); + + return(KERN_SUCCESS); +} + +/*ARGSUSED*/ +kern_return_t +seqnos_memory_object_copy(old_memory_object, seqno, old_memory_control, + offset, length, new_memory_object) + memory_object_t old_memory_object; + mach_port_seqno_t seqno; + memory_object_control_t + old_memory_control; + vm_offset_t offset; + vm_size_t length; + memory_object_t new_memory_object; +{ + panic("%scopy", my_name); + return KERN_FAILURE; +} + +kern_return_t +seqnos_memory_object_lock_completed(pager, seqno, pager_request, + offset, length) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + vm_offset_t offset; + vm_size_t length; +{ +#ifdef lint + pager++; seqno++; pager_request++; offset++; length++; +#endif lint + + panic("%slock_completed",my_name); + return(KERN_FAILURE); +} + +kern_return_t +seqnos_memory_object_data_unlock(pager, seqno, pager_request, + offset, addr, data_cnt) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + vm_offset_t offset; + pointer_t addr; + vm_size_t data_cnt; +{ + panic("%sdata_unlock",my_name); + return(KERN_FAILURE); +} + +kern_return_t +seqnos_memory_object_supply_completed(pager, seqno, pager_request, + offset, length, + result, error_offset) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + vm_offset_t offset; + vm_size_t length; + kern_return_t result; + vm_offset_t error_offset; +{ + panic("%ssupply_completed",my_name); + return(KERN_FAILURE); +} + +kern_return_t +seqnos_memory_object_data_return(pager, seqno, pager_request, + offset, addr, data_cnt, + dirty, kernel_copy) + memory_object_t pager; + mach_port_seqno_t seqno; + mach_port_t pager_request; + vm_offset_t offset; + pointer_t addr; + vm_size_t data_cnt; + boolean_t dirty; + boolean_t kernel_copy; +{ + panic("%sdata_return",my_name); + return(KERN_FAILURE); +} + +kern_return_t +seqnos_memory_object_change_completed(pager, seqno, may_cache, copy_strategy) + memory_object_t pager; + mach_port_seqno_t seqno; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; +{ + panic("%schange_completed",my_name); + return(KERN_FAILURE); +} + + +boolean_t default_pager_notify_server(in, out) + mach_msg_header_t *in, *out; +{ + register mach_no_senders_notification_t *n = + (mach_no_senders_notification_t *) in; + + /* + * The only send-once rights we create are for + * receiving no-more-senders notifications. + * Hence, if we receive a message directed to + * a send-once right, we can assume it is + * a genuine no-senders notification from the kernel. + */ + + if ((n->not_header.msgh_bits != + MACH_MSGH_BITS(0, MACH_MSG_TYPE_PORT_SEND_ONCE)) || + (n->not_header.msgh_id != MACH_NOTIFY_NO_SENDERS)) + return FALSE; + + assert(n->not_header.msgh_size == sizeof *n); + assert(n->not_header.msgh_remote_port == MACH_PORT_NULL); + + assert(n->not_type.msgt_name == MACH_MSG_TYPE_INTEGER_32); + assert(n->not_type.msgt_size == 32); + assert(n->not_type.msgt_number == 1); + assert(n->not_type.msgt_inline); + assert(! n->not_type.msgt_longform); + + default_pager_no_senders(n->not_header.msgh_local_port, + n->not_header.msgh_seqno, n->not_count); + + out->msgh_remote_port = MACH_PORT_NULL; + return TRUE; +} + +extern boolean_t seqnos_memory_object_server(); +extern boolean_t seqnos_memory_object_default_server(); +extern boolean_t default_pager_server(); +extern boolean_t exc_server(); +extern boolean_t bootstrap_server(); +extern void bootstrap_compat(); + +mach_msg_size_t default_pager_msg_size_object = 128; + +boolean_t +default_pager_demux_object(in, out) + mach_msg_header_t *in; + mach_msg_header_t *out; +{ + /* + * We receive memory_object_data_initialize messages in + * the memory_object_default interface. + */ + + clearerr (stdout); + printf ("dpi object message %d\n", in->msgh_id); + return (seqnos_memory_object_server(in, out) || + seqnos_memory_object_default_server(in, out) || + default_pager_notify_server(in, out)); +} + +mach_msg_size_t default_pager_msg_size_default = 8 * 1024; + +boolean_t +default_pager_demux_default(in, out) + mach_msg_header_t *in; + mach_msg_header_t *out; +{ + clearerr (stdout); + printf ("dpi message %d\n", in->msgh_id); + if (in->msgh_local_port == default_pager_default_port) { + /* + * We receive memory_object_create messages in + * the memory_object_default interface. + */ + + return (seqnos_memory_object_default_server(in, out) || + default_pager_server(in, out)); + } else if (in->msgh_local_port == default_pager_exception_port) { + /* + * We receive exception messages for + * ourself and the startup task. + */ + + return exc_server(in, out); + } else if (in->msgh_local_port == default_pager_bootstrap_port) { + /* + * We receive bootstrap requests + * from the startup task. + */ + + if (in->msgh_id == 999999) { + /* compatibility for old bootstrap interface */ + + bootstrap_compat(in, out); + return TRUE; + } + + return bootstrap_server(in, out); + } else { + panic(my_name); + return FALSE; + } +} + +/* + * We use multiple threads, for two reasons. + * + * First, memory objects created by default_pager_object_create + * are "external", instead of "internal". This means the kernel + * sends data (memory_object_data_write) to the object pageable. + * To prevent deadlocks, the external and internal objects must + * be managed by different threads. + * + * Second, the default pager uses synchronous IO operations. + * Spreading requests across multiple threads should + * recover some of the performance loss from synchronous IO. + * + * We have 3+ threads. + * One receives memory_object_create and + * default_pager_object_create requests. + * One or more manage internal objects. + * One or more manage external objects. + */ + +void +default_pager_thread_privileges() +{ + /* + * Set thread privileges. + */ + cthread_wire(); /* attach kernel thread to cthread */ + wire_thread(); /* grab a kernel stack and memory allocation + privileges */ +} + +any_t +default_pager_thread(arg) + any_t arg; +{ + default_pager_thread_t *dpt = (default_pager_thread_t *) arg; + mach_port_t pset; + kern_return_t kr; + + printf ("dtp\n"); + cthread_set_data(cthread_self(), (any_t) dpt); + + printf ("dtp %#x\n", dpt); + + /* + * Threads handling external objects cannot have + * privileges. Otherwise a burst of data-requests for an + * external object could empty the free-page queue, + * because the fault code only reserves real pages for + * requests sent to internal objects. + */ + + if (dpt->dpt_internal) { + default_pager_thread_privileges(); + pset = default_pager_internal_set; + } else { + pset = default_pager_external_set; + } + + for (;;) { + printf ("dtp %#x loop\n", dpt); + kr = mach_msg_server(default_pager_demux_object, + default_pager_msg_size_object, + pset); + panic(my_name, kr); + } +} + +void +start_default_pager_thread(internal) + boolean_t internal; +{ + default_pager_thread_t *dpt; + kern_return_t kr; + + dpt = (default_pager_thread_t *) kalloc(sizeof *dpt); + if (dpt == 0) + panic(my_name); + + dpt->dpt_internal = internal; + + kr = vm_allocate(default_pager_self, &dpt->dpt_buffer, + vm_page_size, TRUE); + if (kr != KERN_SUCCESS) + panic(my_name); + wire_memory(dpt->dpt_buffer, vm_page_size, + VM_PROT_READ|VM_PROT_WRITE); + + printf ("starting thread %d\n", internal); + + dpt->dpt_thread = cthread_fork(default_pager_thread, (any_t) dpt); +} + +void +default_pager_initialize(host_port) + mach_port_t host_port; +{ + memory_object_t DMM; + kern_return_t kr; + + /* + * This task will become the default pager. + */ + default_pager_self = mach_task_self(); + + /* + * Initialize the "default pager" port. + */ + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_RECEIVE, + &default_pager_default_port); + if (kr != KERN_SUCCESS) + panic(my_name); + + DMM = default_pager_default_port; + kr = vm_set_default_memory_manager(host_port, &DMM); + if ((kr != KERN_SUCCESS) || (DMM != MACH_PORT_NULL)) + panic(my_name); + + /* + * Initialize the exception port. + */ + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_RECEIVE, + &default_pager_exception_port); + if (kr != KERN_SUCCESS) + panic(my_name); + + /* + * Initialize the bootstrap port. + */ + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_RECEIVE, + &default_pager_bootstrap_port); + if (kr != KERN_SUCCESS) + panic(my_name); + + /* + * Arrange for wiring privileges. + */ + wire_setup(host_port); + + /* + * Find out how many CPUs we have, to determine the number + * of threads to create. + */ + if (default_pager_internal_count == 0) { + host_basic_info_data_t h_info; + natural_t h_info_count; + + h_info_count = HOST_BASIC_INFO_COUNT; + (void) host_info(host_port, HOST_BASIC_INFO, + (host_info_t)&h_info, &h_info_count); + + /* + * Random computation to get more parallelism on + * multiprocessors. + */ + default_pager_internal_count = + (h_info.avail_cpus > 32 ? 32 : h_info.avail_cpus) / 4 + 3; + } +} + +/* + * Initialize and Run the default pager + */ +void +default_pager() +{ + kern_return_t kr; + int i; + + printf ("dp1\n"); + default_pager_thread_privileges(); + + /* + * Wire down code, data, stack + */ + wire_all_memory(); + + printf ("dp2\n"); + + /* + * Initialize the list of all pagers. + */ + pager_port_list_init(); + + printf ("dp3\n"); + + /* + * This thread will receive memory_object_create + * requests from the kernel and default_pager_object_create + * requests from the user via default_pager_default_port. + */ + + default_pager_default_thread = mach_thread_self(); + + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_PORT_SET, + &default_pager_internal_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_PORT_SET, + &default_pager_external_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_PORT_SET, + &default_pager_default_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + kr = mach_port_move_member(default_pager_self, + default_pager_default_port, + default_pager_default_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + kr = mach_port_move_member(default_pager_self, + default_pager_exception_port, + default_pager_default_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + kr = mach_port_move_member(default_pager_self, + default_pager_bootstrap_port, + default_pager_default_set); + if (kr != KERN_SUCCESS) + panic(my_name); + + printf ("dp4\n"); + + /* + * Now we create the threads that will actually + * manage objects. + */ + + for (i = 0; i < default_pager_internal_count; i++) + start_default_pager_thread(TRUE); + + printf ("dp5\n"); + + for (i = 0; i < default_pager_external_count; i++) + start_default_pager_thread(FALSE); + + printf ("dp6\n"); + + for (;;) { + printf ("dp7\n"); + kr = mach_msg_server(default_pager_demux_default, + default_pager_msg_size_default, + default_pager_default_set); + panic(my_name, kr); + } +} + +/* + * Create an external object. + */ +kern_return_t default_pager_object_create(pager, mem_obj, size) + mach_port_t pager; + mach_port_t *mem_obj; + vm_size_t size; +{ + default_pager_t ds; + mach_port_t port; + kern_return_t result; + + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; + + ds = pager_port_alloc(size); +rename_it: + port = (mach_port_t) pnameof(ds); + result = mach_port_allocate_name(default_pager_self, + MACH_PORT_RIGHT_RECEIVE, port); + if (result != KERN_SUCCESS) { + default_pager_t ds1; + + if (result != KERN_NAME_EXISTS) return (result); + + ds1 = (default_pager_t) kalloc(sizeof *ds1); + *ds1 = *ds; + mutex_lock(&all_pagers.lock); + queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links); + mutex_unlock(&all_pagers.lock); + ds = ds1; + goto rename_it; + } + + /* + * Set up associations between these ports + * and this default_pager structure + */ + + ds->pager = port; + pager_port_list_insert(port, ds); + default_pager_add(ds, FALSE); + + *mem_obj = port; + return (KERN_SUCCESS); +} + +kern_return_t default_pager_info(pager, infop) + mach_port_t pager; + default_pager_info_t *infop; +{ + vm_size_t total, free; + + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; + + mutex_lock(&all_partitions.lock); + paging_space_info(&total, &free); + mutex_unlock(&all_partitions.lock); + + infop->dpi_total_space = ptoa(total); + infop->dpi_free_space = ptoa(free); + infop->dpi_page_size = vm_page_size; + return KERN_SUCCESS; +} + +kern_return_t default_pager_objects(pager, objectsp, ocountp, portsp, pcountp) + mach_port_t pager; + default_pager_object_array_t *objectsp; + natural_t *ocountp; + mach_port_array_t *portsp; + natural_t *pcountp; +{ + vm_offset_t oaddr; /* memory for objects */ + vm_size_t osize; /* current size */ + default_pager_object_t *objects; + natural_t opotential; + + vm_offset_t paddr; /* memory for ports */ + vm_size_t psize; /* current size */ + mach_port_t *ports; + natural_t ppotential; + + unsigned int actual; + unsigned int num_pagers; + kern_return_t kr; + default_pager_t entry; + + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; + + /* start with the inline memory */ + + num_pagers = 0; + + objects = *objectsp; + opotential = *ocountp; + + ports = *portsp; + ppotential = *pcountp; + + mutex_lock(&all_pagers.lock); + /* + * We will send no more than this many + */ + actual = all_pagers.count; + mutex_unlock(&all_pagers.lock); + + if (opotential < actual) { + vm_offset_t newaddr; + vm_size_t newsize; + + newsize = 2 * round_page(actual * sizeof *objects); + + kr = vm_allocate(default_pager_self, &newaddr, newsize, TRUE); + if (kr != KERN_SUCCESS) + goto nomemory; + + oaddr = newaddr; + osize = newsize; + opotential = osize/sizeof *objects; + objects = (default_pager_object_t *) oaddr; + } + + if (ppotential < actual) { + vm_offset_t newaddr; + vm_size_t newsize; + + newsize = 2 * round_page(actual * sizeof *ports); + + kr = vm_allocate(default_pager_self, &newaddr, newsize, TRUE); + if (kr != KERN_SUCCESS) + goto nomemory; + + paddr = newaddr; + psize = newsize; + ppotential = psize/sizeof *ports; + ports = (mach_port_t *) paddr; + } + + /* + * Now scan the list. + */ + + mutex_lock(&all_pagers.lock); + + num_pagers = 0; + queue_iterate(&all_pagers.queue, entry, default_pager_t, links) { + + mach_port_t port; + vm_size_t size; + + if ((num_pagers >= opotential) || + (num_pagers >= ppotential)) { + /* + * This should be rare. In any case, + * we will only miss recent objects, + * because they are added at the end. + */ + break; + } + + /* + * Avoid interfering with normal operations + */ + if (!mutex_try_lock(&entry->dpager.lock)) + goto not_this_one; + size = pager_allocated(&entry->dpager); + mutex_unlock(&entry->dpager.lock); + + dstruct_lock(entry); + + port = entry->pager_name; + if (port == MACH_PORT_NULL) { + /* + * The object is waiting for no-senders + * or memory_object_init. + */ + dstruct_unlock(entry); + goto not_this_one; + } + + /* + * We need a reference for the reply message. + * While we are unlocked, the bucket queue + * can change and the object might be terminated. + * memory_object_terminate will wait for us, + * preventing deallocation of the entry. + */ + + if (--entry->name_refs == 0) { + dstruct_unlock(entry); + + /* keep the list locked, wont take long */ + + kr = mach_port_mod_refs(default_pager_self, + port, MACH_PORT_RIGHT_SEND, + default_pager_max_urefs); + if (kr != KERN_SUCCESS) + panic("%sdefault_pager_objects",my_name); + + dstruct_lock(entry); + + entry->name_refs += default_pager_max_urefs; + pager_port_finish_refs(entry); + } + dstruct_unlock(entry); + + /* the arrays are wired, so no deadlock worries */ + + objects[num_pagers].dpo_object = (vm_offset_t) entry; + objects[num_pagers].dpo_size = size; + ports [num_pagers++] = port; + continue; +not_this_one: + /* + * Do not return garbage + */ + objects[num_pagers].dpo_object = (vm_offset_t) 0; + objects[num_pagers].dpo_size = 0; + ports [num_pagers++] = MACH_PORT_NULL; + + } + + mutex_unlock(&all_pagers.lock); + + /* + * Deallocate and clear unused memory. + * (Returned memory will automagically become pageable.) + */ + + if (objects == *objectsp) { + /* + * Our returned information fit inline. + * Nothing to deallocate. + */ + + *ocountp = num_pagers; + } else if (actual == 0) { + (void) vm_deallocate(default_pager_self, oaddr, osize); + + /* return zero items inline */ + *ocountp = 0; + } else { + vm_offset_t used; + + used = round_page(actual * sizeof *objects); + + if (used != osize) + (void) vm_deallocate(default_pager_self, + oaddr + used, osize - used); + + *objectsp = objects; + *ocountp = num_pagers; + } + + if (ports == *portsp) { + /* + * Our returned information fit inline. + * Nothing to deallocate. + */ + + *pcountp = num_pagers; + } else if (actual == 0) { + (void) vm_deallocate(default_pager_self, paddr, psize); + + /* return zero items inline */ + *pcountp = 0; + } else { + vm_offset_t used; + + used = round_page(actual * sizeof *ports); + + if (used != psize) + (void) vm_deallocate(default_pager_self, + paddr + used, psize - used); + + *portsp = ports; + *pcountp = num_pagers; + } + + return KERN_SUCCESS; + + nomemory: + + { + register int i; + for (i = 0; i < num_pagers; i++) + (void) mach_port_deallocate(default_pager_self, ports[i]); + } + + if (objects != *objectsp) + (void) vm_deallocate(default_pager_self, oaddr, osize); + + if (ports != *portsp) + (void) vm_deallocate(default_pager_self, paddr, psize); + + return KERN_RESOURCE_SHORTAGE; +} + + +kern_return_t +default_pager_object_pages(pager, object, pagesp, countp) + mach_port_t pager; + mach_port_t object; + default_pager_page_array_t *pagesp; + natural_t *countp; +{ + vm_offset_t addr; /* memory for page offsets */ + vm_size_t size; /* current memory size */ + default_pager_page_t *pages; + natural_t potential, actual; + kern_return_t kr; + + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; + + /* we start with the inline space */ + + pages = *pagesp; + potential = *countp; + + for (;;) { + default_pager_t entry; + + mutex_lock(&all_pagers.lock); + queue_iterate(&all_pagers.queue, entry, default_pager_t, links) { + dstruct_lock(entry); + if (entry->pager_name == object) { + mutex_unlock(&all_pagers.lock); + goto found_object; + } + dstruct_unlock(entry); + } + mutex_unlock(&all_pagers.lock); + + /* did not find the object */ + + if (pages != *pagesp) + (void) vm_deallocate(default_pager_self, addr, size); + return KERN_INVALID_ARGUMENT; + + found_object: + + if (!mutex_try_lock(&entry->dpager.lock)) { + /* oh well bad luck */ + + dstruct_unlock(entry); + + /* yield the processor */ + (void) thread_switch(MACH_PORT_NULL, + SWITCH_OPTION_NONE, 0); + continue; + } + + actual = pager_pages(&entry->dpager, pages, potential); + mutex_unlock(&entry->dpager.lock); + dstruct_unlock(entry); + + if (actual <= potential) + break; + + /* allocate more memory */ + + if (pages != *pagesp) + (void) vm_deallocate(default_pager_self, addr, size); + size = round_page(actual * sizeof *pages); + kr = vm_allocate(default_pager_self, &addr, size, TRUE); + if (kr != KERN_SUCCESS) + return kr; + pages = (default_pager_page_t *) addr; + potential = size/sizeof *pages; + } + + /* + * Deallocate and clear unused memory. + * (Returned memory will automagically become pageable.) + */ + + if (pages == *pagesp) { + /* + * Our returned information fit inline. + * Nothing to deallocate. + */ + + *countp = actual; + } else if (actual == 0) { + (void) vm_deallocate(default_pager_self, addr, size); + + /* return zero items inline */ + *countp = 0; + } else { + vm_offset_t used; + + used = round_page(actual * sizeof *pages); + + if (used != size) + (void) vm_deallocate(default_pager_self, + addr + used, size - used); + + *pagesp = pages; + *countp = actual; + } + return KERN_SUCCESS; +} + +/* + * Add/remove extra paging space + */ + +extern mach_port_t bootstrap_master_device_port; +extern mach_port_t bootstrap_master_host_port; + +kern_return_t +default_pager_paging_file(pager, mdport, file_name, add) + mach_port_t pager; + mach_port_t mdport; + default_pager_filename_t file_name; + boolean_t add; +{ + kern_return_t kr; + + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; + +#if 0 +printf("bmd %x md %x\n", bootstrap_master_device_port, mdport); +#endif + if (add) { + kr = add_paging_file(bootstrap_master_device_port, + file_name); + } else { + kr = remove_paging_file(file_name); + } + + /* XXXX more code needed */ + if (mdport != bootstrap_master_device_port) + mach_port_deallocate( mach_task_self(), mdport); + + return kr; +} + +default_pager_register_fileserver(pager, fileserver) + mach_port_t pager; + mach_port_t fileserver; +{ + if (pager != default_pager_default_port) + return KERN_INVALID_ARGUMENT; +#if notyet + mach_port_deallocate(mach_task_self(), fileserver); + if (0) dp_helper_paging_space(0,0,0);/*just linkit*/ +#endif + return KERN_SUCCESS; +} + +/* + * When things do not quite workout... + */ +no_paging_space(out_of_memory) + boolean_t out_of_memory; +{ + static char here[] = "%s *** NOT ENOUGH PAGING SPACE ***"; + + if (out_of_memory) + printf("*** OUT OF MEMORY *** "); + panic(here, my_name); +} + +overcommitted(got_more_space, space) + boolean_t got_more_space; + vm_size_t space; /* in pages */ +{ + vm_size_t pages_free, pages_total; + + static boolean_t user_warned = FALSE; + static vm_size_t pages_shortage = 0; + + paging_space_info(&pages_total, &pages_free); + + /* + * If user added more space, see if it is enough + */ + if (got_more_space) { + pages_free -= pages_shortage; + if (pages_free > 0) { + pages_shortage = 0; + if (user_warned) + printf("%s paging space ok now.\n", my_name); + } else + pages_shortage = pages_free; + user_warned = FALSE; + return; + } + /* + * We ran out of gas, let user know. + */ + pages_free -= space; + pages_shortage = (pages_free > 0) ? 0 : -pages_free; + if (!user_warned && pages_shortage) { + user_warned = TRUE; + printf("%s paging space over-committed.\n", my_name); + } +#if debug + user_warned = FALSE; + printf("%s paging space over-committed [+%d (%d) pages].\n", + my_name, space, pages_shortage); +#endif +} + +paging_space_info(totp, freep) + vm_size_t *totp, *freep; +{ + register vm_size_t total, free; + register partition_t part; + register int i; + + total = free = 0; + for (i = 0; i < all_partitions.n_partitions; i++) { + + if ((part = partition_of(i)) == 0) continue; + + /* no need to lock: by the time this data + gets back to any remote requestor it + will be obsolete anyways */ + total += part->total_size; + free += part->free; +#if debug + printf("Partition %d: x%x total, x%x free\n", + i, part->total_size, part->free); +#endif + } + *totp = total; + *freep = free; +} + +/* + * Catch exceptions. + */ + +kern_return_t +catch_exception_raise(exception_port, thread, task, exception, code, subcode) + mach_port_t exception_port; + mach_port_t thread, task; + int exception, code, subcode; +{ + printf("(default_pager)catch_exception_raise(%d,%d,%d)\n", + exception, code, subcode); + panic(my_name); + + /* mach_msg_server will deallocate thread/task for us */ + + return KERN_FAILURE; +} + +/* + * Handle bootstrap requests. + */ + +kern_return_t +do_bootstrap_privileged_ports(bootstrap, hostp, devicep) + mach_port_t bootstrap; + mach_port_t *hostp, *devicep; +{ + *hostp = bootstrap_master_host_port; + *devicep = bootstrap_master_device_port; + return KERN_SUCCESS; +} + +void +bootstrap_compat(in, out) + mach_msg_header_t *in, *out; +{ + mig_reply_header_t *reply = (mig_reply_header_t *) out; + mach_msg_return_t mr; + + struct imsg { + mach_msg_header_t hdr; + mach_msg_type_t port_desc_1; + mach_port_t port_1; + mach_msg_type_t port_desc_2; + mach_port_t port_2; + } imsg; + + /* + * Send back the host and device ports. + */ + + imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | + MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); + /* msgh_size doesn't need to be initialized */ + imsg.hdr.msgh_remote_port = in->msgh_remote_port; + imsg.hdr.msgh_local_port = MACH_PORT_NULL; + /* msgh_seqno doesn't need to be initialized */ + imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ + + imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; + imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); + imsg.port_desc_1.msgt_number = 1; + imsg.port_desc_1.msgt_inline = TRUE; + imsg.port_desc_1.msgt_longform = FALSE; + imsg.port_desc_1.msgt_deallocate = FALSE; + imsg.port_desc_1.msgt_unused = 0; + + imsg.port_1 = bootstrap_master_host_port; + + imsg.port_desc_2 = imsg.port_desc_1; + + imsg.port_2 = bootstrap_master_device_port; + + /* + * Send the reply message. + * (mach_msg_server can not do this, because the reply + * is not in standard format.) + */ + + mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, + sizeof imsg, 0, MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (mr != MACH_MSG_SUCCESS) + (void) mach_port_deallocate(default_pager_self, + imsg.hdr.msgh_remote_port); + + /* + * Tell mach_msg_server to do nothing. + */ + + reply->RetCode = MIG_NO_REPLY; +} + +#ifdef mips +/* + * set_ras_address for default pager + * Default pager does not have emulator support + * so it needs a local version of set_ras_address. + */ +int +set_ras_address(basepc, boundspc) + vm_offset_t basepc; + vm_offset_t boundspc; +{ + kern_return_t status; + + status = task_ras_control(mach_task_self(), basepc, boundspc, + TASK_RAS_CONTROL_INSTALL_ONE); + if (status != KERN_SUCCESS) + return -1; + return 0; +} +#endif diff --git a/serverboot/defs.h b/serverboot/defs.h new file mode 100644 index 00000000..7b872fd6 --- /dev/null +++ b/serverboot/defs.h @@ -0,0 +1,95 @@ +/* + * 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 new file mode 100644 index 00000000..208df5ce --- /dev/null +++ b/serverboot/dir.h @@ -0,0 +1,142 @@ +/* + * 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 + * 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 new file mode 100644 index 00000000..e0f49ea3 --- /dev/null +++ b/serverboot/disk_inode.h @@ -0,0 +1,101 @@ +/* + * 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 */ + uid_t ic_uid; /* 4: owner's user id */ + gid_t 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 new file mode 100644 index 00000000..43690b2f --- /dev/null +++ b/serverboot/disk_inode_ffs.h @@ -0,0 +1,99 @@ +/* + * 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 new file mode 100644 index 00000000..1d103d3c --- /dev/null +++ b/serverboot/elf-load.c @@ -0,0 +1,88 @@ +/* + * 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 +#include +#include +#include + +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; + Elf32_Ehdr x; + Elf32_Phdr *phdr, *ph; + vm_size_t phsize; + 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.e_ident[EI_MAG0] != ELFMAG0) || + (x.e_ident[EI_MAG1] != ELFMAG1) || + (x.e_ident[EI_MAG2] != ELFMAG2) || + (x.e_ident[EI_MAG3] != ELFMAG3)) + return EX_NOT_EXECUTABLE; + + /* Make sure the file is of the right architecture. */ + if ((x.e_ident[EI_CLASS] != ELFCLASS32) || + (x.e_ident[EI_DATA] != MY_EI_DATA) || + (x.e_machine != MY_E_MACHINE)) + return EX_WRONG_ARCH; + + /* XXX others */ + out_info->entry = (vm_offset_t) x.e_entry; + + phsize = x.e_phnum * x.e_phentsize; + phdr = (Elf32_Phdr *)alloca(phsize); + + result = (*read)(handle, x.e_phoff, phdr, phsize, &actual); + if (result) + return result; + if (actual < phsize) + return EX_CORRUPT; + + for (i = 0; i < x.e_phnum; i++) + { + ph = (Elf32_Phdr *)((vm_offset_t)phdr + i * x.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 new file mode 100644 index 00000000..5b5feedc --- /dev/null +++ b/serverboot/exec.c @@ -0,0 +1,88 @@ +/* + * 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 +#include +#include +#include + +#include + +/* + * 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)®s, + ®_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)®s, + reg_size); + + return (char *)regs.uesp; +} + diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c new file mode 100644 index 00000000..9d743368 --- /dev/null +++ b/serverboot/ext2_file_io.c @@ -0,0 +1,1099 @@ +/* + * 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 +#include + +#include +#include + +#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; + register struct ext2_dir_entry *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 *)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); + + ovbcopy(cp, &namebuf[link_len], 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//', + * 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 */ +} + +/* + * 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 +ext2_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) + size = 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 +ext2_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) + size = 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/ext2_fs.h b/serverboot/ext2_fs.h new file mode 100644 index 00000000..4068c002 --- /dev/null +++ b/serverboot/ext2_fs.h @@ -0,0 +1,451 @@ +/* + * linux/include/linux/ext2_fs.h + * + * Copyright (C) 1992, 1993, 1994 Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#ifndef _LINUX_EXT2_FS_H +#define _LINUX_EXT2_FS_H + +/* + * The second extended filesystem constants/structures + */ + +/* + * Define EXT2FS_DEBUG to produce debug messages + */ +#undef EXT2FS_DEBUG + +/* + * Define EXT2FS_DEBUG_CACHE to produce cache debug messages + */ +#undef EXT2FS_DEBUG_CACHE + +/* + * Define EXT2FS_CHECK_CACHE to add some checks to the name cache code + */ +#undef EXT2FS_CHECK_CACHE + +/* + * Define EXT2FS_PRE_02B_COMPAT to convert ext 2 fs prior to 0.2b + */ +#undef EXT2FS_PRE_02B_COMPAT + +/* + * Define DONT_USE_DCACHE to inhibit the directory cache + */ +#define DONT_USE_DCACHE + +/* + * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files + */ +#define EXT2_PREALLOCATE + +/* + * The second extended file system version + */ +#define EXT2FS_DATE "94/03/10" +#define EXT2FS_VERSION "0.5" + +/* + * Debug code + */ +#ifdef EXT2FS_DEBUG +# define ext2_debug(f, a...) { \ + printk ("EXT2-fs DEBUG (%s, %d): %s:", \ + __FILE__, __LINE__, __FUNCTION__); \ + printk (f, ## a); \ + } +#else +# define ext2_debug(f, a...) /**/ +#endif + +/* + * Special inodes numbers + */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_ACL_IDX_INO 3 /* ACL inode */ +#define EXT2_ACL_DATA_INO 4 /* ACL inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ +#define EXT2_FIRST_INO 11 /* First non reserved inode */ + +/* + * The second extended file system magic number + */ +#define EXT2_PRE_02B_MAGIC 0xEF51 +#define EXT2_SUPER_MAGIC 0xEF53 + +/* + * Maximal count of links to a file + */ +#define EXT2_LINK_MAX 32000 + +/* + * Macro-instructions used to manage several block sizes + */ +#define EXT2_MIN_BLOCK_SIZE 1024 +#define EXT2_MAX_BLOCK_SIZE 4096 +#define EXT2_MIN_BLOCK_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) +#else +# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#endif +#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long)) +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10) +#else +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +#endif +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode)) + +/* + * Macro-instructions used to manage fragments + */ +#define EXT2_MIN_FRAG_SIZE 1024 +#define EXT2_MAX_FRAG_SIZE 4096 +#define EXT2_MIN_FRAG_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) +#else +# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) +#endif + +/* + * ACL structures + */ +struct ext2_acl_header /* Header of Access Control Lists */ +{ + unsigned long aclh_size; + unsigned long aclh_file_count; + unsigned long aclh_acle_count; + unsigned long aclh_first_acle; +}; + +struct ext2_acl_entry /* Access Control List Entry */ +{ + unsigned long acle_size; + unsigned short acle_perms; /* Access permissions */ + unsigned short acle_type; /* Type of entry */ + unsigned short acle_tag; /* User or group identity */ + unsigned short acle_pad1; + unsigned long acle_next; /* Pointer on next entry for the */ + /* same inode or on next free entry */ +}; + +/* + * Structure of a blocks group descriptor + */ +struct ext2_old_group_desc +{ + unsigned long bg_block_bitmap; /* Blocks bitmap block */ + unsigned long bg_inode_bitmap; /* Inodes bitmap block */ + unsigned long bg_inode_table; /* Inodes table block */ + unsigned short bg_free_blocks_count; /* Free blocks count */ + unsigned short bg_free_inodes_count; /* Free inodes count */ +}; + +struct ext2_group_desc +{ + unsigned long bg_block_bitmap; /* Blocks bitmap block */ + unsigned long bg_inode_bitmap; /* Inodes bitmap block */ + unsigned long bg_inode_table; /* Inodes table block */ + unsigned short bg_free_blocks_count; /* Free blocks count */ + unsigned short bg_free_inodes_count; /* Free inodes count */ + unsigned short bg_used_dirs_count; /* Directories count */ + unsigned short bg_pad; + unsigned long bg_reserved[3]; +}; + +/* + * Macro-instructions used to manage group descriptors + */ +#ifdef __KERNEL__ +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) +# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) +#else +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) +# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) +#endif + +/* + * Constants relative to the data blocks + */ +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) + +/* + * Inode flags + */ +#define EXT2_SECRM_FL 0x0001 /* Secure deletion */ +#define EXT2_UNRM_FL 0x0002 /* Undelete */ +#define EXT2_COMPR_FL 0x0004 /* Compress file */ +#define EXT2_SYNC_FL 0x0008 /* Synchronous updates */ + +/* + * ioctl commands + */ +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) +#define EXT2_IOC_GETVERSION _IOR('v', 1, long) +#define EXT2_IOC_SETVERSION _IOW('v', 2, long) + +/* + * Structure of an inode on the disk + */ +struct ext2_inode { + unsigned short i_mode; /* File mode */ + unsigned short i_uid; /* Owner Uid */ + unsigned long i_size; /* Size in bytes */ + unsigned long i_atime; /* Access time */ + unsigned long i_ctime; /* Creation time */ + unsigned long i_mtime; /* Modification time */ + unsigned long i_dtime; /* Deletion Time */ + unsigned short i_gid; /* Group Id */ + unsigned short i_links_count; /* Links count */ + unsigned long i_blocks; /* Blocks count */ + unsigned long i_flags; /* File flags */ + unsigned long i_reserved1; + unsigned long i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + unsigned long i_version; /* File version (for NFS) */ + unsigned long i_file_acl; /* File ACL */ + unsigned long i_dir_acl; /* Directory ACL */ + unsigned long i_faddr; /* Fragment address */ + unsigned char i_frag; /* Fragment number */ + unsigned char i_fsize; /* Fragment size */ + unsigned short i_pad1; + unsigned long i_reserved2[2]; +}; + +/* + * File system states + */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleany */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ + +/* + * Mount flags + */ +#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */ +#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */ +#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \ + EXT2_MOUNT_CHECK_STRICT) +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ + +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ + EXT2_MOUNT_##opt) +/* + * Maximal mount counts between two filesystem checks + */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ + +/* + * Behaviour when detecting errors + */ +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE + +/* + * Structure of the super block + */ +struct ext2_super_block { + unsigned long s_inodes_count; /* Inodes count */ + unsigned long s_blocks_count; /* Blocks count */ + unsigned long s_r_blocks_count;/* Reserved blocks count */ + unsigned long s_free_blocks_count;/* Free blocks count */ + unsigned long s_free_inodes_count;/* Free inodes count */ + unsigned long s_first_data_block;/* First Data Block */ + unsigned long s_log_block_size;/* Block size */ + long s_log_frag_size; /* Fragment size */ + unsigned long s_blocks_per_group;/* # Blocks per group */ + unsigned long s_frags_per_group;/* # Fragments per group */ + unsigned long s_inodes_per_group;/* # Inodes per group */ + unsigned long s_mtime; /* Mount time */ + unsigned long s_wtime; /* Write time */ + unsigned short s_mnt_count; /* Mount count */ + short s_max_mnt_count; /* Maximal mount count */ + unsigned short s_magic; /* Magic signature */ + unsigned short s_state; /* File system state */ + unsigned short s_errors; /* Behaviour when detecting errors */ + unsigned short s_pad; + unsigned long s_lastcheck; /* time of last check */ + unsigned long s_checkinterval; /* max. time between checks */ + unsigned long s_reserved[238]; /* Padding to the end of the block */ +}; + +/* + * Structure of a directory entry + */ +#define EXT2_NAME_LEN 255 + +struct ext2_dir_entry { + unsigned long inode; /* Inode number */ + unsigned short rec_len; /* Directory entry length */ + unsigned short name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ + ~EXT2_DIR_ROUND) + +#ifdef __KERNEL__ +/* + * Function prototypes + */ + +/* + * Ok, these declarations are also in but none of the + * ext2 source programs needs to include it so they are duplicated here. + */ +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define NORET_TYPE __volatile__ +# define ATTRIB_NORET /**/ +# define NORET_AND /**/ +#else +# define NORET_TYPE /**/ +# define ATTRIB_NORET __attribute__((noreturn)) +# define NORET_AND noreturn, +#endif + +/* acl.c */ +extern int ext2_permission (struct inode *, int); + +/* balloc.c */ +extern int ext2_new_block (struct super_block *, unsigned long, + unsigned long *, unsigned long *); +extern void ext2_free_blocks (struct super_block *, unsigned long, + unsigned long); +extern unsigned long ext2_count_free_blocks (struct super_block *); +extern void ext2_check_blocks_bitmap (struct super_block *); + +/* bitmap.c */ +extern unsigned long ext2_count_free (struct buffer_head *, unsigned); + +#ifndef DONT_USE_DCACHE +/* dcache.c */ +extern void ext2_dcache_invalidate (unsigned short); +extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long, + const char *, int); +extern void ext2_dcache_add (unsigned short, unsigned long, const char *, + int, unsigned long); +extern void ext2_dcache_remove (unsigned short, unsigned long, const char *, + int); +#endif + +/* dir.c */ +extern int ext2_check_dir_entry (char *, struct inode *, + struct ext2_dir_entry *, struct buffer_head *, + unsigned long); + +/* file.c */ +extern int ext2_read (struct inode *, struct file *, char *, int); +extern int ext2_write (struct inode *, struct file *, char *, int); + +/* fsync.c */ +extern int ext2_sync_file (struct inode *, struct file *); + +/* ialloc.c */ +extern struct inode * ext2_new_inode (const struct inode *, int); +extern void ext2_free_inode (struct inode *); +extern unsigned long ext2_count_free_inodes (struct super_block *); +extern void ext2_check_inodes_bitmap (struct super_block *); + +/* inode.c */ +extern int ext2_bmap (struct inode *, int); + +extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *); +extern struct buffer_head * ext2_bread (struct inode *, int, int, int *); + +extern int ext2_getcluster (struct inode * inode, long block); +extern void ext2_read_inode (struct inode *); +extern void ext2_write_inode (struct inode *); +extern void ext2_put_inode (struct inode *); +extern int ext2_sync_inode (struct inode *); +extern void ext2_discard_prealloc (struct inode *); + +/* ioctl.c */ +extern int ext2_ioctl (struct inode *, struct file *, unsigned int, + unsigned long); + +/* namei.c */ +extern int ext2_open (struct inode *, struct file *); +extern void ext2_release (struct inode *, struct file *); +extern int ext2_lookup (struct inode *,const char *, int, struct inode **); +extern int ext2_create (struct inode *,const char *, int, int, + struct inode **); +extern int ext2_mkdir (struct inode *, const char *, int, int); +extern int ext2_rmdir (struct inode *, const char *, int); +extern int ext2_unlink (struct inode *, const char *, int); +extern int ext2_symlink (struct inode *, const char *, int, const char *); +extern int ext2_link (struct inode *, struct inode *, const char *, int); +extern int ext2_mknod (struct inode *, const char *, int, int, int); +extern int ext2_rename (struct inode *, const char *, int, + struct inode *, const char *, int); + +/* super.c */ +extern void ext2_error (struct super_block *, const char *, const char *, ...) + __attribute__ ((format (printf, 3, 4))); +extern NORET_TYPE void ext2_panic (struct super_block *, const char *, + const char *, ...) + __attribute__ ((NORET_AND format (printf, 3, 4))); +extern void ext2_warning (struct super_block *, const char *, const char *, ...) + __attribute__ ((format (printf, 3, 4))); +extern void ext2_put_super (struct super_block *); +extern void ext2_write_super (struct super_block *); +extern int ext2_remount (struct super_block *, int *, char *); +extern struct super_block * ext2_read_super (struct super_block *,void *,int); +extern void ext2_statfs (struct super_block *, struct statfs *); + +/* truncate.c */ +extern void ext2_truncate (struct inode *); + +/* + * Inodes and files operations + */ + +/* dir.c */ +extern struct inode_operations ext2_dir_inode_operations; + +/* file.c */ +extern struct inode_operations ext2_file_inode_operations; + +/* symlink.c */ +extern struct inode_operations ext2_symlink_inode_operations; + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_EXT2_FS_H */ diff --git a/serverboot/ffs_compat.c b/serverboot/ffs_compat.c new file mode 100644 index 00000000..46644a9b --- /dev/null +++ b/serverboot/ffs_compat.c @@ -0,0 +1,63 @@ +/* + * 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 +#include + +#include +#include + +#include + +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 new file mode 100644 index 00000000..d78840f5 --- /dev/null +++ b/serverboot/ffs_compat.h @@ -0,0 +1,54 @@ +/* + * 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 new file mode 100644 index 00000000..889ca4e5 --- /dev/null +++ b/serverboot/ffs_file_io.c @@ -0,0 +1,1085 @@ +/* + * 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 +#include + +#include +#include + +#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); + + ovbcopy(cp, &namebuf[link_len], 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//', + * 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 */ +} + +/* + * 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 +ffs_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) + size = 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 +ffs_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) + size = 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.c b/serverboot/file_io.c new file mode 100644 index 00000000..141fdcfe --- /dev/null +++ b/serverboot/file_io.c @@ -0,0 +1,225 @@ +/* + * 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 +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 */ +{ + switch (fdp->f_fstype) { + case EXT2_FS: + return ext2_page_read_file_direct(fdp, offset, size, addr, size_read); + case MINIX_FS: + return minix_page_read_file_direct(fdp, offset, size, addr, size_read); + default: + return ffs_page_read_file_direct(fdp, offset, size, addr, size_read); + } +} + +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 */ +{ + switch (fdp->f_fstype) { + case EXT2_FS: + return ext2_page_write_file_direct(fdp, offset, addr, size, size_written); + case MINIX_FS: + return minix_page_write_file_direct(fdp, offset, addr, size, size_written); + default: + return ffs_page_write_file_direct(fdp, offset, addr, size, size_written); + } +} + +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; + } +} diff --git a/serverboot/file_io.h b/serverboot/file_io.h new file mode 100644 index 00000000..5706ce5b --- /dev/null +++ b/serverboot/file_io.h @@ -0,0 +1,174 @@ +/* + * 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 +#include + +#include + +#include +#include "minix_fs.h" +#include "ext2_fs.h" +#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. + */ + +#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 + a routine */ + +#endif /* _FILE_IO_H_ */ diff --git a/serverboot/fs.h b/serverboot/fs.h new file mode 100644 index 00000000..5809ed93 --- /dev/null +++ b/serverboot/fs.h @@ -0,0 +1,455 @@ +/* + * 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 new file mode 100644 index 00000000..61d14460 --- /dev/null +++ b/serverboot/gets.c @@ -0,0 +1,90 @@ +/* + * 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 +#include +#include + +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/kalloc.c b/serverboot/kalloc.c new file mode 100644 index 00000000..80438738 --- /dev/null +++ b/serverboot/kalloc.c @@ -0,0 +1,274 @@ +/* + * Mach Operating System + * Copyright (c) 1993-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. + */ +/* + * File: kern/kalloc.c + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * General kernel memory allocator. This allocator is designed + * to be used by the kernel to manage dynamic memory fast. + */ + +#include +#include /* for spin locks */ + +#define DEBUG + +/* + * All allocations of size less than kalloc_max are rounded to the + * next highest power of 2. + */ +vm_size_t kalloc_max; /* max before we use vm_allocate */ +#define MINSIZE 4 /* minimum allocation size */ + +struct free_list { + spin_lock_t lock; + vm_offset_t head; /* head of free list */ +#ifdef DEBUG + int count; +#endif /*DEBUG*/ +}; + +#define KLIST_MAX 13 + /* sizes: 4, 8, 16, 32, 64, + 128, 256, 512, 1024, + 2048, 4096, 8192, 16384 */ +struct free_list kfree_list[KLIST_MAX]; + +spin_lock_t kget_space_lock; +vm_offset_t kalloc_next_space = 0; +vm_offset_t kalloc_end_of_space = 0; + +vm_size_t kalloc_wasted_space = 0; + +boolean_t kalloc_initialized = FALSE; + +/* + * Initialize the memory allocator. This should be called only + * once on a system wide basis (i.e. first processor to get here + * does the initialization). + * + * This initializes all of the zones. + */ + +void kalloc_init(void) +{ + vm_offset_t min, max; + vm_size_t size; + register int i; + + /* + * Support free lists for items up to vm_page_size or + * 16Kbytes, whichever is less. + */ + + if (vm_page_size > 16*1024) + kalloc_max = 16*1024; + else + kalloc_max = vm_page_size; + + for (i = 0; i < KLIST_MAX; i++) { + spin_lock_init(&kfree_list[i].lock); + kfree_list[i].head = 0; + } + spin_lock_init(&kget_space_lock); + + /* + * Do not allocate memory at address 0. + */ + kalloc_next_space = vm_page_size; + kalloc_end_of_space = vm_page_size; +} + +/* + * Contiguous space allocator for items of less than a page size. + */ +vm_offset_t kget_space(vm_offset_t size) +{ + vm_size_t space_to_add; + vm_offset_t new_space = 0; + vm_offset_t addr; + + spin_lock(&kget_space_lock); + while (kalloc_next_space + size > kalloc_end_of_space) { + /* + * Add at least one page to allocation area. + */ + space_to_add = round_page(size); + + if (new_space == 0) { + /* + * Unlock and allocate memory. + * Try to make it contiguous with the last + * allocation area. + */ + spin_unlock(&kget_space_lock); + + new_space = kalloc_end_of_space; + if (vm_map(mach_task_self(), + &new_space, space_to_add, (vm_offset_t) 0, TRUE, + MEMORY_OBJECT_NULL, (vm_offset_t) 0, FALSE, + VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT) + != KERN_SUCCESS) + return 0; + wire_memory(new_space, space_to_add, + VM_PROT_READ|VM_PROT_WRITE); + spin_lock(&kget_space_lock); + continue; + } + + /* + * Memory was allocated in a previous iteration. + * Check whether the new region is contiguous with the + * old one. + */ + if (new_space != kalloc_end_of_space) { + /* + * Throw away the remainder of the old space, + * and start a new one. + */ + kalloc_wasted_space += + kalloc_end_of_space - kalloc_next_space; + kalloc_next_space = new_space; + } + kalloc_end_of_space = new_space + space_to_add; + + new_space = 0; + } + + addr = kalloc_next_space; + kalloc_next_space += size; + spin_unlock(&kget_space_lock); + + if (new_space != 0) + (void) vm_deallocate(mach_task_self(), new_space, space_to_add); + + return addr; +} + +void *kalloc(vm_size_t size) +{ + register vm_size_t allocsize; + vm_offset_t addr; + register struct free_list *fl; + + if (!kalloc_initialized) { + kalloc_init(); + kalloc_initialized = TRUE; + } + + /* compute the size of the block that we will actually allocate */ + + allocsize = size; + if (size < kalloc_max) { + allocsize = MINSIZE; + fl = kfree_list; + while (allocsize < size) { + allocsize <<= 1; + fl++; + } + } + + /* + * If our size is still small enough, check the queue for that size + * and allocate. + */ + + if (allocsize < kalloc_max) { + spin_lock(&fl->lock); + if ((addr = fl->head) != 0) { + fl->head = *(vm_offset_t *)addr; +#ifdef DEBUG + fl->count--; +#endif + spin_unlock(&fl->lock); + } + else { + spin_unlock(&fl->lock); + addr = kget_space(allocsize); + } + } + else { + if (vm_allocate(mach_task_self(), &addr, allocsize, TRUE) + != KERN_SUCCESS) + addr = 0; + } + return (void *) addr; +} + +void +kfree( void *data, + vm_size_t size) +{ + register vm_size_t freesize; + register struct free_list *fl; + + freesize = size; + if (size < kalloc_max) { + freesize = MINSIZE; + fl = kfree_list; + while (freesize < size) { + freesize <<= 1; + fl++; + } + } + + if (freesize < kalloc_max) { + spin_lock(&fl->lock); + *(vm_offset_t *)data = fl->head; + fl->head = (vm_offset_t) data; +#ifdef DEBUG + fl->count++; +#endif + spin_unlock(&fl->lock); + } + else { + (void) vm_deallocate(mach_task_self(), (vm_offset_t)data, freesize); + } +} + +void *malloc(vm_size_t size) +{ + return (void *)kalloc(size); +} + +void free(void *addr) +{ + /* Just ignore harmless attempts at cleanliness. */ + /* panic("free not implemented"); */ +} + +void malloc_fork_prepare() +{ +} + +void malloc_fork_parent() +{ +} + +void malloc_fork_child() +{ +} diff --git a/serverboot/load.c b/serverboot/load.c new file mode 100644 index 00000000..9a3e3b98 --- /dev/null +++ b/serverboot/load.c @@ -0,0 +1,406 @@ +/* + * 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 +#include +#include +#include +#include "../boot/boot_script.h" + +#include + + +boolean_t load_protect_text = TRUE; + + +struct stuff +{ + struct file *fp; + task_t user_task; + + 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; +} + +mach_port_t boot_script_read_file (const char *file) +{ return MACH_PORT_NULL; } /* XXX */ + +int +boot_script_exec_cmd (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; + 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("openi %d", result); + } + + /* + * Add space for: + * arg_count + * pointers to arguments + * trailing 0 pointer + * dummy 0 pointer to environment variables + * and align to integer boundary + */ + arg_len += sizeof(integer_t) + (2 + arg_count) * sizeof(char *); + 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); + if (result) + panic("(bootstrap) exec_load %s: error %d", namebuf, result); +#if 0 + printf("(bootstrap): 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: %x", namebuf, result); + arg_pos = set_regs(user_task, user_thread, &info, arg_len); + + /* + * Read symbols from the executable file. + */ +#if 0 + printf("(bootstrap): 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 *) + + 2 * sizeof(char *) + + sizeof(integer_t); + k_cp = (char *)k_arg_start + arg_count * sizeof(char *) + + 2 * sizeof(char *) + + sizeof(integer_t); + + /* + * first the argument count + */ + *k_ap++ = (char *)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; + bcopy (argstrings, k_cp, argslen); + + /* + * last, the trailing 0 argument and a null environment pointer. + */ + *k_ap++ = (char *)0; + *k_ap = (char *)0; + + /* + * 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/minix_ffs_compat.c b/serverboot/minix_ffs_compat.c new file mode 100644 index 00000000..7d493520 --- /dev/null +++ b/serverboot/minix_ffs_compat.c @@ -0,0 +1,62 @@ +/* + * 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 +#include + +#include +#include + +#include + +#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 new file mode 100644 index 00000000..cc038032 --- /dev/null +++ b/serverboot/minix_ffs_compat.h @@ -0,0 +1,43 @@ +/* + * 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 new file mode 100644 index 00000000..0a18092b --- /dev/null +++ b/serverboot/minix_file_io.c @@ -0,0 +1,966 @@ +/* + * 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 +#include + +#include +#include + +#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 */ +} + +/* + * Special read and write routines for default pager. + * Assume that all offsets and sizes are multiples + * of DEV_BSIZE. + */ + +#define minix_fdir_blkoff(fdp, offset) /* offset % fd_bsize */ \ + ((offset) & ((fdp)->fd_bsize - 1)) +#define minix_fdir_lblkno(fdp, offset) /* offset / fd_bsize */ \ + ((offset) >> (fdp)->fd_bshift) + +#define minix_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 +minix_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 minix_daddr_t file_block; + minix_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 = minix_fdir_blkoff(fdp, offset); + file_block = minix_fdir_lblkno(fdp, offset); + + if (file_is_device(fdp)) { + disk_block = file_block; + } else { + disk_block = ((minix_daddr_t *)fdp->fd_blocks)[file_block]; + if (disk_block == 0) + return (FS_NOT_IN_FILE); + } + + if (size > fdp->fd_bsize) + size = fdp->fd_bsize; + + return (device_read(fdp->fd_dev, + 0, + (recnum_t) (minix_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 +minix_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 minix_daddr_t file_block; + minix_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 = minix_fdir_blkoff(fdp, offset); + file_block = minix_fdir_lblkno(fdp, offset); + + if (file_is_device(fdp)) { + disk_block = file_block; + } else { + disk_block = ((minix_daddr_t *)fdp->fd_blocks)[file_block]; + if (disk_block == 0) + return (FS_NOT_IN_FILE); + } + + if (size > fdp->fd_bsize) + size = 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) (minix_fdir_fsbtodb(fdp, disk_block) + btodb(off)), + (char *) addr, + size, + &num_written); + *size_written = num_written; + return rc; +} diff --git a/serverboot/minix_fs.h b/serverboot/minix_fs.h new file mode 100644 index 00000000..678f3a0d --- /dev/null +++ b/serverboot/minix_fs.h @@ -0,0 +1,107 @@ +/* + * 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 . 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 new file mode 100644 index 00000000..144cf064 --- /dev/null +++ b/serverboot/minix_super.h @@ -0,0 +1,49 @@ +/* + * 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 new file mode 100644 index 00000000..80197500 --- /dev/null +++ b/serverboot/panic.c @@ -0,0 +1,59 @@ +/* + * 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 +#include +#include + +static mach_port_t master_host_port; + +panic_init(port) + mach_port_t port; +{ + master_host_port = port; +} + +/*VARARGS1*/ +panic(s, va_alist) + char *s; + va_dcl +{ + va_list listp; + + clearerr (stdout); + printf("bootstrap/default-pager panic: "); + va_start(listp); + 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/queue.h b/serverboot/queue.h new file mode 100644 index 00000000..3e93476f --- /dev/null +++ b/serverboot/queue.h @@ -0,0 +1,316 @@ +/* + * 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 rights + * to redistribute these changes. + */ +/* + * File: queue.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Type definitions for generic queues. + * + */ + +#ifndef _QUEUE_H_ +#define _QUEUE_H_ + +/* + * Queue of abstract objects. Queue is maintained + * within that object. + * + * Supports fast removal from within the queue. + * + * How to declare a queue of elements of type "foo_t": + * In the "*foo_t" type, you must have a field of + * type "queue_chain_t" to hold together this queue. + * There may be more than one chain through a + * "foo_t", for use by different queues. + * + * Declare the queue as a "queue_t" type. + * + * Elements of the queue (of type "foo_t", that is) + * are referred to by reference, and cast to type + * "queue_entry_t" within this module. + */ + +/* + * A generic doubly-linked list (queue). + */ + +struct queue_entry { + struct queue_entry *next; /* next element */ + struct queue_entry *prev; /* previous element */ +}; + +typedef struct queue_entry *queue_t; +typedef struct queue_entry queue_head_t; +typedef struct queue_entry queue_chain_t; +typedef struct queue_entry *queue_entry_t; + +/* + * Macro: queue_init + * Function: + * Initialize the given queue. + * Header: + * void queue_init(q) + * queue_t q; / * MODIFIED * / + */ +#define queue_init(q) ((q)->next = (q)->prev = q) + +/* + * Macro: queue_first + * Function: + * Returns the first entry in the queue, + * Header: + * queue_entry_t queue_first(q) + * queue_t q; / * IN * / + */ +#define queue_first(q) ((q)->next) + +/* + * Macro: queue_next + * Function: + * Returns the entry after an item in the queue. + * Header: + * queue_entry_t queue_next(qc) + * queue_t qc; + */ +#define queue_next(qc) ((qc)->next) + +/* + * Macro: queue_last + * Function: + * Returns the last entry in the queue. + * Header: + * queue_entry_t queue_last(q) + * queue_t q; / * IN * / + */ +#define queue_last(q) ((q)->prev) + +/* + * Macro: queue_prev + * Function: + * Returns the entry before an item in the queue. + * Header: + * queue_entry_t queue_prev(qc) + * queue_t qc; + */ +#define queue_prev(qc) ((qc)->prev) + +/* + * Macro: queue_end + * Function: + * Tests whether a new entry is really the end of + * the queue. + * Header: + * boolean_t queue_end(q, qe) + * queue_t q; + * queue_entry_t qe; + */ +#define queue_end(q, qe) ((q) == (qe)) + +/* + * Macro: queue_empty + * Function: + * Tests whether a queue is empty. + * Header: + * boolean_t queue_empty(q) + * queue_t q; + */ +#define queue_empty(q) queue_end((q), queue_first(q)) + + +/*----------------------------------------------------------------*/ +/* + * Macros that operate on generic structures. The queue + * chain may be at any location within the structure, and there + * may be more than one chain. + */ + +/* + * Macro: queue_enter + * Function: + * Insert a new element at the tail of the queue. + * Header: + * void queue_enter(q, elt, type, field) + * queue_t q; + * elt; + * is what's in our queue + * is the chain field in (*) + */ +#define queue_enter(head, elt, type, field) \ +{ \ + register queue_entry_t prev; \ + \ + prev = (head)->prev; \ + if ((head) == prev) { \ + (head)->next = (queue_entry_t) (elt); \ + } \ + else { \ + ((type)prev)->field.next = (queue_entry_t)(elt);\ + } \ + (elt)->field.prev = prev; \ + (elt)->field.next = head; \ + (head)->prev = (queue_entry_t) elt; \ +} + +/* + * Macro: queue_enter_first + * Function: + * Insert a new element at the head of the queue. + * Header: + * void queue_enter_first(q, elt, type, field) + * queue_t q; + * elt; + * is what's in our queue + * is the chain field in (*) + */ +#define queue_enter_first(head, elt, type, field) \ +{ \ + register queue_entry_t next; \ + \ + next = (head)->next; \ + if ((head) == next) { \ + (head)->prev = (queue_entry_t) (elt); \ + } \ + else { \ + ((type)next)->field.prev = (queue_entry_t)(elt);\ + } \ + (elt)->field.next = next; \ + (elt)->field.prev = head; \ + (head)->next = (queue_entry_t) elt; \ +} + +/* + * Macro: queue_field [internal use only] + * Function: + * Find the queue_chain_t (or queue_t) for the + * given element (thing) in the given queue (head) + */ +#define queue_field(head, thing, type, field) \ + (((head) == (thing)) ? (head) : &((type)(thing))->field) + +/* + * Macro: queue_remove + * Function: + * Remove an arbitrary item from the queue. + * Header: + * void queue_remove(q, qe, type, field) + * arguments as in queue_enter + */ +#define queue_remove(head, elt, type, field) \ +{ \ + register queue_entry_t next, prev; \ + \ + next = (elt)->field.next; \ + prev = (elt)->field.prev; \ + \ + if ((head) == next) \ + (head)->prev = prev; \ + else \ + ((type)next)->field.prev = prev; \ + \ + if ((head) == prev) \ + (head)->next = next; \ + else \ + ((type)prev)->field.next = next; \ +} + +/* + * Macro: queue_remove_first + * Function: + * Remove and return the entry at the head of + * the queue. + * Header: + * queue_remove_first(head, entry, type, field) + * entry is returned by reference + */ +#define queue_remove_first(head, entry, type, field) \ +{ \ + register queue_entry_t next; \ + \ + (entry) = (type) ((head)->next); \ + next = (entry)->field.next; \ + \ + if ((head) == next) \ + (head)->prev = (head); \ + else \ + ((type)(next))->field.prev = (head); \ + (head)->next = next; \ +} + +/* + * Macro: queue_remove_last + * Function: + * Remove and return the entry at the tail of + * the queue. + * Header: + * queue_remove_last(head, entry, type, field) + * entry is returned by reference + */ +#define queue_remove_last(head, entry, type, field) \ +{ \ + register queue_entry_t prev; \ + \ + (entry) = (type) ((head)->prev); \ + prev = (entry)->field.prev; \ + \ + if ((head) == prev) \ + (head)->next = (head); \ + else \ + ((type)(prev))->field.next = (head); \ + (head)->prev = prev; \ +} + +/* + * Macro: queue_assign + */ +#define queue_assign(to, from, type, field) \ +{ \ + ((type)((from)->prev))->field.next = (to); \ + ((type)((from)->next))->field.prev = (to); \ + *to = *from; \ +} + +/* + * Macro: queue_iterate + * Function: + * iterate over each item in the queue. + * Generates a 'for' loop, setting elt to + * each item in turn (by reference). + * Header: + * queue_iterate(q, elt, type, field) + * queue_t q; + * elt; + * is what's in our queue + * is the chain field in (*) + */ +#define queue_iterate(head, elt, type, field) \ + for ((elt) = (type) queue_first(head); \ + !queue_end((head), (queue_entry_t)(elt)); \ + (elt) = (type) queue_next(&(elt)->field)) + + + +#endif _QUEUE_H_ diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c new file mode 100644 index 00000000..53c097ba --- /dev/null +++ b/serverboot/strfcns.c @@ -0,0 +1,117 @@ +/* + * 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 + +#define EXPORT_BOOLEAN +#include + +/* + * 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(dest, va_alist) + register char * dest; + va_dcl +{ + va_list argptr; + register char * src; + register int c; + + va_start(argptr); + while ((src = va_arg(argptr, char *)) != (char *)0) { + + while ((c = *src++) != '\0') + *dest++ = c; + } + *dest = '\0'; + 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); +} + +/* + * ovbcopy - like bcopy, but recognizes overlapping ranges and handles + * them correctly. + */ +ovbcopy(from, to, bytes) + char *from, *to; + int bytes; /* num bytes to copy */ +{ + /* Assume that bcopy copies left-to-right (low addr first). */ + if (from + bytes <= to || to + bytes <= from || to == from) + bcopy(from, to, bytes); /* non-overlapping or no-op*/ + else if (from > to) + bcopy(from, to, bytes); /* overlapping but OK */ + else { + /* to > from: overlapping, and must copy right-to-left. */ + from += bytes - 1; + to += bytes - 1; + while (bytes-- > 0) + *to-- = *from--; + } +} + +/* + * Return a pointer to the first occurence of 'c' in + * string s, or 0 if none. + */ +char * +index(s, c) + char *s; + char c; +{ + char cc; + + while ((cc = *s) != c) { + if (cc == 0) + return 0; + s++; + } + return s; +} + diff --git a/serverboot/translate_root.c b/serverboot/translate_root.c new file mode 100644 index 00000000..b544d5c8 --- /dev/null +++ b/serverboot/translate_root.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1995 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: Stephen Clawson, University of Utah CSL + */ + + +#include "translate_root.h" + +unsigned int atoh(ap) + char *ap; +{ + register char *p; + register unsigned int n; + register int digit,lcase; + + p = ap; + n = 0; + while(*p == ' ') + p++; + while ((digit = (*p >= '0' && *p <= '9')) || + (lcase = (*p >= 'a' && *p <= 'f')) || + (*p >= 'A' && *p <= 'F')) { + n *= 16; + if (digit) n += *p++ - '0'; + else if (lcase) n += 10 + (*p++ - 'a'); + else n += 10 + (*p++ - 'A'); + } + return(n); +} + +/* + * Translate the root device from whatever strange encoding we might + * be given. Currently that includes BSD's slightly different name + * for IDE devices, and Linux's device number encoding (since that's + * what LILO passes us, for whatever reason). + */ +char * +translate_root(root_string) + char *root_string; +{ + int linuxdev = atoh(root_string); + + /* LILO passes us a string representing the linux device number of + * our root device. Since this is _not_ what we want, we'll make + * a stab at converting it. + * + * Linux major numbers we care about: + * + * 2 = fd + * 3 = hd[ab] (IDE channel 1) + * 8 = sd + * 22 = hd[cd] (IDE channel 2) + * + */ + if (linuxdev) { + if (LINUX_MAJOR(linuxdev) == 2) { + root_string[0] = 'f'; + root_string[1] = 'd'; + root_string[2] = LINUX_FD_DEVICE_NR(linuxdev) + '0'; + root_string[3] = '\0'; + } else { + int shift; + + switch (LINUX_MAJOR(linuxdev)) { + case 3: + case 22: + shift = 6; + root_string[0] = 'h'; + break; + case 8: + shift = 4; + root_string[0] = 's'; + break; + default: + printf("Unknown linux device" + "(major = %d, minor = %d) passed as " + "root argument!\n" + "using hd0a as default.\n", + LINUX_MAJOR(linuxdev), + LINUX_MINOR(linuxdev)); + shift = 1; + root_string[0] = 'h'; + linuxdev = 1; + } + + root_string[1] = 'd'; + root_string[2] = LINUX_DEVICE_NR(linuxdev, shift)+'0'; + root_string[3] = LINUX_PARTN(linuxdev, shift)+'a' - 1; + root_string[4] = '\0'; + } + } else + /* This could be handled much simpler in the BSD boot + * adapter code, but baford insists that the boot + * adapter code shouldn't be tainted by Mach's notion + * of the `correct' device naming. Thus, we get wdxx + * instead of hdxx if booted from the BSD bootblocks, + * and this is the lame hack that tries to convert it. + */ + if (root_string[0] == 'w' && root_string[1] == 'd') + root_string[0] = 'h'; + + return root_string; +} + + + diff --git a/serverboot/translate_root.h b/serverboot/translate_root.h new file mode 100644 index 00000000..e5bab70a --- /dev/null +++ b/serverboot/translate_root.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1995 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: Stephen Clawson, University of Utah CSL + */ + +#ifndef _TRANSLATE_ROOT_H_ +#define _TRANSLATE_ROOT_H_ + +#define DEFAULT_ROOT "hd0a" + +extern char *translate_root(char *); + +#define LINUX_MAJOR(a) (int)((unsigned short)(a) >> 8) +#define LINUX_MINOR(a) (int)((unsigned short)(a) & 0xFF) + +#define LINUX_PARTN(device, shift) \ + (LINUX_MINOR(device) & ((1 << (shift)) - 1)) +#define LINUX_DEVICE_NR(device, shift) \ + (LINUX_MINOR(device) >> (shift)) +#define LINUX_FD_DEVICE_NR(device) \ + ( ((device) & 3) | (((device) & 0x80 ) >> 5 )) + +#endif /* _TRANSLATE_ROOT_H_ */ diff --git a/serverboot/wiring.c b/serverboot/wiring.c new file mode 100644 index 00000000..550c1bec --- /dev/null +++ b/serverboot/wiring.c @@ -0,0 +1,140 @@ +/* + * 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. + */ +/* + * Package to wire current task's memory. + */ +#include +#include +#include + +mach_port_t this_task; /* our task */ +mach_port_t priv_host_port = MACH_PORT_NULL; + /* the privileged host port */ + +void +wire_setup(host_priv) + mach_port_t host_priv; +{ + priv_host_port = host_priv; + this_task = mach_task_self(); +} + +void +wire_memory(start, size, prot) + vm_address_t start; + vm_size_t size; + vm_prot_t prot; +{ + kern_return_t kr; + + if (priv_host_port == MACH_PORT_NULL) + return; + + kr = vm_wire(priv_host_port, + this_task, + start, size, prot); + if (kr != KERN_SUCCESS) + panic("mem_wire: %d", kr); +} + +void +wire_thread() +{ + kern_return_t kr; + + if (priv_host_port == MACH_PORT_NULL) + return; + + kr = thread_wire(priv_host_port, + mach_thread_self(), + TRUE); + if (kr != KERN_SUCCESS) + panic("wire_thread: %d", kr); +} + +void +wire_all_memory() +{ + register kern_return_t kr; + vm_offset_t address; + vm_size_t size; + vm_prot_t protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + boolean_t is_shared; + memory_object_name_t object; + vm_offset_t offset; + + if (priv_host_port == MACH_PORT_NULL) + return; + + /* iterate thru all regions, wiring */ + address = 0; + while ( + (kr = vm_region(this_task, &address, + &size, + &protection, + &max_protection, + &inheritance, + &is_shared, + &object, + &offset)) + == KERN_SUCCESS) + { + if (MACH_PORT_VALID(object)) + (void) mach_port_deallocate(this_task, object); + if (protection != VM_PROT_NONE) + wire_memory(address, size, protection); + address += size; + } +} + +/* + * Alias for vm_allocate to return wired memory. + */ +kern_return_t +vm_allocate(task, address, size, anywhere) + task_t task; + vm_address_t *address; + vm_size_t size; + boolean_t anywhere; +{ + kern_return_t kr; + + if (anywhere) + *address = VM_MIN_ADDRESS; + kr = vm_map(task, + address, size, (vm_offset_t) 0, anywhere, + MEMORY_OBJECT_NULL, (vm_offset_t)0, FALSE, + VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT); + if (kr != KERN_SUCCESS) + return kr; + + if (task == this_task) + (void) vm_wire(priv_host_port, task, *address, size, + VM_PROT_DEFAULT); + return KERN_SUCCESS; +} diff --git a/serverboot/wiring.h b/serverboot/wiring.h new file mode 100644 index 00000000..b5f8e53f --- /dev/null +++ b/serverboot/wiring.h @@ -0,0 +1,35 @@ +/* + * 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 + * 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. + */ +/* + * Package to wire current task's memory. + */ +#include +#include + +extern void wire_setup(/* mach_port_t host_priv */); +extern void wire_memory(/* vm_address_t, vm_size_t, vm_prot_t */); +extern void wire_thread(); +extern void wire_all_memory(); -- cgit v1.2.3 From 8e98bdc7a128545a0b7a8d4686f822719ac74ecb Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 4 Apr 1997 01:13:44 +0000 Subject: Thu Apr 3 20:00:58 1997 Thomas Bushnell, n/BSG * elf-load.c (exec_load): Include instead of . Include "mach-exec.h" instead of . (exec_load) [i386]: Check for i386 types directly; abandon old MY_EI_DATA and MY_E_MACHINE. * load.c: Include "mach-exec.h" instead of . * exec.c: Likewise. * mach-exec.h: New file. --- serverboot/ChangeLog | 11 +++++ serverboot/elf-load.c | 12 +++-- serverboot/exec.c | 2 +- serverboot/load.c | 2 +- serverboot/mach-exec.h | 130 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 serverboot/mach-exec.h diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 52f60f35..c2caea69 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,14 @@ +Thu Apr 3 20:00:58 1997 Thomas Bushnell, n/BSG + + * elf-load.c (exec_load): Include instead of + . Include "mach-exec.h" instead of + . + (exec_load) [i386]: Check for i386 types directly; abandon old + MY_EI_DATA and MY_E_MACHINE. + * load.c: Include "mach-exec.h" instead of . + * exec.c: Likewise. + * mach-exec.h: New file. + Wed Mar 19 14:45:27 1997 Thomas Bushnell, n/BSG * panic.c (panic): Clear possible errors on stdout before printing diff --git a/serverboot/elf-load.c b/serverboot/elf-load.c index 1d103d3c..a30124a2 100644 --- a/serverboot/elf-load.c +++ b/serverboot/elf-load.c @@ -24,8 +24,8 @@ #include #include -#include -#include +#include +#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) @@ -50,10 +50,14 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, return EX_NOT_EXECUTABLE; /* Make sure the file is of the right architecture. */ +#ifdef i386 if ((x.e_ident[EI_CLASS] != ELFCLASS32) || - (x.e_ident[EI_DATA] != MY_EI_DATA) || - (x.e_machine != MY_E_MACHINE)) + (x.e_ident[EI_DATA] != ELFDATA2LSB) || + (x.e_machine != EM_386)) return EX_WRONG_ARCH; +#else +#error Not ported to this architecture! +#endif /* XXX others */ out_info->entry = (vm_offset_t) x.e_entry; diff --git a/serverboot/exec.c b/serverboot/exec.c index 5b5feedc..a0773f4c 100644 --- a/serverboot/exec.c +++ b/serverboot/exec.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include "mach-exec.h" #include diff --git a/serverboot/load.c b/serverboot/load.c index 9a3e3b98..36e8307b 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include "mach-exec.h" #include "../boot/boot_script.h" #include diff --git a/serverboot/mach-exec.h b/serverboot/mach-exec.h new file mode 100644 index 00000000..94b234b0 --- /dev/null +++ b/serverboot/mach-exec.h @@ -0,0 +1,130 @@ +/* + * 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 +#include + +/* 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_ */ -- cgit v1.2.3 From fd925dedd58c3e2e5b4943d94475e68eddb3ccf6 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 9 Apr 1997 18:03:32 +0000 Subject: Wed Apr 9 13:57:44 1997 Thomas Bushnell, n/BSG * default_pager.c (default_pager_default_thread): New function. (default_pager): Fork default_pager_default_thread instead of doing it here to avoid the possibility that we are on a tiny stack. Current thread dies. --- serverboot/ChangeLog | 7 +++++++ serverboot/default_pager.c | 23 ++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index c2caea69..4d589510 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +Wed Apr 9 13:57:44 1997 Thomas Bushnell, n/BSG + + * default_pager.c (default_pager_default_thread): New function. + (default_pager): Fork default_pager_default_thread instead of + doing it here to avoid the possibility that we are on a tiny + stack. Current thread dies. + Thu Apr 3 20:00:58 1997 Thomas Bushnell, n/BSG * elf-load.c (exec_load): Include instead of diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 6c44bd0d..e7d5fa5a 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2663,6 +2663,20 @@ default_pager_thread_privileges() privileges */ } +any_t +default_pager_default_thread (arg) + any_t arg; +{ + for (;;) { + kr = mach_msg_server(default_pager_demux_default, + default_pager_msg_size_default, + default_pager_default_set); + panic(my_name, kr); + } +} + + + any_t default_pager_thread(arg) any_t arg; @@ -2876,13 +2890,8 @@ default_pager() printf ("dp6\n"); - for (;;) { - printf ("dp7\n"); - kr = mach_msg_server(default_pager_demux_default, - default_pager_msg_size_default, - default_pager_default_set); - panic(my_name, kr); - } + cthread_fork (default_pager_default_thread, 0); + cthread_exit (cthread_self ()); } /* -- cgit v1.2.3 From 234a828078cd55af65a55d410aa9b5f35b6506f9 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 9 Apr 1997 18:09:14 +0000 Subject: Wed Apr 9 13:57:44 1997 Thomas Bushnell, n/BSG * default_pager.c (default_pager_default_thread): New function. Delete old variable with this name, it was never used. (default_pager): Fork default_pager_default_thread instead of doing it here to avoid the possibility that we are on a tiny stack. Current thread dies. --- serverboot/ChangeLog | 1 + serverboot/default_pager.c | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 4d589510..ccfccbe2 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,6 +1,7 @@ Wed Apr 9 13:57:44 1997 Thomas Bushnell, n/BSG * default_pager.c (default_pager_default_thread): New function. + Delete old variable with this name, it was never used. (default_pager): Fork default_pager_default_thread instead of doing it here to avoid the possibility that we are on a tiny stack. Current thread dies. diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index e7d5fa5a..85590f18 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -1800,7 +1800,6 @@ void pager_port_finish_refs(ds) task_t default_pager_self; /* Our task port. */ mach_port_t default_pager_default_port; /* Port for memory_object_create. */ -thread_t default_pager_default_thread; /* Thread for default_port. */ /* We catch exceptions on ourself & startup using this port. */ mach_port_t default_pager_exception_port; @@ -2832,14 +2831,6 @@ default_pager() printf ("dp3\n"); - /* - * This thread will receive memory_object_create - * requests from the kernel and default_pager_object_create - * requests from the user via default_pager_default_port. - */ - - default_pager_default_thread = mach_thread_self(); - kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_PORT_SET, &default_pager_internal_set); if (kr != KERN_SUCCESS) -- cgit v1.2.3 From 250b75ac0877e7573c9db66225451b5808c76310 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 9 Apr 1997 18:10:29 +0000 Subject: *** empty log message *** --- serverboot/default_pager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 85590f18..ba305359 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2666,6 +2666,7 @@ any_t default_pager_default_thread (arg) any_t arg; { + kern_return_t kr; for (;;) { kr = mach_msg_server(default_pager_demux_default, default_pager_msg_size_default, -- cgit v1.2.3 From 490115514139529e966bb579acdb61e0a480e627 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 14 Apr 1997 16:50:48 +0000 Subject: *** empty log message *** --- serverboot/default_pager.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index ba305359..9b38abb5 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2580,8 +2580,6 @@ default_pager_demux_object(in, out) * the memory_object_default interface. */ - clearerr (stdout); - printf ("dpi object message %d\n", in->msgh_id); return (seqnos_memory_object_server(in, out) || seqnos_memory_object_default_server(in, out) || default_pager_notify_server(in, out)); @@ -2594,8 +2592,6 @@ default_pager_demux_default(in, out) mach_msg_header_t *in; mach_msg_header_t *out; { - clearerr (stdout); - printf ("dpi message %d\n", in->msgh_id); if (in->msgh_local_port == default_pager_default_port) { /* * We receive memory_object_create messages in @@ -2685,10 +2681,8 @@ default_pager_thread(arg) mach_port_t pset; kern_return_t kr; - printf ("dtp\n"); cthread_set_data(cthread_self(), (any_t) dpt); - printf ("dtp %#x\n", dpt); /* * Threads handling external objects cannot have @@ -2706,7 +2700,6 @@ default_pager_thread(arg) } for (;;) { - printf ("dtp %#x loop\n", dpt); kr = mach_msg_server(default_pager_demux_object, default_pager_msg_size_object, pset); @@ -2734,8 +2727,6 @@ start_default_pager_thread(internal) wire_memory(dpt->dpt_buffer, vm_page_size, VM_PROT_READ|VM_PROT_WRITE); - printf ("starting thread %d\n", internal); - dpt->dpt_thread = cthread_fork(default_pager_thread, (any_t) dpt); } @@ -2815,7 +2806,6 @@ default_pager() kern_return_t kr; int i; - printf ("dp1\n"); default_pager_thread_privileges(); /* @@ -2823,15 +2813,12 @@ default_pager() */ wire_all_memory(); - printf ("dp2\n"); /* * Initialize the list of all pagers. */ pager_port_list_init(); - printf ("dp3\n"); - kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_PORT_SET, &default_pager_internal_set); if (kr != KERN_SUCCESS) @@ -2865,8 +2852,6 @@ default_pager() if (kr != KERN_SUCCESS) panic(my_name); - printf ("dp4\n"); - /* * Now we create the threads that will actually * manage objects. @@ -2875,13 +2860,9 @@ default_pager() for (i = 0; i < default_pager_internal_count; i++) start_default_pager_thread(TRUE); - printf ("dp5\n"); - for (i = 0; i < default_pager_external_count; i++) start_default_pager_thread(FALSE); - printf ("dp6\n"); - cthread_fork (default_pager_default_thread, 0); cthread_exit (cthread_self ()); } -- cgit v1.2.3 From f176b7157c8f75b13ace3aecef1fab943bf9fcad Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 16 Apr 1997 20:09:23 +0000 Subject: Thu Apr 10 13:54:31 1997 Thomas Bushnell, n/BSG * dlabel.c: Don't include . (_IOR, _IOC, IOC_OUT, IOCPARM_MASK): New macros. --- ufs-utils/ChangeLog | 5 +++++ ufs-utils/dlabel.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 71d92548..656a25ec 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +Thu Apr 10 13:54:31 1997 Thomas Bushnell, n/BSG + + * dlabel.c: Don't include . + (_IOR, _IOC, IOC_OUT, IOCPARM_MASK): New macros. + Wed Feb 19 23:10:54 1997 Miles Bader * mkfs.c (argp_program_version): Make const. diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c index e3678310..a51fc8ec 100644 --- a/ufs-utils/dlabel.c +++ b/ufs-utils/dlabel.c @@ -23,9 +23,15 @@ #include #include #include -#include /* Ick */ #include #include + +/* XXX Ick. */ +#define IOCPARM_MASK 0x1fff/* parameter length, at most 13 bits */ +#define IOC_OUT 0x40000000/* copy out parameters */ +#define _IOC(inout,group,num,len) \ + (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) +#define _IOR(g,n,t) _IOC(IOC_OUT,(g), (n), sizeof(t)) static error_t fd_get_device (int fd, device_t *device) -- cgit v1.2.3 From d095d0f79c74ae0fc1ee5f63021bab7a79e235d7 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 18 Apr 1997 20:46:08 +0000 Subject: Fri Apr 18 16:44:49 1997 Thomas Bushnell, n/BSG * wiring.c (__vm_allocate): New function. Wed Apr 16 14:18:28 1997 Thomas Bushnell, n/BSG * default_pager.c (debug): Turn off. Mon Apr 14 12:50:20 1997 Thomas Bushnell, n/BSG * default_pager.c: Remove debugging printfs. Thu Apr 10 15:10:25 1997 Thomas Bushnell, n/BSG * Makefile (installationdir): Set variable. --- serverboot/ChangeLog | 16 ++++++++++++++++ serverboot/Makefile | 1 + serverboot/default_pager.c | 2 +- serverboot/wiring.c | 12 ++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index ccfccbe2..4a1a3611 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,19 @@ +Fri Apr 18 16:44:49 1997 Thomas Bushnell, n/BSG + + * wiring.c (__vm_allocate): New function. + +Wed Apr 16 14:18:28 1997 Thomas Bushnell, n/BSG + + * default_pager.c (debug): Turn off. + +Mon Apr 14 12:50:20 1997 Thomas Bushnell, n/BSG + + * default_pager.c: Remove debugging printfs. + +Thu Apr 10 15:10:25 1997 Thomas Bushnell, n/BSG + + * Makefile (installationdir): Set variable. + Wed Apr 9 13:57:44 1997 Thomas Bushnell, n/BSG * default_pager.c (default_pager_default_thread): New function. diff --git a/serverboot/Makefile b/serverboot/Makefile index 05a07d58..290671ea 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -30,6 +30,7 @@ LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.h \ disk_inode.h file_io.h minix_super.h translate_root.h target = serverboot HURDLIBS = threads +installationdir := $(prefix)/boot vpath boot_script.c $(srcdir)/../boot diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 9b38abb5..90cc4f6b 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -50,7 +50,7 @@ #include "file_io.h" -#define debug 1 +#define debug 0 extern void *kalloc(); diff --git a/serverboot/wiring.c b/serverboot/wiring.c index 550c1bec..993fbacc 100644 --- a/serverboot/wiring.c +++ b/serverboot/wiring.c @@ -138,3 +138,15 @@ vm_allocate(task, address, size, anywhere) VM_PROT_DEFAULT); return KERN_SUCCESS; } + +/* Other versions of this function in libc... */ +kern_return_t +__vm_allocate (task, address, size, anywhere) + task_t task; + vm_address_t *address; + vm_size_t size; + boolean_t anywhere; +{ + return vm_allcoate (task, address, size, anywhere); +} + -- cgit v1.2.3 From 2fbd92d4b9e7a6d26dee7da2b180b473029f5c0a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 18 Apr 1997 20:48:21 +0000 Subject: fix typo. --- serverboot/wiring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/wiring.c b/serverboot/wiring.c index 993fbacc..ddcbd373 100644 --- a/serverboot/wiring.c +++ b/serverboot/wiring.c @@ -147,6 +147,6 @@ __vm_allocate (task, address, size, anywhere) vm_size_t size; boolean_t anywhere; { - return vm_allcoate (task, address, size, anywhere); + return vm_allocate (task, address, size, anywhere); } -- cgit v1.2.3 From e34b180ab96587b999f26f0e8298fa2f24e5afa1 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 18 Apr 1997 21:07:16 +0000 Subject: add debugging. --- serverboot/default_pager.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 90cc4f6b..b562ab43 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2394,11 +2394,19 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, #endif lint if ((data_cnt % vm_page_size) != 0) + { + printf ("fail 1: %d %d\n", data_cnt, vm_page_size); panic(here,my_name); + } + ds = pager_port_lookup(pager); if (ds == DEFAULT_PAGER_NULL) + { + printf ("fail 2: %d %d\n", pager, ds); panic(here,my_name); + } + pager_port_lock(ds, seqno); pager_port_check_request(ds, pager_request); pager_port_start_write(ds); @@ -2428,8 +2436,13 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, } pager_port_finish_write(ds); - if (vm_deallocate(default_pager_self, addr, data_cnt) != KERN_SUCCESS) - panic(here,my_name); + result = vm_deallocate(default_pager_self, addr, data_cnt); + if (result != KERN_SUCCESS) + { + printf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, result) + panic(here,my_name); + } + return(KERN_SUCCESS); } -- cgit v1.2.3 From 6e021c0be78490eaaaf31a3155b0845c257e066c Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 18 Apr 1997 21:08:49 +0000 Subject: typo --- serverboot/default_pager.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index b562ab43..533fe2de 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2388,6 +2388,7 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, vm_size_t amount_sent; default_pager_t ds; static char here[] = "%sdata_write"; + int err #ifdef lint pager_request++; @@ -2436,10 +2437,11 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, } pager_port_finish_write(ds); - result = vm_deallocate(default_pager_self, addr, data_cnt); - if (result != KERN_SUCCESS) + err = vm_deallocate(default_pager_self, addr, data_cnt); + if (err != KERN_SUCCESS) { - printf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, result) + printf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, err); + panic(here,my_name); } -- cgit v1.2.3 From 9b303e01da12fd37bf030321fdebbd7ecec73db8 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 18 Apr 1997 21:09:49 +0000 Subject: *** empty log message *** --- serverboot/default_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 533fe2de..006751fc 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -2388,7 +2388,7 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, vm_size_t amount_sent; default_pager_t ds; static char here[] = "%sdata_write"; - int err + int err; #ifdef lint pager_request++; -- cgit v1.2.3 From be0d281e9ebe801263e777d0e1e036bf3025da9d Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 30 Apr 1997 18:18:01 +0000 Subject: *** empty log message *** --- serverboot/default_pager.c | 113 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 26 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 006751fc..832d4b5f 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -56,6 +56,12 @@ extern void *kalloc(); static char my_name[] = "(default pager):"; +static struct mutex printf_lock = MUTEX_INITIALIZER; + +#define dprintf(f, x...) \ + ({ mutex_lock (&printf_lock); printf (f , ##x); mutex_unlock (&printf_lock); }) +#define ddprintf(f, x...) ((void)0) + /* * parallel vs serial switch */ @@ -221,7 +227,7 @@ create_paging_partition(const char *name, mutex_unlock(&all_partitions.lock); #if 0 - printf("%s Added paging %s %s\n", my_name, + dprintf("%s Added paging %s %s\n", my_name, (isa_file) ? "file" : "device", name); #endif overcommitted(TRUE, part->free); @@ -249,6 +255,7 @@ choose_partition(size, cur_part) if (i == cur_part) continue; +dprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i); /* one that was removed ? */ if ((part = partition_of(i)) == 0) continue; @@ -291,6 +298,7 @@ pager_alloc_page(pindex, lock_it) if (no_partition(pindex)) return (NO_BLOCK); +dprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it); part = partition_of(pindex); /* unlikely, but possible deadlock against destroy_partition */ @@ -351,6 +359,7 @@ pager_dealloc_page(pindex, page, lock_it) /* be paranoid */ if (no_partition(pindex)) panic("%sdealloc_page",my_name); +dprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it); part = partition_of(pindex); if (page >= part->total_size) @@ -797,7 +806,7 @@ pager_read_offset(pager, offset) #endif if (f_page >= pager->size) { - printf ("%spager_read_offset pager %x: bad page %d >= size %d", + dprintf ("%spager_read_offset pager %x: bad page %d >= size %d", my_name, pager, f_page, pager->size); return (union dp_map *) NO_BLOCK; #if 0 @@ -890,6 +899,7 @@ pager_move_page(block) /* * Got the resources, now move the data */ +dprintf ("pager_move_page(%x,%d,%d)\n",block.block.p_offset,old_pindex,new_pindex); old_part = partition_of(old_pindex); offset = ptoa(block.block.p_offset); rc = page_read_file_direct (old_part->file, @@ -1140,8 +1150,8 @@ pager_write_offset(pager, offset) if ( ! no_partition(new_part) ) { #if debug -printf("%s partition %x filled,", my_name, pager->cur_partition); -printf("extending object %x (size %x) to %x.\n", +dprintf("%s partition %x filled,", my_name, pager->cur_partition); +dprintf("extending object %x (size %x) to %x.\n", pager, pager->size, new_part); #endif @@ -1332,6 +1342,7 @@ default_read(ds, addr, size, offset, out_addr, deallocate) * Read it, trying for the entire page. */ offset = ptoa(block.block.p_offset); +dprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); part = partition_of(block.block.p_index); first_time = TRUE; *out_addr = addr; @@ -1417,6 +1428,7 @@ default_write(ds, addr, size, offset) } #endif CHECKSUM offset = ptoa(block.block.p_offset); +dprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); part = partition_of(block.block.p_index); /* @@ -1431,8 +1443,8 @@ default_write(ds, addr, size, offset) size, &wsize); if (rc != 0) { - printf("*** PAGER ERROR: default_write: "); - printf("ds=0x%x addr=0x%x size=0x%x offset=0x%x resid=0x%x\n", + dprintf("*** PAGER ERROR: default_write: "); + dprintf("ds=0x%x addr=0x%x size=0x%x offset=0x%x resid=0x%x\n", ds, addr, size, offset, wsize); return (PAGER_ERROR); } @@ -1582,7 +1594,7 @@ destroy_paging_partition(name, pp_private) */ all_over_again: #if debug -printf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok); +dprintf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok); #endif all_ok = TRUE; mutex_lock(&part->p_lock); @@ -1627,7 +1639,7 @@ printf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok); *pp_private = part->file; kfree(part->bitmap, howmany(part->total_size, NB_BM) * sizeof(bm_entry_t)); kfree(part, sizeof(struct part)); - printf("%s Removed paging partition %s\n", my_name, name); + dprintf("%s Removed paging partition %s\n", my_name, name); return KERN_SUCCESS; } @@ -1665,10 +1677,14 @@ 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); } } @@ -1679,8 +1695,11 @@ 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); } /* @@ -1858,7 +1877,7 @@ default_pager_t pager_port_alloc(size) part = choose_partition(0,P_INDEX_INVALID); #if debug if (no_partition(part)) - printf("%s No paging space at all !!\n", my_name); + dprintf("%s No paging space at all !!\n", my_name); #endif } pager_alloc(&ds->dpager, part, size); @@ -2083,6 +2102,8 @@ seqnos_memory_object_terminate(pager, seqno, pager_request, pager_name) ds = pager_port_lookup(pager); if (ds == DEFAULT_PAGER_NULL) panic(here, my_name); +ddprintf ("seqnos_memory_object_terminate <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n", + &kr, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held, seqno); pager_port_lock(ds, seqno); /* @@ -2112,6 +2133,8 @@ seqnos_memory_object_terminate(pager, seqno, pager_request, pager_name) ds->pager_name = MACH_PORT_NULL; name_refs = ds->name_refs; ds->name_refs = 0; +ddprintf ("seqnos_memory_object_terminate <%p>: pager_port_unlock: <%p>[s:%d,r:%d,w:%d,l:%d]\n", + &kr, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held); pager_port_unlock(ds); /* @@ -2242,6 +2265,8 @@ seqnos_memory_object_data_request(pager, seqno, reply_to, offset, ds = pager_port_lookup(pager); if (ds == DEFAULT_PAGER_NULL) panic(here,my_name); +ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n", + &ds, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held, seqno); pager_port_lock(ds, seqno); pager_port_check_request(ds, reply_to); pager_port_wait_for_writers(ds); @@ -2252,10 +2277,12 @@ seqnos_memory_object_data_request(pager, seqno, reply_to, offset, */ errors = ds->errors; +ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_unlock: <%p>[s:%d,r:%d,w:%d,l:%d]\n", + &ds, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held); pager_port_unlock(ds); if (errors) { - printf("%s %s\n", my_name, + dprintf("%s %s\n", my_name, "dropping data_request because of previous paging errors"); (void) memory_object_data_error(reply_to, offset, vm_page_size, @@ -2337,9 +2364,13 @@ seqnos_memory_object_data_initialize(pager, seqno, pager_request, ds = pager_port_lookup(pager); if (ds == DEFAULT_PAGER_NULL) panic(here,my_name); +ddprintf ("seqnos_memory_object_data_initialize <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n", + &ds, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held, seqno); pager_port_lock(ds, seqno); pager_port_check_request(ds, pager_request); pager_port_start_write(ds); +ddprintf ("seqnos_memory_object_data_initialize <%p>: pager_port_unlock: <%p>[s:%d,r:%d,w:%d,l:%d]\n", + &ds, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held); pager_port_unlock(ds); for (amount_sent = 0; @@ -2352,7 +2383,7 @@ seqnos_memory_object_data_initialize(pager, seqno, pager_request, vm_page_size, offset + amount_sent) != PAGER_SUCCESS) { - printf("%s%s write error\n", my_name, here); + dprintf("%s%s write error\n", my_name, here); dstruct_lock(ds); ds->errors++; dstruct_unlock(ds); @@ -2394,39 +2425,54 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, pager_request++; #endif lint +dprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err); if ((data_cnt % vm_page_size) != 0) { - printf ("fail 1: %d %d\n", data_cnt, vm_page_size); + dprintf ("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) { - printf ("fail 2: %d %d\n", pager, ds); + dprintf ("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); pager_port_unlock(ds); +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 - printf("%s WRITE ERROR on default_pageout:", my_name); - printf(" pager=%x, offset=0x%x, length=0x%x, result=%d\n", + 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); @@ -2436,16 +2482,20 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, 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) { - printf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, err); + dprintf ("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); } @@ -2595,9 +2645,14 @@ default_pager_demux_object(in, out) * the memory_object_default interface. */ - return (seqnos_memory_object_server(in, out) || +int rval; +dprintf ("DPAGER DEMUX OBJECT <%p>: %d\n", in, in->msgh_id); +rval = + (seqnos_memory_object_server(in, out) || seqnos_memory_object_default_server(in, out) || default_pager_notify_server(in, out)); +dprintf ("DPAGER DEMUX OBJECT DONE <%p>: %d\n", in, in->msgh_id); +return rval; } mach_msg_size_t default_pager_msg_size_default = 8 * 1024; @@ -2613,8 +2668,13 @@ default_pager_demux_default(in, out) * the memory_object_default interface. */ - return (seqnos_memory_object_default_server(in, out) || +int rval; +dprintf ("DPAGER DEMUX DEFAULT <%p>: %d\n", in, in->msgh_id); +rval = + (seqnos_memory_object_default_server(in, out) || default_pager_server(in, out)); +dprintf ("DPAGER DEMUX DEFAULT DONE <%p>: %d\n", in, in->msgh_id); +return rval; } else if (in->msgh_local_port == default_pager_exception_port) { /* * We receive exception messages for @@ -2879,7 +2939,8 @@ default_pager() start_default_pager_thread(FALSE); cthread_fork (default_pager_default_thread, 0); - cthread_exit (cthread_self ()); + /* cthread_exit (cthread_self ()); */ + thread_suspend (mach_thread_self ()); } /* @@ -3308,7 +3369,7 @@ default_pager_paging_file(pager, mdport, file_name, add) return KERN_INVALID_ARGUMENT; #if 0 -printf("bmd %x md %x\n", bootstrap_master_device_port, mdport); +dprintf("bmd %x md %x\n", bootstrap_master_device_port, mdport); #endif if (add) { kr = add_paging_file(bootstrap_master_device_port, @@ -3346,7 +3407,7 @@ no_paging_space(out_of_memory) static char here[] = "%s *** NOT ENOUGH PAGING SPACE ***"; if (out_of_memory) - printf("*** OUT OF MEMORY *** "); + dprintf("*** OUT OF MEMORY *** "); panic(here, my_name); } @@ -3369,7 +3430,7 @@ overcommitted(got_more_space, space) if (pages_free > 0) { pages_shortage = 0; if (user_warned) - printf("%s paging space ok now.\n", my_name); + dprintf("%s paging space ok now.\n", my_name); } else pages_shortage = pages_free; user_warned = FALSE; @@ -3382,11 +3443,11 @@ overcommitted(got_more_space, space) pages_shortage = (pages_free > 0) ? 0 : -pages_free; if (!user_warned && pages_shortage) { user_warned = TRUE; - printf("%s paging space over-committed.\n", my_name); + dprintf("%s paging space over-committed.\n", my_name); } #if debug user_warned = FALSE; - printf("%s paging space over-committed [+%d (%d) pages].\n", + dprintf("%s paging space over-committed [+%d (%d) pages].\n", my_name, space, pages_shortage); #endif } @@ -3409,7 +3470,7 @@ paging_space_info(totp, freep) total += part->total_size; free += part->free; #if debug - printf("Partition %d: x%x total, x%x free\n", + dprintf("Partition %d: x%x total, x%x free\n", i, part->total_size, part->free); #endif } @@ -3427,7 +3488,7 @@ catch_exception_raise(exception_port, thread, task, exception, code, subcode) mach_port_t thread, task; int exception, code, subcode; { - printf("(default_pager)catch_exception_raise(%d,%d,%d)\n", + dprintf ("(default_pager)catch_exception_raise(%d,%d,%d)\n", exception, code, subcode); panic(my_name); -- cgit v1.2.3 From 5d7d623776489cae6685b931d3db51a8f11ef0a6 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 1 May 1997 22:43:37 +0000 Subject: Thu May 1 18:40:53 1997 Thomas Bushnell, n/BSG * bootstrap.c (cthread_stack_size): Don't set special value here; use the default. --- serverboot/ChangeLog | 5 +++++ serverboot/bootstrap.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 4a1a3611..2e5fff35 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +Thu May 1 18:40:53 1997 Thomas Bushnell, n/BSG + + * bootstrap.c (cthread_stack_size): Don't set special value here; + use the default. + Fri Apr 18 16:44:49 1997 Thomas Bushnell, n/BSG * wiring.c (__vm_allocate): New function. diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index b603a55f..49a8e00b 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -37,6 +37,7 @@ #include "../boot/boot_script.h" #include "translate_root.h" +#if 0 /* * Use 8 Kbyte stacks instead of the default 64K. * Use 4 Kbyte waiting stacks instead of the default 8K. @@ -46,6 +47,7 @@ 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; -- cgit v1.2.3 From bf2eafbaa0f9caad5d35498726ba78656a0468c1 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 2 May 1997 15:35:17 +0000 Subject: Turn off debugging printfs. --- serverboot/ChangeLog | 6 +++++ serverboot/default_pager.c | 64 +++++++++++++++++++++++++++++++--------------- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 2e5fff35..5fc390ca 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -3,6 +3,12 @@ Thu May 1 18:40:53 1997 Thomas Bushnell, n/BSG * bootstrap.c (cthread_stack_size): Don't set special value here; use the default. +Wed Apr 30 12:01:53 1997 Thomas Bushnell, n/BSG + + * default_pager.c (default_pager_default_thread): Now that this is + forked, rather than run directly by the first thread, we have to + gain kernel privileges to acquire reserved pages. + Fri Apr 18 16:44:49 1997 Thomas Bushnell, n/BSG * wiring.c (__vm_allocate): New function. diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 832d4b5f..302cf3f0 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -59,7 +59,7 @@ static char my_name[] = "(default pager):"; static struct mutex printf_lock = MUTEX_INITIALIZER; #define dprintf(f, x...) \ - ({ mutex_lock (&printf_lock); printf (f , ##x); mutex_unlock (&printf_lock); }) + ({ mutex_lock (&printf_lock); printf (f , ##x); fflush (stdout); mutex_unlock (&printf_lock); }) #define ddprintf(f, x...) ((void)0) /* @@ -255,7 +255,7 @@ choose_partition(size, cur_part) if (i == cur_part) continue; -dprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i); +ddprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i); /* one that was removed ? */ if ((part = partition_of(i)) == 0) continue; @@ -298,7 +298,7 @@ pager_alloc_page(pindex, lock_it) if (no_partition(pindex)) return (NO_BLOCK); -dprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it); +ddprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it); part = partition_of(pindex); /* unlikely, but possible deadlock against destroy_partition */ @@ -359,7 +359,7 @@ pager_dealloc_page(pindex, page, lock_it) /* be paranoid */ if (no_partition(pindex)) panic("%sdealloc_page",my_name); -dprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it); +ddprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it); part = partition_of(pindex); if (page >= part->total_size) @@ -689,6 +689,11 @@ pager_extend(pager, new_size) pager->writer = FALSE; #endif mutex_unlock(&pager->lock); + ddprintf ("pager_extend 1 mapptr %x [3b] = %x\n", new_mapptr, + new_mapptr[0x3b]); + if (new_mapptr[0x3b].indirect > 0x10000 + && new_mapptr[0x3b].indirect != NO_BLOCK) + panic ("debug panic"); return; } @@ -712,6 +717,12 @@ pager_extend(pager, new_size) kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); old_mapptr = new_mapptr; + ddprintf ("pager_extend 2 mapptr %x [3b] = %x\n", new_mapptr, + new_mapptr[0x3b]); + if (new_mapptr[0x3b].indirect > 0x10000 + && new_mapptr[0x3b].indirect != NO_BLOCK) + panic ("debug panic"); + /* * Now allocate indirect map. */ @@ -806,7 +817,7 @@ pager_read_offset(pager, offset) #endif if (f_page >= pager->size) { - dprintf ("%spager_read_offset pager %x: bad page %d >= size %d", + ddprintf ("%spager_read_offset pager %x: bad page %d >= size %d", my_name, pager, f_page, pager->size); return (union dp_map *) NO_BLOCK; #if 0 @@ -899,7 +910,7 @@ pager_move_page(block) /* * Got the resources, now move the data */ -dprintf ("pager_move_page(%x,%d,%d)\n",block.block.p_offset,old_pindex,new_pindex); +ddprintf ("pager_move_page(%x,%d,%d)\n",block.block.p_offset,old_pindex,new_pindex); old_part = partition_of(old_pindex); offset = ptoa(block.block.p_offset); rc = page_read_file_direct (old_part->file, @@ -1070,6 +1081,8 @@ pager_write_offset(pager, offset) } while (f_page >= pager->size) { + ddprintf ("pager_write_offset: extending: %x %x\n", f_page, pager->size); + /* * Paging object must be extended. * Remember that offset is 0-based, but size is 1-based. @@ -1088,16 +1101,18 @@ pager_write_offset(pager, offset) #if DEBUG_READER_CONFLICTS pager->readers++; #endif + ddprintf ("pager_write_offset: done extending: %x %x\n", f_page, pager->size); } if (INDIRECT_PAGEMAP(pager->size)) { - + ddprintf ("pager_write_offset: indirect\n"); mapptr = pager->map[f_page/PAGEMAP_ENTRIES].indirect; if (mapptr == 0) { /* * Allocate the indirect block */ register int i; + ddprintf ("pager_write_offset: allocating indirect\n"); mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES)); if (mapptr == 0) { @@ -1134,6 +1149,7 @@ pager_write_offset(pager, offset) } block = mapptr[f_page]; + ddprintf ("pager_write_offset: block starts as %x[%x] %x\n", mapptr, f_page, block); if (no_block(block)) { vm_offset_t off; @@ -1145,6 +1161,7 @@ pager_write_offset(pager, offset) */ p_index_t new_part; + ddprintf ("pager_write_offset: could not allocate block\n"); /* returns it locked (if any one is non-full) */ new_part = choose_partition( ptoa(1), pager->cur_partition); if ( ! no_partition(new_part) ) { @@ -1170,12 +1187,16 @@ dprintf("extending object %x (size %x) to %x.\n", overcommitted(FALSE, 1); goto out; } + ddprintf ("pager_write_offset: decided to allocate block\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: #if DEBUG_READER_CONFLICTS @@ -1342,7 +1363,7 @@ default_read(ds, addr, size, offset, out_addr, deallocate) * Read it, trying for the entire page. */ offset = ptoa(block.block.p_offset); -dprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); +ddprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); part = partition_of(block.block.p_index); first_time = TRUE; *out_addr = addr; @@ -1409,6 +1430,8 @@ default_write(ds, addr, size, offset) vm_size_t wsize; register int rc; + ddprintf ("default_write: pager offset %x\n", offset); + /* * Find block in paging partition */ @@ -1428,7 +1451,7 @@ default_write(ds, addr, size, offset) } #endif CHECKSUM offset = ptoa(block.block.p_offset); -dprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); +ddprintf ("default_write(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); part = partition_of(block.block.p_index); /* @@ -2425,10 +2448,10 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, pager_request++; #endif lint -dprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err); +ddprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err); if ((data_cnt % vm_page_size) != 0) { - dprintf ("fail 1: %d %d\n", data_cnt, vm_page_size); + ddprintf ("fail 1: %d %d\n", data_cnt, vm_page_size); panic(here,my_name); } @@ -2438,7 +2461,7 @@ ddprintf ("seqnos_memory_object_data_write <%p>: 2\n", &err); ddprintf ("seqnos_memory_object_data_write <%p>: 3\n", &err); if (ds == DEFAULT_PAGER_NULL) { - dprintf ("fail 2: %d %d\n", pager, ds); + ddprintf ("fail 2: %d %d\n", pager, ds); panic(here,my_name); } @@ -2489,7 +2512,7 @@ ddprintf ("seqnos_memory_object_data_write <%p>: 13\n", &err); ddprintf ("seqnos_memory_object_data_write <%p>: 14\n", &err); if (err != KERN_SUCCESS) { - dprintf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, &err); + ddprintf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, &err); panic(here,my_name); } @@ -2646,12 +2669,12 @@ default_pager_demux_object(in, out) */ int rval; -dprintf ("DPAGER DEMUX OBJECT <%p>: %d\n", in, in->msgh_id); +ddprintf ("DPAGER DEMUX OBJECT <%p>: %d\n", in, in->msgh_id); rval = (seqnos_memory_object_server(in, out) || seqnos_memory_object_default_server(in, out) || default_pager_notify_server(in, out)); -dprintf ("DPAGER DEMUX OBJECT DONE <%p>: %d\n", in, in->msgh_id); +ddprintf ("DPAGER DEMUX OBJECT DONE <%p>: %d\n", in, in->msgh_id); return rval; } @@ -2669,11 +2692,11 @@ default_pager_demux_default(in, out) */ int rval; -dprintf ("DPAGER DEMUX DEFAULT <%p>: %d\n", in, in->msgh_id); +ddprintf ("DPAGER DEMUX DEFAULT <%p>: %d\n", in, in->msgh_id); rval = (seqnos_memory_object_default_server(in, out) || default_pager_server(in, out)); -dprintf ("DPAGER DEMUX DEFAULT DONE <%p>: %d\n", in, in->msgh_id); +ddprintf ("DPAGER DEMUX DEFAULT DONE <%p>: %d\n", in, in->msgh_id); return rval; } else if (in->msgh_local_port == default_pager_exception_port) { /* @@ -2738,7 +2761,8 @@ default_pager_default_thread (arg) any_t arg; { kern_return_t kr; - for (;;) { + default_pager_thread_privileges (); + for (;;) { kr = mach_msg_server(default_pager_demux_default, default_pager_msg_size_default, default_pager_default_set); @@ -3488,7 +3512,7 @@ catch_exception_raise(exception_port, thread, task, exception, code, subcode) mach_port_t thread, task; int exception, code, subcode; { - dprintf ("(default_pager)catch_exception_raise(%d,%d,%d)\n", + ddprintf ("(default_pager)catch_exception_raise(%d,%d,%d)\n", exception, code, subcode); panic(my_name); -- cgit v1.2.3 From d8519e3ee38bd699a82be31a18cce0cb2eab64ca Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 23 May 1997 16:39:25 +0000 Subject: Fri May 23 10:06:34 1997 Thomas Bushnell, n/BSG * configure.in: Use AC_PROG_CC_LOCAL instead of AC_PROG_CC. * aclocal.m4: New file. * Makefile (DIST_FILES): Add aclocal.m4. (Patch from Marcus G. Daniels, marcus@cathcart.sysc.pdx.edu). --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 6afafb12..8f55c4c1 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.10 1996/09/25 01:49:10 miles Exp $]) +AC_REVISION([$Id: configure.in,v 1.11 1997/05/23 16:39:25 thomas Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -24,7 +24,7 @@ AC_PROG_INSTALL AC_CHECK_TOOL(CC, gcc) # That check handles cross-compilation well, but AC_PROG_CC tests for GCC # and sets default CFLAGS nicely for us, so do that too. -AC_PROG_CC +AC_PROG_CC_LOCAL # Require GCC. if test x$GCC != xyes; then AC_MSG_ERROR([this code uses GNU C extensions, you must compile with GCC]) -- cgit v1.2.3 From 076c20cd94c74b6d6076db51ed304ab32df4cf18 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 9 Jun 1997 18:56:35 +0000 Subject: (LCLHDRS): Add mach-exec.h. --- serverboot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/Makefile b/serverboot/Makefile index 290671ea..bb5553fa 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -27,7 +27,7 @@ OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ memory_object_defaultServer.o LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.h \ minix_ffs_compat.h wiring.h dir.h ffs_compat.h minix_fs.h \ - disk_inode.h file_io.h minix_super.h translate_root.h + disk_inode.h file_io.h minix_super.h translate_root.h mach-exec.h target = serverboot HURDLIBS = threads installationdir := $(prefix)/boot -- cgit v1.2.3 From 749d13762145d78d698adb905928435e7d5e7d25 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 9 Jun 1997 19:22:30 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 5fc390ca..0ddcae91 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +1997-06-09 Miles Bader + + * Makefile (LCLHDRS): Add mach-exec.h. + Thu May 1 18:40:53 1997 Thomas Bushnell, n/BSG * bootstrap.c (cthread_stack_size): Don't set special value here; -- cgit v1.2.3 From b42b96ba1715d1eeb5c9b7ebb35e0e652cb320ed Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 10 Jun 1997 00:48:24 +0000 Subject: Mon Jun 9 12:27:40 1997 Thomas Bushnell, n/BSG * version.h (HURD_VERSION): Update version number. * sh-version.sed: Likewise. * README: Likewise. * INSTALL: Likewise. --- sh-version.sed | 2 +- version.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh-version.sed b/sh-version.sed index 226cdaf4..d13c94d0 100644 --- a/sh-version.sed +++ b/sh-version.sed @@ -1 +1 @@ -s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 (GNU Hurd) 0.1/ +s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 (GNU Hurd) 0.2/ diff --git a/version.h b/version.h index c61c275e..ab6c5b2b 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ /* Hurd version - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. Written by Thomas Bushnell, n/BSG. This file is part of the GNU Hurd. @@ -21,7 +21,7 @@ /* See sh-version.sed for duplicates of this information. */ #ifndef HURD_VERSION -#define HURD_VERSION "0.1" +#define HURD_VERSION "0.2" #endif /* The standard way to print versions for --version. */ -- cgit v1.2.3 From 9a31fe78f3dff8b24c72a9e9a273bbaa6fedb0e4 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 10 Jun 1997 15:22:45 +0000 Subject: MAKEDEV now lives in /sbin, so get it from there. --- SETUP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP b/SETUP index 13101df8..62651e3b 100644 --- a/SETUP +++ b/SETUP @@ -8,4 +8,4 @@ set -v # Setup crucial devices cd /dev -/bin/sh ./MAKEDEV std +/bin/sh /sbin/MAKEDEV std -- cgit v1.2.3 From ecd15a793488433b22f1108670600541bbbdd100 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 10 Jun 1997 17:37:55 +0000 Subject: The real version is release/SETUP --- SETUP | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 SETUP diff --git a/SETUP b/SETUP deleted file mode 100644 index 62651e3b..00000000 --- a/SETUP +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Setup critical hurd translators - -set -v - -# Set up the PFLOCAL server so we can do pipes -/bin/settrans -c /servers/socket/1 /hurd/pflocal - -# Setup crucial devices -cd /dev -/bin/sh /sbin/MAKEDEV std -- cgit v1.2.3 From fa154160ea6ea5de6bc767f5ce191157edf93e0a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 11 Jun 1997 15:35:33 +0000 Subject: Tue Jun 10 21:54:52 1997 Thomas Bushnell, n/BSG * disk_inode.h (struct icommon): Use short instead of uid_t/gid_t in structure definition; those are now 32 bit types. * bootstrap.c (main): Support running from command line too; this is useful at least for simple debugging. --- serverboot/ChangeLog | 8 +++++++ serverboot/bootstrap.c | 56 +++++++++++++++++++++++++++++-------------------- serverboot/disk_inode.h | 4 ++-- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 0ddcae91..79b9c123 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,11 @@ +Tue Jun 10 21:54:52 1997 Thomas Bushnell, n/BSG + + * disk_inode.h (struct icommon): Use short instead of uid_t/gid_t + in structure definition; those are now 32 bit types. + + * bootstrap.c (main): Support running from command line too; this + is useful at least for simple debugging. + 1997-06-09 Miles Bader * Makefile (LCLHDRS): Add mach-exec.h. diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 49a8e00b..d238e8bb 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -171,38 +171,48 @@ main(argc, argv) */ cthread_wait_stack_size = 4 * 1024; - /* - * Parse the arguments. - */ - if (argc < 5) - panic("bootstrap: not enough arguments"); - - /* - * Arg 0 is program name - */ - /* * Arg 1 is flags */ if (argv[1][0] != '-') - panic("bootstrap: no flags"); - + panic("bootstrap: no flags"); + flag_string = argv[1]; - + /* - * Arg 2 is host port number + * Parse the arguments. */ - bootstrap_master_host_port = atoi(argv[2]); + if (argc >= 5) + { + /* + * Arg 0 is program name + */ - /* - * Arg 3 is device port number - */ - bootstrap_master_device_port = atoi(argv[3]); + /* + * Arg 2 is host port number + */ + bootstrap_master_host_port = atoi(argv[2]); - /* - * Arg 4 is root name - */ - root_name = argv[4]; + /* + * 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 diff --git a/serverboot/disk_inode.h b/serverboot/disk_inode.h index e0f49ea3..6eed9104 100644 --- a/serverboot/disk_inode.h +++ b/serverboot/disk_inode.h @@ -61,8 +61,8 @@ struct icommon { u_short ic_mode; /* 0: mode and type of file */ short ic_nlink; /* 2: number of links to file */ - uid_t ic_uid; /* 4: owner's user id */ - gid_t ic_gid; /* 6: owner's group id */ + 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; -- cgit v1.2.3 From 0c7263cd36e2336c2a13e8c04c37c0e267b079b1 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 17 Jun 1997 04:05:45 +0000 Subject: Replaced by storeio. --- devio/ChangeLog | 270 ------------------------------- devio/MAKEDEV | 80 ---------- devio/Makefile | 30 ---- devio/dev.c | 227 --------------------------- devio/dev.h | 147 ----------------- devio/devio.c | 359 ------------------------------------------ devio/devpager.c | 257 ------------------------------ devio/io.c | 396 ---------------------------------------------- devio/iostate.c | 79 ---------- devio/iostate.h | 67 -------- devio/mem.c | 57 ------- devio/mem.h | 33 ---- devio/open.c | 90 ----------- devio/open.h | 73 --------- devio/ptypes.h | 23 --- devio/rdwr.c | 471 ------------------------------------------------------- devio/window.c | 171 -------------------- devio/window.h | 84 ---------- 18 files changed, 2914 deletions(-) delete mode 100644 devio/ChangeLog delete mode 100644 devio/MAKEDEV delete mode 100644 devio/Makefile delete mode 100644 devio/dev.c delete mode 100644 devio/dev.h delete mode 100644 devio/devio.c delete mode 100644 devio/devpager.c delete mode 100644 devio/io.c delete mode 100644 devio/iostate.c delete mode 100644 devio/iostate.h delete mode 100644 devio/mem.c delete mode 100644 devio/mem.h delete mode 100644 devio/open.c delete mode 100644 devio/open.h delete mode 100644 devio/ptypes.h delete mode 100644 devio/rdwr.c delete mode 100644 devio/window.c delete mode 100644 devio/window.h diff --git a/devio/ChangeLog b/devio/ChangeLog deleted file mode 100644 index 07f59609..00000000 --- a/devio/ChangeLog +++ /dev/null @@ -1,270 +0,0 @@ -Sun Sep 8 18:10:57 1996 Miles Bader - - * Makefile (DIST_FILES): Variable removed. - (install, $(prefix)/dev/MAKEDEV): Targets removed. - -Fri Jul 19 15:55:27 1996 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Return correct values for - NUM_RUNS and NUM_OFFSETS. - -Thu Jul 18 18:33:49 1996 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Fill in the array-length - return values. - - * MAKEDEV: Add "com[0-9]". - -Wed Jul 17 10:00:04 1996 Miles Bader - - * MAKEDEV (st): New function. - Use new st function (get rid of chmods). - Accept disk device names without partitions, & with slice + partition. - -Sat Jun 15 14:13:24 1996 Michael I. Bushnell, p/BSG - - * MAKEDEV ([hrs]d*): Allow user to specify slice as well. Patch - from Gord Matzigkeit, gord@enci.ucalgary.ca. - -Thu May 9 12:15:47 1996 Miles Bader - - * io.c (trivfs_S_io_select): Remove TAG arg. - (trivfs_S_file_get_storage_info): Fix param type. - -Tue May 7 16:41:48 1996 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Swap PORTS_TYPE & NUM_PORTS. - -Mon May 6 20:14:43 1996 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Enable new version. - -Fri May 3 15:09:00 1996 Miles Bader - - * io.c [0] (trivfs_S_file_get_storage_info): Rewrite for new interface. - -Tue Apr 30 10:03:50 1996 Michael I. Bushnell, p/BSG - - * Makefile (include ../Makeconf): BEFORE dependencies. - ($(prefix)/dev/MAKEDEV): Find MAKEDEV in $(srcdir). - -Fri Feb 16 19:28:32 1996 Miles Bader - - * MAKEDEV: Add rule for `time', and add `time' to std. - -Tue Jan 30 12:34:28 1996 Roland McGrath - - * MAKEDEV: Grok `tty'. - -Thu Jan 25 18:10:24 1996 Miles Bader - - * devio.c (trivfs_goaway): Handle errors from ports_inhibit_class_rpcs. - Allow rpcs to resume if we're going to return EBUSY. - -Tue Jan 16 16:19:51 1996 Miles Bader - - * devio.c (trivfs_modify_stat): The peropen hook holds a struct - open, not a struct dev. - -Fri Dec 29 23:41:39 1995 Miles Bader - - * MAKEDEV (std): Make `fd' one of the standard devices. - -Fri Dec 15 13:30:33 1995 Miles Bader - - * MAKEDEV (ST): Variable holding the proper settrans command, - which use. - (_CWD): Use this variable to pass down the current directory to - sub MAKEDEVS. - (console): Use the new term syntax. - (tty[0-9]?|tty[0-9a-f]): New rule for normal ttys. - ([pt]ty[pqPQ]?): New rule for ptys (both master and slave). - ([pt]ty[pqPQ]): New rule for making sets of ptys. - -Mon Dec 4 15:17:14 1995 Miles Bader - - * io.c (trivfs_S_file_set_size, trivfs_S_file_sync, - trivfs_S_file_syncfs, trivfs_S_file_get_storage_info): Add totally - gratuitous, annoying, and trouble-making reply-port args. - - * io.c (trivfs_S_file_get_storage_info): Use inline return if possible. - -Wed Nov 8 16:44:05 1995 Miles Bader - - * io.c (trivfs_S_file_set_size): Renamed from trivfs_S_file_truncate. - -Sun Nov 5 10:00:56 1995 Miles Bader - - * devio.c (main): Add FLAGS arg to trivfs_startup call. - -Sat Nov 4 20:03:05 1995 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Add FLAGS argument. - -Fri Oct 6 17:25:37 1995 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): Change type of ADDRESSES - to off_t **, and add BLOCK_SIZE parameter. - -Sun Oct 1 16:20:45 1995 Miles Bader - - * devio.c (main, trivfs_S_fsys_syncfs): Get rid of debugging noise. - * rdwr.c (open_write, open_read): Ditto. - * dev.c (dev_open, dev_sync, dev_write, dev_read): Ditto. - * io.c (trivfs_S_file_syncfs, trivfs_S_file_sync): Ditto. - * devpager.c (pager_write_page, pager_read_page): Ditto. - * window.c (position): Ditto. - -Tue Sep 26 15:33:14 1995 Miles Bader - - * io.c (trivfs_S_file_get_storage_info): New function. - * dev.c (dev_open): Record NAME in the returned dev structure. - * dev.h (struct dev): Add the NAME field. - -Thu Aug 24 10:28:00 1995 Miles Bader - - * Makefile (devio): Put all dependencies here. - (HURDLIBS): Removed. - -Tue Aug 22 10:45:31 1995 Miles Bader - - * Makefile (HURDLIBS): Add libshouldbeinlibc. - (OBJS): Get rid of error.o. - Get rid of rules dealing with error.o. - ($(prefix)/dev/MAKEDEV): Use $(INSTALL_PROGRAM) instead of - $(INSTALL_DATA) + `chmod +x'. - - * devio.c (trivfs_modify_stat): Get the device from CRED now that - we have it. - -Mon Aug 21 16:34:29 1995 Miles Bader - - * devio.c (trivfs_goaway, trivfs_modify_stat): Update arguments. - -Tue Aug 15 19:47:57 1995 Roland McGrath - - * MAKEDEV ([hrs]d*): Fixed partition parsing: use glob pattern, - not regexp. - -Sun Aug 13 10:57:03 1995 Miles Bader - - * devio.c (trivfs_peropen_create_hook): This now returns an error_t. - (open_hook): And thus this does as well. - -Sat Jul 22 18:32:03 1995 Miles Bader - - * rdwr.c (open_read, open_write): Clean up STATE before returning - with an error. - * devpager.c (dev_get_memory_object): A new pager now comes with 1 - ref, so we allocate a ref ourselves when we're using an old one, - and once we've created the send right, remove a reference. - -Mon Jul 10 15:15:45 1995 Miles Bader - - * rdwr.c (open_seek): New function. - (raw_read, raw_write): Return EINVAL if *OFFS isn't a block boundary. - * open.h: Add declaration for open_seek. - * io.c (trivfs_S_io_seek): Call open_seek instead of doing ourselves. - -Sat Jul 8 18:35:17 1995 Miles Bader - - * MAKEDEV (fd): Put the fd server on `fd', not `stdin'. - * MAKEDEV (console): Give /hurd/term a ttyname argument. - -Thu Jul 6 15:33:33 1995 Miles Bader - - * Makefile: Remove include dependencies. - -Wed Jun 28 19:22:47 1995 Miles Bader - - * Makefile (HURDLIBS): Add libihash. - - * iostate.c (io_state_sync): Remember that we've synced the buffer. - * devpager.c (dev_stop_paging): New function. - (pager_dropweak): New function. - * dev.h (struct dev): Add the pager_port_bucket field. - Declare dev_stop_paging (). - * devio.c (trivfs_goaway): Make trivfs_goaway do the right thing. - (clean_exit, close_device): Deleted functions. - (thread_cancel): New function. - - * devpager.c (pager_port_type): Deleted var. - (pager_port_bucket, pager_port_class): New vars. - (dev_get_memory_object): Moved here from dev.c. Also, call - init_dev_pager if necessary. - (service_paging_requests): New function. - (init_dev_pager): New function. - * dev.c (dev_get_memory_object): Moved function to devpager.c. - - * devio.c (fsys_port_class, root_port_class, port_bucket): New vars. - (trivfs_protid_portclasses, trivfs_cntl_portclasses, - trivfs_protid_nportclasses, trivfs_cntl_nportclasses): New vars. - (main): Initialize *portclasses vars, and convert to new trivfs lib. - (trivfs_protid_porttypes, trivfs_cntl_porttypes, - trivfs_protid_nporttypes, trivfs_cntl_nporttypes): Deleted vars. - (trivfs_goaway): Convert args for new trivfs lib. - (ports_cleanroutines): Delete var. - (ports_demuxer, ports_notice_idle, ports_no_live_ports, - ports_no_hard_ports): Delete functions. - * ptypes.h: Deleted file. - -Wed Jun 28 15:51:51 1995 Michael I Bushnell - - * Makefile: Repair mangled include-file dependencies. - -Fri Apr 21 14:17:19 1995 Roland McGrath - - * MAKEDEV: Split out `std' into individual device-makers it calls. - Rewrote /dev/fd stuff (still commented out). Use case built-in - instead of expr program. - -Tue Apr 11 15:46:35 1995 Michael I Bushnell - - * Makefile (DIST_FILES): New var, for MAKEDEV. - (install): Depend on $(prefix)/dev/MAKEDEV. - ($(prefix)/dev/MAKEDEV): New target. - * MAKEDEV: New file. - -Mon Apr 10 10:22:26 1995 Miles Bader - - * rdwr.c (open_write, open_read): Bounds check I/O. - - * io.c (trivfs_S_file_truncate): Always return 0, so O_TRUNC works. - - * devio.c (main, check_open_hook, close_device, trivfs_goaway): - Add a new lock, device_lock, and use it to control access to the - DEVICE variable. - (open_hook, trivfs_modify_stat, trivfs_S_fys_syncfs): Copy DEVICE - before using it, so it doesn't change underneath us. - - * devio.c (clean_exit): Add a new argument that says whether to - aquire a lock before doing our work. - (ports_notice_idle, ports_no_live_ports): Use it. - - * devio.c (close_device): New function, closes DEVICE cleanly. - (clean_exit, ports_no_hard_ports): Use close_device. - - * devio.c (main): Use trivfs_startup instead of doing it manually. - - * devio.c (trivfs_goaway): Try and do it better, paying attention - to flags, etc.; this still isn't right though, we may want to wait - for the ports library to be fixed first. - - * devio.c (DEBUG): New macro, executes its arg with debug_lock locked. - (most everything): use DEBUG instead of doing things manually. - - * open.c (open_create): Supply our dev's size when creating a window. - -Sun Apr 9 14:49:33 1995 Miles Bader - - * window.h: Add a new window field, max_pos. Rename the location - field `pos'. - * window.c (position): Use a shorter than normal window if - necessary to avoid going past the end of the device. - (window_create): Initialize the new MAX_POS field. - (window_create, position, window_write, window_read): Rename the - location field `pos'. - - * devpager.c (pager_read_page, pager_write_page): Read or write - partial pages at the end of the device. - diff --git a/devio/MAKEDEV b/devio/MAKEDEV deleted file mode 100644 index 7d13fe3b..00000000 --- a/devio/MAKEDEV +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# -# Make standard devices -# - -PATH=/bin - -function st { - NODE="$1" - OWNER="$2" - PERM="$3" - shift 3 - settrans -cg "$NODE" - chown "$OWNER" "$NODE" - chmod "$PERM" "$NODE" - settrans "$NODE" "$@" -} - -_CWD=${_CWD:-`pwd`} -export _CWD - -for I; do - case "$I" in - std) - $0 console tty null zero fd time - ;; - console|tty[0-9][0-9a-f]|tty[0-9a-f]|com[0-9]) - st $I root 600 /hurd/term $_CWD/$I device $I;; - null) - st $I root 666 /hurd/null;; - zero) - st $I root 666 /hurd/null -z;; - tty) - st $I root 666 /hurd/magic tty;; - fd) - st $I root 666 /hurd/magic fd - ln -f -s fd/0 stdin - ln -f -s fd/1 stdout - ln -f -s fd/2 stderr - ;; - time) - st $I root 666 /hurd/devport time ;; - - # ptys - [pt]ty[pqPQ]?) - # Make one pty, both the master and slave halves - ID="`expr substr $I 4 99`" - st pty$ID root 640 /hurd/term $_CWD/pty$ID pty-master $_CWD/tty$ID - st tty$ID root 640 /hurd/term $_CWD/tty$ID pty-slave $_CWD/pty$ID - ;; - [pt]ty[pqPQ]) - # Make a bunch of ptys - $0 ${I}0 ${I}1 ${I}2 ${I}3 ${I}4 ${I}5 ${I}6 ${I}7 - $0 ${I}8 ${I}9 ${I}a ${I}b ${I}c ${I}d ${I}e ${I}f - ;; - - fd*|mt*) - st r$I root 640 /hurd/devio $I - st $I root 640 /hurd/devio -b $I - ;; - - [hrs]d*) - case "$I" in - [a-z][a-z][0-9][a-z] | [a-z][a-z][0-9]s[1-9] | [a-z][a-z][0-9]s[1-9][a-z] | [a-z][a-z][0-9]) - st r$I root 640 /hurd/devio $I - st $I root 640 /hurd/devio -b $I - ;; - *) - echo 1>&2 $0: $I: Illegal device name: must supply a device number - exit 1 - ;; - esac - ;; - - *) - echo >&2 $0: $I: Unknown device - exit 1 - ;; - esac -done diff --git a/devio/Makefile b/devio/Makefile deleted file mode 100644 index 1dda469d..00000000 --- a/devio/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Makefile for devio -# -# Copyright (C) 1995, 1996 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 -# published by the Free Software Foundation; either version 2, 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. - -dir := devio -makemode := server - -target = devio -SRCS = dev.c iostate.c window.c devio.c open.c devpager.c io.c rdwr.c mem.c -LCLHDRS = dev.h iostate.h window.h open.h ptypes.h mem.h - -OBJS = $(SRCS:.c=.o) - -include ../Makeconf - -devio: $(OBJS) ../libtrivfs/libtrivfs.a ../libpager/libpager.a ../libports/libports.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libihash/libihash.a ../libshouldbeinlibc/libshouldbeinlibc.a diff --git a/devio/dev.c b/devio/dev.c deleted file mode 100644 index 4d3b89cb..00000000 --- a/devio/dev.c +++ /dev/null @@ -1,227 +0,0 @@ -/* Mach devices. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include -#include -#include - -#include "dev.h" -#include "iostate.h" - -/* ---------------------------------------------------------------- */ - -/* Returns a pointer to a new device structure in DEV for the kernel device - NAME, with the given FLAGS. If BLOCK_SIZE is non-zero, it should be the - desired block size, and must be a multiple of the device block size. - If an error occurs, the error code is returned, otherwise 0. */ -error_t -dev_open(char *name, int flags, int block_size, struct dev **dev) -{ - error_t err = 0; - static mach_port_t device_master = MACH_PORT_NULL; - - *dev = malloc(sizeof (struct dev)); - - if (!(flags & DEV_SERIAL)) - flags |= DEV_SEEKABLE; - - if (*dev == NULL) - return ENOMEM; - - (*dev)->name = malloc (strlen (name) + 1); - if ((*dev)->name) - strcpy ((*dev)->name, name); - else - err = ENOMEM; - - (*dev)->port = MACH_PORT_NULL; - - if (!err && device_master == MACH_PORT_NULL) - err = get_privileged_ports(NULL, &device_master); - - if (!err) - err = device_open(device_master, - D_READ | (flags & DEV_READONLY ? D_WRITE : 0), - name, &(*dev)->port); - - if (!err) - { - int count = DEV_GET_SIZE_COUNT; - int sizes[DEV_GET_SIZE_COUNT]; - - /* Get info about the device: total size (in bytes) and block size (in - bytes). Block size is unit in which device addressing is done. */ - err = device_get_status((*dev)->port, DEV_GET_SIZE, sizes, &count); - if (!err) - { - (*dev)->size = sizes[DEV_GET_SIZE_DEVICE_SIZE]; - (*dev)->dev_block_size = sizes[DEV_GET_SIZE_RECORD_SIZE]; - } - } - - if (!err) - { - if (block_size > 0) - if (block_size > (*dev)->dev_block_size - && block_size % (*dev)->dev_block_size == 0) - (*dev)->block_size = block_size; - else - err = EINVAL; - else - (*dev)->block_size = (*dev)->dev_block_size; - - if ((*dev)->dev_block_size == 1) - flags |= DEV_SERIAL; - - (*dev)->flags = flags; - (*dev)->owner = 0; - } - - if (!err) - err = io_state_init(&(*dev)->io_state, *dev); - - if (err) - { - if ((*dev)->port != MACH_PORT_NULL) - mach_port_deallocate(mach_task_self(), (*dev)->port); - free(*dev); - } - - return err; -} - -/* Free DEV and any resources it consumes. */ -void -dev_close(struct dev *dev) -{ - if (!dev_is(dev, DEV_READONLY)) - { - if (dev->pager != NULL) - pager_shutdown(dev->pager); - io_state_sync(&dev->io_state, dev); - } - - device_close(dev->port); - io_state_finalize(&dev->io_state); - - free(dev); -} - -/* ---------------------------------------------------------------- */ - -/* Try and write out any pending writes to DEV. If WAIT is true, will wait - for any paging activity to cease. */ -error_t -dev_sync(struct dev *dev, int wait) -{ - error_t err = 0; - - if (!dev_is(dev, DEV_READONLY)) - { - struct io_state *ios = &dev->io_state; - - io_state_lock(ios); - - /* Sync any paged backing store. */ - if (dev->pager != NULL) - pager_sync(dev->pager, wait); - - /* Write out any stuff buffered in our io_state. */ - err = io_state_sync(ios, dev); - - io_state_unlock(ios); - } - - return err; -} - -/* ---------------------------------------------------------------- */ - -/* Writes AMOUNT bytes from the buffer pointed to by BUF to the device DEV. - *OFFS is incremented to reflect the amount read/written. Both AMOUNT and - *OFFS must be multiples of DEV's block size, and either BUF must be - page-aligned, or dev_write_valid() must return true for these arguments. - If an error occurs, the error code is returned, otherwise 0. */ -error_t -dev_write(struct dev *dev, - vm_address_t buf, vm_size_t amount, vm_offset_t *offs) -{ - int bsize = dev->dev_block_size; - vm_offset_t written = 0; - vm_offset_t block = (bsize == 1 ? *offs : *offs / bsize); - error_t err; - - assert(dev_write_valid(dev, buf, amount, *offs)); - assert(*offs % bsize == 0); - assert(amount % bsize == 0); - - if (amount < IO_INBAND_MAX) - err = - device_write_inband (dev->port, 0, block, - (io_buf_ptr_t)buf, amount, &written); - else - err = - device_write (dev->port, 0, block, (io_buf_ptr_t)buf, amount, &written); - - if (!err) - *offs += written; - - return err; -} - -/* Reads AMOUNT bytes from DEV and returns it in BUF and BUF_LEN (using the - standard mach out-array convention). *OFFS is incremented to reflect the - amount read/written. Both LEN and *OFFS must be multiples of DEV's block - size. If an error occurs, the error code is returned, otherwise 0. */ -error_t -dev_read(struct dev *dev, - vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, - vm_offset_t *offs) -{ - error_t err = 0; - int bsize = dev->dev_block_size; - vm_offset_t read = 0; - vm_offset_t block = (bsize == 1 ? *offs : *offs / bsize); - - assert(*offs % bsize == 0); - assert(amount % bsize == 0); - - if (amount < IO_INBAND_MAX) - { - if (*buf_len < amount) - err = vm_allocate(mach_task_self(), buf, amount, 1); - if (!err) - err = - device_read_inband(dev->port, 0, block, - amount, (io_buf_ptr_t)*buf, &read); - } - else - err = - device_read(dev->port, 0, block, amount, (io_buf_ptr_t *)buf, &read); - - if (!err) - { - *offs += read; - *buf_len = read; - } - - return err; -} diff --git a/devio/dev.h b/devio/dev.h deleted file mode 100644 index de51d788..00000000 --- a/devio/dev.h +++ /dev/null @@ -1,147 +0,0 @@ -/* A handle on a mach device. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 __DEV_H__ -#define __DEV_H__ - -#include -#include - -#include "iostate.h" - -/* #define FAKE */ -#define MSG - -#ifdef MSG -#include -#include -#include -extern FILE *debug; -extern struct mutex debug_lock; -#endif - -/* ---------------------------------------------------------------- */ - -/* Information about a kernel device. */ -struct dev -{ - /* The device port for the kernel device we're doing paging on. */ - device_t port; - /* The mach device name which we opened. */ - char *name; - - /* The total size of DEV. */ - vm_size_t size; - - /* The block size of DEV. I/O to DEV must occur in multiples of - block_size. */ - int dev_block_size; - /* The block size in which we will do I/O; this must be a multiple of - DEV_BLOCK_SIZE. */ - int block_size; - - /* Various attributes of this device (see below for the DEV_ flag bits). - This field is constant. */ - int flags; - - /* Current state of our output stream -- location and the buffer used to do - buffered i/o. */ - struct io_state io_state; - - /* The pager we're using to do disk i/o for us. If NULL, a pager hasn't - been allocated yet. Lock the lock in IO_STATE if you want to update - this field. */ - struct pager *pager; - /* The port_bucket for paging ports. */ - struct port_bucket *pager_port_bucket; - - /* The current owner of the open device. For terminals, this affects - controlling terminal behavior (see term_become_ctty). For all objects - this affects old-style async IO. Negative values represent pgrps. This - has nothing to do with the owner of a file (as returned by io_stat, and - as used for various permission checks by filesystems). An owner of 0 - indicates that there is no owner. */ - pid_t owner; -}; - -/* Various bits to be set in the flags field. */ - -/* True if this device should be used in `block' mode, with buffering of - sub-block-size i/o. */ -#define DEV_BUFFERED 0x1 -/* True if this device only supports serial i/o (that is, there's only one - read/write location, which must explicitly be moved to do i/o elsewhere.*/ -#define DEV_SERIAL 0x2 -/* True if we can change the current i/o location of a serial device. */ -#define DEV_SEEKABLE 0x4 -/* True if a device cannot be written on. */ -#define DEV_READONLY 0x8 - -/* Returns TRUE if any of the flags in BITS are set for DEV. */ -#define dev_is(dev, bits) ((dev)->flags & (bits)) - -/* Returns true if it's ok to call dev_write on these arguments, without - first copying BUF to a page-aligned buffer. */ -#define dev_write_valid(dev, buf, len, offs) \ - ((len) <= IO_INBAND_MAX || (buf) % vm_page_size == 0) - -/* Returns a pointer to a new device structure in DEV for the kernel device - NAME, with the given FLAGS. If BLOCK_SIZE is non-zero, it should be the - desired block size, and must be a multiple of the device block size. - If an error occurs, the error code is returned, otherwise 0. */ -error_t dev_open(char *name, int flags, int block_size, struct dev **dev); - -/* Free DEV and any resources it consumes. */ -void dev_close(struct dev *dev); - -/* Reads AMOUNT bytes from DEV and returns it in BUF and BUF_LEN (using the - standard mach out-array convention). *OFFS is incremented to reflect the - amount read/written. Both LEN and *OFFS must be multiples of DEV's block - size. If an error occurs, the error code is returned, otherwise 0. */ -error_t dev_read(struct dev *dev, - vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, - vm_offset_t *offs); - -/* Writes AMOUNT bytes from the buffer pointed to by BUF to the device DEV. - *OFFS is incremented to reflect the amount read/written. Both AMOUNT and - *OFFS must be multiples of DEV's block size, and either BUF must be - page-aligned, or dev_write_valid() must return true for these arguments. - If an error occurs, the error code is returned, otherwise 0. */ -error_t dev_write(struct dev *dev, - vm_address_t buf, vm_size_t amount, vm_offset_t *offs); - -/* Returns in MEMOBJ the port for a memory object backed by the storage on - DEV. Returns 0 or the error code if an error occurred. */ -error_t dev_get_memory_object(struct dev *dev, memory_object_t *memobj); - -/* Try to stop all paging activity on DEV, returning true if we were - successful. If NOSYNC is true, then we won't write back any (kernel) - cached pages to the device. */ -int dev_stop_paging (struct dev *dev, int nosync); - -/* Try and write out any pending writes to DEV. If WAIT is true, will wait - for any paging activity to cease. */ -error_t dev_sync(struct dev *dev, int wait); - -#ifdef MSG -char *brep(vm_address_t buf, vm_size_t len); -#endif - -#endif /* !__DEV_H__ */ diff --git a/devio/devio.c b/devio/devio.c deleted file mode 100644 index f1eb428a..00000000 --- a/devio/devio.c +++ /dev/null @@ -1,359 +0,0 @@ -/* A translator for doing I/O to mach kernel devices. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "open.h" -#include "dev.h" - -/* ---------------------------------------------------------------- */ - -/* The port class of our file system control pointer. */ -struct port_class *fsys_port_class; -/* The port class of the (only) root file port for the opened device. */ -struct port_class *root_port_class; - -/* A bucket to put all our ports in. */ -struct port_bucket *port_bucket; - -/* Trivfs noise. */ -struct port_class *trivfs_protid_portclasses[1]; -struct port_class *trivfs_cntl_portclasses[1]; -int trivfs_protid_nportclasses = 1; -int trivfs_cntl_nportclasses = 1; - -/* ---------------------------------------------------------------- */ - -#define USAGE "Usage: %s [OPTION...] DEVICE\n" - -static void -usage(int status) -{ - if (status != 0) - fprintf(stderr, "Try `%s --help' for more information.\n", - program_invocation_name); - else - { - printf(USAGE, program_invocation_name); - printf("\ -\n\ - -d, --devnum=NUM Give DEVICE a device number NUM\n\ - -r, --readonly Disable writing to DEVICE\n\ - -p, --seekable Enable seeking if DEVICE is serial\n\ - -s, --serial Indicate that DEVICE has a single R/W point\n\ - -b, --buffered, --block Open DEVICE in `block' mode, which allows reads\n\ - or writes less than a single block and buffers\n\ - I/O to the actual device. By default, all reads\n\ - and writes are made directly to the device,\n\ - with no buffering, and any sub-block-size I/O\n\ - is padded to the nearest full block.\n\ - -B NUM, --block-size=NUM Use a block size of NUM, which must be an integer\n\ - multiple of DEVICE's real block size\n\ -"); - } - - exit(status); -} - -#define SHORT_OPTIONS "bB:d:D:?rpsu" - -static struct option options[] = -{ - {"block-size", required_argument, 0, 'B'}, - {"help", no_argument, 0, '?'}, - {"devnum", required_argument, 0, 'm'}, - {"block", no_argument, 0, 'b'}, - {"buffered", no_argument, 0, 'b'}, - {"readonly", no_argument, 0, 'r'}, - {"seekable", no_argument, 0, 'p'}, - {"serial", no_argument, 0, 's'}, - {0, 0, 0, 0} -}; - -/* ---------------------------------------------------------------- */ - -/* A struct dev for the open kernel device. */ -static struct dev *device = NULL; -/* And a lock to arbitrate changes to it. */ -static struct mutex device_lock; - -/* Desired device parameters specified by the user. */ -static char *device_name = NULL; -static int device_flags = 0; -static int device_block_size = 0; - -/* A unixy device number to return when the device is stat'd. */ -static int device_number = 0; - -void main(int argc, char *argv[]) -{ - int opt; - error_t err; - mach_port_t bootstrap; - - while ((opt = getopt_long(argc, argv, SHORT_OPTIONS, options, 0)) != EOF) - switch (opt) - { - case 'r': device_flags |= DEV_READONLY; break; - case 's': device_flags |= DEV_SERIAL; break; - case 'b': device_flags |= DEV_BUFFERED; break; - case 'p': device_flags |= DEV_SEEKABLE; break; - case 'B': device_block_size = atoi(optarg); break; - case 'd': device_number = atoi(optarg); break; - case '?': usage(0); - default: usage(1); - } - - if (device_flags & DEV_READONLY) - /* Catch illegal writes at the point of open. */ - trivfs_allow_open &= ~O_WRITE; - - if (argv[optind] == NULL || argv[optind + 1] != NULL) - { - fprintf(stderr, USAGE, program_invocation_name); - usage(1); - } - - device_name = argv[optind]; - - task_get_bootstrap_port (mach_task_self (), &bootstrap); - if (bootstrap == MACH_PORT_NULL) - error(2, 0, "Must be started as a translator"); - - fsys_port_class = ports_create_class (trivfs_clean_cntl, 0); - root_port_class = ports_create_class (trivfs_clean_protid, 0); - port_bucket = ports_create_bucket (); - trivfs_protid_portclasses[0] = root_port_class; - trivfs_cntl_portclasses[0] = fsys_port_class; - - /* Reply to our parent */ - err = - trivfs_startup(bootstrap, 0, - fsys_port_class, port_bucket, - root_port_class, port_bucket, - NULL); - if (err) - error(3, err, "Contacting parent"); - - /* Open the device only when necessary. */ - device = NULL; - mutex_init(&device_lock); - - /* Launch. */ - ports_manage_port_operations_multithread (port_bucket, trivfs_demuxer, - 30*1000, 5*60*1000, 0, 0); - - exit(0); -} - -/* Called whenever someone tries to open our node (even for a stat). We - delay opening the kernel device until this point, as we can usefully - return errors from here. */ -static error_t -check_open_hook (struct trivfs_control *trivfs_control, - uid_t *uids, u_int nuids, - gid_t *gids, u_int ngids, - int flags) -{ - error_t err = 0; - - mutex_lock(&device_lock); - if (device == NULL) - /* Try and open the device. */ - { - err = dev_open(device_name, device_flags, device_block_size, &device); - if (err) - device = NULL; - if (err && (flags & (O_READ|O_WRITE)) == 0) - /* If we're not opening for read or write, then just ignore the - error, as this allows stat to word correctly. XXX */ - err = 0; - } - mutex_unlock(&device_lock); - - return err; -} - -static error_t -open_hook(struct trivfs_peropen *peropen) -{ - struct dev *dev = device; - if (dev) - return open_create(dev, (struct open **)&peropen->hook); - else - return 0; -} - -static void -close_hook(struct trivfs_peropen *peropen) -{ - if (peropen->hook) - open_free(peropen->hook); -} - -/* ---------------------------------------------------------------- */ -/* Trivfs hooks */ - -int trivfs_fstype = FSTYPE_DEV; -int trivfs_fsid = 0; - -int trivfs_support_read = 1; -int trivfs_support_write = 1; -int trivfs_support_exec = 0; - -int trivfs_allow_open = O_READ | O_WRITE; - -void -trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) -{ - struct open *open = cred->po->hook; - - if (open) - /* An open device. */ - { - struct dev *dev = open->dev; - vm_size_t size = dev->size; - - if (dev->block_size > 1) - st->st_blksize = dev->block_size; - - st->st_size = size; - st->st_blocks = size / 512; - - if (dev_is(dev, DEV_READONLY)) - st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); - - st->st_mode &= ~S_IFMT; - st->st_mode |= dev_is(dev, DEV_BUFFERED) ? S_IFBLK : S_IFCHR; - } - else - /* Try and do things without an open device... */ - { - st->st_blksize = device_block_size; - st->st_size = 0; - st->st_blocks = 0; - st->st_mode &= ~S_IFMT; - st->st_mode |= (device_flags & DEV_BUFFERED) ? S_IFBLK : S_IFCHR; - if (device_flags & DEV_READONLY) - st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); - } - - st->st_rdev = device_number; -} - -error_t -trivfs_goaway (struct trivfs_control *fsys, int flags) -{ - error_t err; - int force = (flags & FSYS_GOAWAY_FORCE); - int nosync = (flags & FSYS_GOAWAY_NOSYNC); - - mutex_lock(&device_lock); - - if (device == NULL) - exit (0); - - /* Wait until all pending rpcs are done. */ - err = ports_inhibit_class_rpcs (root_port_class); - if (err == EINTR || (err && !force)) - { - mutex_unlock (&device_lock); - return err; - } - - if (force && nosync) - /* Exit with extreme prejudice. */ - exit (0); - - if (!force && ports_count_class (root_port_class) > 0) - /* Still users, so don't exit. */ - goto busy; - - if (!nosync) - /* Sync the device here, if necessary, so that closing it won't result in - any I/O (which could get hung up trying to use one of our pagers). */ - dev_sync (device, 1); - - /* devpager_shutdown may sync the pagers as side-effect (if NOSYNC is 0), - so we put that first in this test. */ - if (dev_stop_paging (device, nosync) || force) - /* Bye-bye. */ - { - if (!nosync) - /* If NOSYNC is true, we don't close DEV, as that could cause data to - be written back. */ - dev_close (device); - exit (0); - } - - busy: - /* Allow normal operations to proceed. */ - ports_enable_class (root_port_class); - ports_resume_class_rpcs (root_port_class); - mutex_unlock(&device_lock); - - /* Complain that there are still users. */ - return EBUSY; -} - -/* If this variable is set, it is called every time an open happens. - UIDS, GIDS, and FLAGS are from the open; CNTL identifies the - node being opened. This call need not check permissions on the underlying - node. If the open call should block, then return EWOULDBLOCK. Other - errors are immediately reflected to the user. If O_NONBLOCK - is not set in FLAGS and EWOULDBLOCK is returned, then call - trivfs_complete_open when all pending open requests for this - file can complete. */ -error_t (*trivfs_check_open_hook)(struct trivfs_control *trivfs_control, - uid_t *uids, u_int nuids, - gid_t *gids, u_int ngids, - int flags) - = check_open_hook; - -/* If this variable is set, it is called every time a new peropen - structure is created and initialized. */ -error_t (*trivfs_peropen_create_hook)(struct trivfs_peropen *) = open_hook; - -/* If this variable is set, it is called every time a peropen structure - is about to be destroyed. */ -void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *) = close_hook; - -/* Sync this filesystem. */ -kern_return_t -trivfs_S_fsys_syncfs (struct trivfs_control *cntl, - mach_port_t reply, mach_msg_type_name_t replytype, - int wait, int dochildren) -{ - struct dev *dev = device; - if (dev) - return dev_sync(dev, wait); - else - return 0; -} diff --git a/devio/devpager.c b/devio/devpager.c deleted file mode 100644 index 1f3b3ee1..00000000 --- a/devio/devpager.c +++ /dev/null @@ -1,257 +0,0 @@ -/* A pager interface for raw mach devices. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include -#include -#include - -#include "dev.h" - -/* ---------------------------------------------------------------- */ -/* Pager library callbacks; see for more info. */ - -/* 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. */ -error_t -pager_read_page(struct user_pager_info *upi, - vm_offset_t page, vm_address_t *buf, int *writelock) -{ - error_t err; - int read; /* bytes actually read */ - int want = vm_page_size; /* bytes we want to read */ - struct dev *dev = (struct dev *)upi; - - if (page + want > dev->size) - /* Read a partial page if necessary to avoid reading off the end. */ - want = dev->size - page; - - err = device_read(dev->port, 0, page / dev->dev_block_size, want, - (io_buf_ptr_t *)buf, &read); - - if (!err && want < vm_page_size) - /* Zero anything we didn't read. Allocation only happens in page-size - multiples, so we know we can write there. */ - bzero((char *)*buf + want, vm_page_size - want); - - *writelock = (dev->flags & DEV_READONLY); - - if (err || read < want) - return EIO; - else - return 0; -} - -/* For pager PAGER, synchronously write one page from BUF to offset PAGE. In - addition, vm_deallocate (or equivalent) BUF. The only permissable error - returns are EIO, EDQUOT, and ENOSPC. */ -error_t -pager_write_page(struct user_pager_info *upi, - vm_offset_t page, vm_address_t buf) -{ - struct dev *dev = (struct dev *)upi; - - if (dev->flags & DEV_READONLY) - return EROFS; - else - { - error_t err; - int written; - int want = vm_page_size; - - if (page + want > dev->size) - /* Write a partial page if necessary to avoid reading off the end. */ - want = dev->size - page; - - err = device_write(dev->port, 0, page / dev->dev_block_size, - (io_buf_ptr_t)buf, want, &written); - - vm_deallocate(mach_task_self(), buf, vm_page_size); - - if (err || written < want) - return EIO; - else - return 0; - } -} - -/* A page should be made writable. */ -error_t -pager_unlock_page(struct user_pager_info *upi, vm_offset_t address) -{ - struct dev *dev = (struct dev *)upi; - - if (dev->flags & DEV_READONLY) - return EROFS; - else - return 0; -} - -/* The user must define this function. It should report back (in - *OFFSET and *SIZE the minimum valid address the pager will accept - and the size of the object. */ -error_t -pager_report_extent(struct user_pager_info *upi, - vm_address_t *offset, vm_size_t *size) -{ - *offset = 0; - *size = ((struct dev *)upi)->size; - return 0; -} - -/* This is called when a pager is being deallocated after all extant send - rights have been destroyed. */ -void -pager_clear_user_data(struct user_pager_info *upi) -{ -} - -/* ---------------------------------------------------------------- */ - -/* A top-level function for the paging thread that just services paging - requests. */ -static void -service_paging_requests (any_t arg) -{ - struct dev *dev = (struct dev *)arg; - for (;;) - ports_manage_port_operations_multithread (dev->pager_port_bucket, - pager_demuxer, - 1000 * 30, 1000 * 60 * 5, - 1, MACH_PORT_NULL); -} - -/* Initialize paging for this device. */ -static void -init_dev_paging (struct dev *dev) -{ - dev->pager_port_bucket = ports_create_bucket (); - - /* Make a thread to service paging requests. */ - cthread_detach (cthread_fork ((cthread_fn_t)service_paging_requests, - (any_t)dev)); -} - -void -pager_dropweak (struct user_pager_info *upi __attribute__ ((unused))) -{ -} - -/* ---------------------------------------------------------------- */ - -/* Try to stop all paging activity on DEV, returning true if we were - successful. If NOSYNC is true, then we won't write back any (kernel) - cached pages to the device. */ -int -dev_stop_paging (struct dev *dev, int nosync) -{ - int success = 1; /* Initially assume success. */ - - io_state_lock(&dev->io_state); - - if (dev->pager != NULL) - { - int num_pagers = ports_count_bucket (dev->pager_port_bucket); - if (num_pagers > 0 && !nosync) - { - error_t block_cache (void *arg) - { - struct pager *p = arg; - pager_change_attributes (p, 0, MEMORY_OBJECT_COPY_DELAY, 1); - return 0; - } - error_t enable_cache (void *arg) - { - struct pager *p = arg; - pager_change_attributes (p, 1, MEMORY_OBJECT_COPY_DELAY, 0); - return 0; - } - - /* Loop through the pagers and turn off caching one by one, - synchronously. That should cause termination of each pager. */ - ports_bucket_iterate (dev->pager_port_bucket, block_cache); - - /* Give it a second; the kernel doesn't actually shutdown - immediately. XXX */ - sleep (1); - - num_pagers = ports_count_bucket (dev->pager_port_bucket); - if (num_pagers > 0) - /* Darn, there are actual honest users. Turn caching back on, - and return failure. */ - { - ports_bucket_iterate (dev->pager_port_bucket, enable_cache); - success = 0; - } - } - - if (success && !nosync) - /* shutdown the pager on DEV. If NOSYNC is set, we don't bother, for - fear that this may result in I/O. In this case we've disabled - rpcs on the pager's ports, so this will result in hanging... What - do we do??? XXXX */ - pager_shutdown (dev->pager); - } - - if (success) - dev->pager = NULL; - - io_state_lock(&dev->io_state); - - return success; -} - -/* ---------------------------------------------------------------- */ - -/* Returns in MEMOBJ the port for a memory object backed by the storage on - DEV. Returns 0 or the error code if an error occurred. */ -error_t -dev_get_memory_object(struct dev *dev, memory_object_t *memobj) -{ - if (dev_is(dev, DEV_SERIAL)) - return ENODEV; - - io_state_lock(&dev->io_state); - if (dev->pager_port_bucket == NULL) - init_dev_paging (dev); - if (dev->pager == NULL) - dev->pager = - pager_create((struct user_pager_info *)dev, dev->pager_port_bucket, - 1, MEMORY_OBJECT_COPY_DELAY); - else - ports_port_ref (dev->pager); - io_state_unlock(&dev->io_state); - - if (dev->pager == NULL) - return ENODEV; /* XXX ??? */ - - *memobj = pager_get_port(dev->pager); - ports_port_deref (dev->pager); /* Drop our original ref on PAGER. */ - - if (*memobj != MACH_PORT_NULL) - return - mach_port_insert_right(mach_task_self(), - *memobj, *memobj, - MACH_MSG_TYPE_MAKE_SEND); - - return 0; -} diff --git a/devio/io.c b/devio/io.c deleted file mode 100644 index 61f655d2..00000000 --- a/devio/io.c +++ /dev/null @@ -1,396 +0,0 @@ -/* Implements the hurd io interface to devio. - - Copyright (C) 1995, 1996 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include -#include -#include -#include - -#include "open.h" -#include "dev.h" -#include "iostate.h" - -/* ---------------------------------------------------------------- */ - -/* Return objects mapping the data underlying this memory object. If - the object can be read then memobjrd will be provided; if the - object can be written then memobjwr will be provided. For objects - where read data and write data are the same, these objects will be - equal, otherwise they will be disjoint. Servers are permitted to - implement io_map but not io_map_cntl. Some objects do not provide - mapping; they will set none of the ports and return an error. Such - objects can still be accessed by io_read and io_write. */ -kern_return_t -trivfs_S_io_map(struct trivfs_protid *cred, - memory_object_t *rdobj, - mach_msg_type_name_t *rdtype, - memory_object_t *wrobj, - mach_msg_type_name_t *wrtype) -{ - if (!cred) - return EOPNOTSUPP; - else - { - mach_port_t memobj; - struct open *open = (struct open *)cred->po->hook; - error_t err = dev_get_memory_object(open->dev, &memobj); - - if (!err) - { - if (cred->po->openmodes & O_READ) - { - *rdobj = memobj; - *rdtype = MACH_MSG_TYPE_MOVE_SEND; - } - else - *rdobj = MACH_PORT_NULL; - - if (cred->po->openmodes & O_WRITE) - { - *wrobj = memobj; - *wrtype = MACH_MSG_TYPE_MOVE_SEND; - } - else - *wrobj = MACH_PORT_NULL; - } - - return err; - } -} - -/* ---------------------------------------------------------------- */ - -/* Read data from an IO object. If offset if -1, read from the object - maintained file pointer. If the object is not seekable, offset is - ignored. The amount desired to be read is in AMT. */ -kern_return_t -trivfs_S_io_read(struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - vm_address_t *data, - mach_msg_type_number_t *datalen, - off_t offs, - mach_msg_type_number_t amt) -{ - if (!cred) - return EOPNOTSUPP; - else if (!(cred->po->openmodes & O_READ)) - return EBADF; - else - return open_read((struct open *)cred->po->hook, data, datalen, amt, offs); -} - -/* ---------------------------------------------------------------- */ - -/* Tell how much data can be read from the object without blocking for - a "long time" (this should be the same meaning of "long time" used - by the nonblocking flag. */ -kern_return_t -trivfs_S_io_readable (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - mach_msg_type_number_t *amount) -{ - if (!cred) - return EOPNOTSUPP; - else if (!(cred->po->openmodes & O_READ)) - return EINVAL; - else - { - struct open *open = (struct open *)cred->po->hook; - struct dev *dev = open->dev; - vm_offset_t location = open_get_io_state(open)->location; - *amount = dev->size - location; - return 0; - } -} - -/* ---------------------------------------------------------------- */ - -/* Change current read/write offset */ -kern_return_t -trivfs_S_io_seek (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - off_t offs, int whence, off_t *new_offs) -{ - if (!cred) - return EOPNOTSUPP; - else - return open_seek ((struct open *)cred->po->hook, offs, whence, new_offs); -} - -/* ---------------------------------------------------------------- */ - -/* SELECT_TYPE is the bitwise OR of SELECT_READ, SELECT_WRITE, and SELECT_URG. - Block until one of the indicated types of i/o can be done "quickly", and - return the types that are then available. */ -kern_return_t -trivfs_S_io_select (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - int *type) -{ - if (!cred) - return EOPNOTSUPP; - else if (((*type & SELECT_READ) && !(cred->po->openmodes & O_READ)) - || ((*type & SELECT_WRITE) && !(cred->po->openmodes & O_WRITE))) - return EBADF; - else - *type &= ~SELECT_URG; - return 0; -} - -/* ---------------------------------------------------------------- */ - -/* Write data to an IO object. If offset is -1, write at the object - maintained file pointer. If the object is not seekable, offset is - ignored. The amount successfully written is returned in amount. A - given user should not have more than one outstanding io_write on an - object at a time; servers implement congestion control by delaying - responses to io_write. Servers may drop data (returning ENOBUFS) - if they recevie more than one write when not prepared for it. */ -kern_return_t -trivfs_S_io_write (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - vm_address_t data, mach_msg_type_number_t datalen, - off_t offs, mach_msg_type_number_t *amt) -{ - if (!cred) - return EOPNOTSUPP; - else if (!(cred->po->openmodes & O_WRITE)) - return EBADF; - else - return open_write((struct open *)cred->po->hook, data, datalen, amt, offs); -} - -/* ---------------------------------------------------------------- */ - -/* Truncate file. */ -kern_return_t -trivfs_S_file_set_size (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t reply_type, - off_t size) -{ - if (!cred) - return EOPNOTSUPP; - else - return 0; -} - -/* ---------------------------------------------------------------- */ -/* These four routines modify the O_APPEND, O_ASYNC, O_FSYNC, and - O_NONBLOCK bits for the IO object. In addition, io_get_openmodes - will tell you which of O_READ, O_WRITE, and O_EXEC the object can - be used for. The O_ASYNC bit affects icky async I/O; good async - I/O is done through io_async which is orthogonal to these calls. */ - -kern_return_t -trivfs_S_io_get_openmodes (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - int *bits) -{ - if (!cred) - return EOPNOTSUPP; - else - { - *bits = cred->po->openmodes; - return 0; - } -} - -error_t -trivfs_S_io_set_all_openmodes(struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t replytype, - int mode) -{ - if (!cred) - return EOPNOTSUPP; - else - return 0; -} - -kern_return_t -trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t replytype, - int bits) -{ - if (!cred) - return EOPNOTSUPP; - else - return 0; -} - -kern_return_t -trivfs_S_io_clear_some_openmodes (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t replytype, - int bits) -{ - if (!cred) - return EOPNOTSUPP; - else - return 0; -} - -/* ---------------------------------------------------------------- */ -/* Get/set the owner of the IO object. For terminals, this affects - controlling terminal behavior (see term_become_ctty). For all - objects this affects old-style async IO. Negative values represent - pgrps. This has nothing to do with the owner of a file (as - returned by io_stat, and as used for various permission checks by - filesystems). An owner of 0 indicates that there is no owner. */ - -kern_return_t -trivfs_S_io_get_owner (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t replytype, - pid_t *owner) -{ - if (!cred) - return EOPNOTSUPP; - else - { - struct open *open = (struct open *)cred->po->hook; - *owner = open->dev->owner; - return 0; - } -} - -kern_return_t -trivfs_S_io_mod_owner (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t replytype, - pid_t owner) -{ - if (!cred) - return EOPNOTSUPP; - else - { - struct open *open = (struct open *)cred->po->hook; - open->dev->owner = owner; - return 0; - } -} - - -/* ---------------------------------------------------------------- */ -/* File syncing operations; these all do the same thing, sync the underlying - device. */ - -kern_return_t -trivfs_S_file_sync (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t reply_type, - int wait) -{ - if (cred) - return dev_sync (((struct open *)cred->po->hook)->dev, wait); - else - return EOPNOTSUPP; -} - -kern_return_t -trivfs_S_file_syncfs (struct trivfs_protid *cred, - mach_port_t reply, mach_msg_type_name_t reply_type, - int wait, int dochildren) -{ - if (!cred) - return dev_sync (((struct open *)cred->po->hook)->dev, wait); - else - return EOPNOTSUPP; -} - -error_t -trivfs_S_file_get_storage_info (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t reply_type, - mach_port_t **ports, - mach_msg_type_name_t *ports_type, - mach_msg_type_number_t *num_ports, - int **ints, mach_msg_type_number_t *num_ints, - off_t **offsets, - mach_msg_type_number_t *num_offsets, - char **data, mach_msg_type_number_t *data_len) -{ - error_t err = 0; - - if (!cred) - err = EOPNOTSUPP; - else - { - /* True when we've allocated memory for the corresponding vector. */ - int al_ports = 0, al_ints = 0, al_offsets = 0, al_data = 0; - -#define ENSURE_MEM(v, vl, alp, num) \ - if (!err && *vl < num) \ - { \ - err = vm_allocate (mach_task_self (), \ - (vm_address_t *)v, num * sizeof (**v), 1); \ - if (! err) \ - { \ - *vl = num; \ - alp = 1; \ - } \ - } - - ENSURE_MEM (ports, num_ports, al_ports, 1); - ENSURE_MEM (ints, num_ints, al_ints, 6); - ENSURE_MEM (offsets, num_offsets, al_offsets, 2); - ENSURE_MEM (data, data_len, al_data, 1); - - if (! err) - { - struct dev *dev = ((struct open *)cred->po->hook)->dev; - (*ints)[0] = STORAGE_DEVICE; /* type */ - (*ints)[1] = 0; /* flags */ - (*ints)[2] = dev->dev_block_size; /* block_size */ - (*ints)[3] = 1; /* num_runs */ - (*ints)[4] = strlen (dev->name) + 1; /* name_len */ - (*ints)[5] = 0; /* misc_len */ - *num_ints = 6; - - (*offsets)[0] = 0; - (*offsets)[1] = dev->size / dev->dev_block_size; - *num_offsets = 2; - - strcpy (*data, dev->name); - *data_len = strlen (dev->name) + 1; - - if (cred->isroot) - (*ports)[0] = dev->port; - else - (*ports)[0] = MACH_PORT_NULL; - *num_ports = 1; - *ports_type = MACH_MSG_TYPE_COPY_SEND; - } - else - /* Some memory allocation failed (not bloody likely). */ - { -#define DISCARD_MEM(v, vl, alp) \ - if (alp) \ - vm_deallocate (mach_task_self (), (vm_address_t)*v, *vl * sizeof (**v)); - - DISCARD_MEM (ports, num_ports, al_ports); - DISCARD_MEM (ints, num_ints, al_ints); - DISCARD_MEM (offsets, num_offsets, al_offsets); - DISCARD_MEM (data, data_len, al_data); - } - } - - return err; -} diff --git a/devio/iostate.c b/devio/iostate.c deleted file mode 100644 index fe40fcd2..00000000 --- a/devio/iostate.c +++ /dev/null @@ -1,79 +0,0 @@ -/* State for an I/O stream. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 - -#include "iostate.h" -#include "dev.h" - -/* ---------------------------------------------------------------- */ - -/* Initialize the io_state structure IOS to be used with the device DEV. If - a memory allocation error occurs, ENOMEM is returned, otherwise 0. */ -error_t -io_state_init(struct io_state *ios, struct dev *dev) -{ - error_t err = - vm_allocate(mach_task_self(), - (vm_address_t *)&ios->buffer, dev->block_size, 1); - - ios->location = 0; - ios->buffer_size = dev->block_size; - ios->buffer_use = 0; - mutex_init(&ios->lock); - - return err; -} - -/* Frees all resources used by IOS. */ -void -io_state_finalize(struct io_state *ios) -{ - vm_deallocate(mach_task_self(), (vm_address_t)ios->buffer, ios->buffer_size); -} - -/* If IOS's location isn't block aligned because writes have been buffered - there, then sync the whole buffer out to the device. Any error that - occurs while writing is returned, otherwise 0. */ -error_t -io_state_sync(struct io_state *ios, struct dev *dev) -{ - error_t err = 0; - - if (ios->buffer_use == IO_STATE_BUFFERED_WRITE) - { - vm_offset_t pos = ios->location; - int block_offs = pos % dev->block_size; - - if (block_offs > 0) - { - bzero((char *)ios->buffer + block_offs, - dev->block_size - block_offs); - ios->location -= block_offs; - err = - dev_write(dev, ios->buffer, dev->block_size, &ios->location); - } - - /* Remember that there's nothing left in the buffer. */ - ios->buffer_use = 0; - } - - return err; -} diff --git a/devio/iostate.h b/devio/iostate.h deleted file mode 100644 index 1795e153..00000000 --- a/devio/iostate.h +++ /dev/null @@ -1,67 +0,0 @@ -/* State for an I/O stream. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 __IOSTATE_H__ -#define __IOSTATE_H__ - -/* ---------------------------------------------------------------- */ - -enum io_state_buffer_use -{ - /* 0 means nothing */ - IO_STATE_BUFFERED_WRITE = 1, IO_STATE_BUFFERED_READ = 2 -}; - -struct io_state { - /* What we think the current position is. */ - vm_offset_t location; - - /* The buffer in which we accumulate buffered i/o. */ - vm_address_t buffer; - /* The size of BUFFER. */ - vm_size_t buffer_size; - - /* If LOCATION is not a multiple of the block size (and so points somewhere - in the middle of BUFFER), this indicates why. */ - enum io_state_buffer_use buffer_use; - - /* Lock this if you want to read/modify LOCATION or BUFFER. */ - struct mutex lock; -}; - -#define io_state_lock(ios) mutex_lock(&(ios)->lock) -#define io_state_unlock(ios) mutex_unlock(&(ios)->lock) - -/* Declare this to keep the parameter scope below sane. */ -struct dev; - -/* Initialize the io_state structure IOS to be used with the device DEV. If - a memory allocation error occurs, ENOMEM is returned, otherwise 0. */ -error_t io_state_init(struct io_state *ios, struct dev *dev); - -/* Frees all resources used by IOS. */ -void io_state_finalize(struct io_state *ios); - -/* If IOS's location isn't block aligned because writes have been buffered - there, then sync the whole buffer out to the device. Any error that - occurs while writing is returned, otherwise 0. */ -error_t io_state_sync(struct io_state *ios, struct dev *dev); - -#endif /* !__IOSTATE_H__ */ diff --git a/devio/mem.c b/devio/mem.c deleted file mode 100644 index 65caa19f..00000000 --- a/devio/mem.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Some random handy ops for dealing with rpcs that return memory. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include - -/* ---------------------------------------------------------------- */ - -/* Makes sure that BUF, points to a buffer with AMOUNT bytes available. - *BUF_LEN should be the current length of *BUF, and if this isn't enough to - hold AMOUNT bytes, then more is allocated and the new buffer is returned - in *BUF and *BUF_LEN. If a memory allocation error occurs, the error code - is returned, otherwise 0. */ -error_t -allocate(vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount) -{ - if (*buf_len < amount) - { - error_t err = vm_allocate(mach_task_self(), buf, amount, 1); - if (err) - return err; - } - - *buf_len = amount; - return 0; -} - -/* Deallocates any pages entirely within the last EXCESS bytes of the BUF_LEN - long buffer, BUF. */ -error_t -deallocate_excess(vm_address_t buf, vm_size_t buf_len, vm_size_t excess) -{ - vm_size_t excess_pages = buf_len - round_page(buf_len - excess); - if (excess_pages > 0) - return - vm_deallocate(mach_task_self(), - round_page(buf + buf_len - excess), excess_pages); - else - return 0; -} diff --git a/devio/mem.h b/devio/mem.h deleted file mode 100644 index e19b590c..00000000 --- a/devio/mem.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Some random handy memory ops that know about VM. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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. */ - -/* For bcopy &c. */ -#include - -/* Makes sure that BUF, points to a buffer with AMOUNT bytes available. - *BUF_LEN should be the current length of *BUF, and if this isn't enough to - hold AMOUNT bytes, then more is allocated and the new buffer is returned - in *BUF and *BUF_LEN. If a memory allocation error occurs, the error code - is returned, otherwise 0. */ -error_t allocate(vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount); - -/* Deallocates any pages entirely within the last EXCESS bytes of the BUF_LEN - long buffer, BUF. */ -error_t deallocate_excess(vm_address_t buf, vm_size_t buf_len, vm_size_t excess); diff --git a/devio/open.c b/devio/open.c deleted file mode 100644 index bab4fe99..00000000 --- a/devio/open.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Per-open information for devio. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 - -#include "open.h" -#include "window.h" -#include "dev.h" - -/* ---------------------------------------------------------------- */ - -/* Returns a new per-open structure for the device DEV in OPEN. If an error - occurs, the error-code is returned, otherwise 0. */ -error_t -open_create(struct dev *dev, struct open **open) -{ - error_t err; - - *open = malloc(sizeof(struct open)); - - if (*open == NULL) - return ENOMEM; - - (*open)->dev = dev; - - err = io_state_init(&(*open)->io_state, dev); - - if (!err && dev_is(dev, DEV_BUFFERED) && !dev_is(dev, DEV_SERIAL)) - /* A random-access buffered device -- use a pager to do i/o to it. */ - { - mach_port_t memobj; - err = dev_get_memory_object(dev, &memobj); - if (!err) - err = - window_create(memobj, dev->size, 0, 0, dev_is(dev, DEV_READONLY), - &(*open)->window); /* XXX sizes */ - if (err) - { - mach_port_destroy(mach_task_self(), memobj); - io_state_finalize(&(*open)->io_state); - } - } - else - (*open)->window = NULL; - - if (err) - free(*open); - - return err; -} - -/* ---------------------------------------------------------------- */ - -/* Free OPEN and any resources it holds. */ -void -open_free(struct open *open) -{ - io_state_finalize(&open->io_state); - window_free(open->window); - free(open); -} - - -/* ---------------------------------------------------------------- */ - -/* Returns the appropiate io_state object for OPEN (which may be either - per-open or a per-device depending on the device). */ -struct io_state * -open_get_io_state(struct open *open) -{ - return - dev_is(open->dev, DEV_SERIAL) ? &open->dev->io_state : &open->io_state; -} diff --git a/devio/open.h b/devio/open.h deleted file mode 100644 index 80763585..00000000 --- a/devio/open.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Per-open information for devio. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 __OPEN_H__ -#define __OPEN_H__ - -#include "iostate.h" - -/* ---------------------------------------------------------------- */ - -/* A structure describing a particular i/o stream on this device. */ -struct open -{ - /* Current state of our output stream -- location and the buffer used to do - buffered i/o. */ - struct io_state io_state; - - /* The memory window we're using to do i/o. This may be NULL, indicating - we're not doing buffered random access i/o. */ - struct window *window; - - /* The device that this an open on. */ - struct dev *dev; -}; - -/* Returns a new per-open structure for the device DEV in OPEN. If an error - occurs, the error-code is returned, otherwise 0. */ -error_t open_create(struct dev *dev, struct open **open); - -/* Free OPEN and any resources it holds. */ -void open_free(struct open *open); - -/* Returns the appropiate io_state object for OPEN (which may be either - per-open or a per-device depending on the device). */ -struct io_state *open_get_io_state(struct open *open); - -/* Writes up to LEN bytes from BUF to OPEN's device at device offset OFFS - (which may be ignored if the device doesn't support random access), - and returns the number of bytes written in AMOUNT. If no error occurs, - zero is returned, otherwise the error code is returned. */ -error_t open_write(struct open *open, vm_address_t buf, vm_size_t len, - vm_size_t *amount, off_t offs); - -/* Reads up to AMOUNT bytes from the device into BUF and BUF_LEN using the - standard mach out-array convention. If no error occurs, zero is returned, - otherwise the error code is returned. */ -error_t open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, - vm_size_t amount, off_t offs); - -/* Set OPEN's location to OFFS, interpreted according to WHENCE as by seek. - The new absolute location is returned in NEW_OFFS (and may not be the same - as OFFS). If no error occurs, zero is returned, otherwise the error code - is returned. */ -error_t open_seek (struct open *open, off_t offs, int whence, off_t *new_offs); - -#endif /* !__OPEN_H__ */ diff --git a/devio/ptypes.h b/devio/ptypes.h deleted file mode 100644 index 64aa3b0d..00000000 --- a/devio/ptypes.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Libports port types for devio. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 PT_FSYS 0 -#define PT_NODE 1 -#define PT_MEMOBJ 2 diff --git a/devio/rdwr.c b/devio/rdwr.c deleted file mode 100644 index 67f087a0..00000000 --- a/devio/rdwr.c +++ /dev/null @@ -1,471 +0,0 @@ -/* Implements various types of I/O on top of raw devices. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 -#include -#include - -#include "open.h" -#include "dev.h" -#include "mem.h" -#include "window.h" - -/* ---------------------------------------------------------------- */ - -/* Writes BUF to DEV, copying through an intermediate buffer to page-align - it. If STAGING_BUF isn't 0, it is used as the copy buffer for - small-enough transfers (staging_buf is assumed to be one block in length). - AMOUNT is the actual amount written, and LEN is the amount of source - material actually in BUF; if LEN is smaller than AMOUNT, the remainder is - zero. */ -static error_t -copying_block_write(struct dev *dev, vm_address_t staging_buf, - vm_address_t buf, vm_size_t len, vm_size_t amount, - vm_offset_t *offs) -{ - error_t err = 0; - vm_address_t copy_buf = staging_buf; - vm_size_t copy_buf_len = dev->block_size; - - if (amount > dev->block_size || staging_buf == 0) - { - copy_buf_len = amount; - err = vm_allocate(mach_task_self(), ©_buf, copy_buf_len, 1); - if (err) - return err; - } - - bcopy((char *)buf, (char *)copy_buf, len); - if (len < amount && copy_buf == staging_buf) - /* We need to zero the rest of the bloc, but only if we didn't - vm_allocate it (in which case it will be zero-filled). */ - bzero((char *)buf + len, amount - len); - - err = dev_write(dev, copy_buf, amount, offs); - - if (copy_buf != staging_buf) - vm_deallocate(mach_task_self(), copy_buf, copy_buf_len); - - return err; -} - -/* ---------------------------------------------------------------- */ - -/* Copies LEN bytes from BUF to DEV, using STAGING_BUF to do buffering of - partial blocks, and returning the amount actually written in AMOUNT. - *OFFS is incremented to reflect the amount read/written. If an error - occurs, the error code is returned, otherwise 0. */ -error_t -buffered_write(struct dev *dev, vm_address_t staging_buf, - vm_address_t buf, vm_size_t len, vm_size_t *amount, - vm_offset_t *offs) -{ - error_t err = 0; - int bsize = dev->block_size; - int staging_buf_loc = *offs % bsize; - int left_in_staging_buf = bsize - staging_buf_loc; - vm_offset_t start_offs = *offs; - - if (left_in_staging_buf > 0) - /* Write what's buffered from the last I/O. */ - { - /* Amount of the current i/o we can put in the staging buffer. */ - int stage = (left_in_staging_buf > len ? len : left_in_staging_buf); - - bcopy((char *)buf, (char *)staging_buf + staging_buf_loc, stage); - - buf += stage; - len -= stage; - *offs += stage; - - if (stage == left_in_staging_buf) - /* We've filled up STAGING_BUF so we can write it out now. */ - { - /* Backup OFFS to reflect the beginning-of-block position. */ - *offs -= bsize; - err = dev_write(dev, staging_buf, bsize, offs); - } - } - - if (!err && len > bsize) - /* Enough i/o pending to do whole block transfers. */ - { - /* The number of bytes at the end of the transfer that aren't a - multiple of the block-size. We have to deal with these separately - because device i/o must be in block multiples. */ - int excess = len % bsize; - vm_size_t block_len = len - excess; - - if (dev_write_valid(dev, buf, block_len, offs)) - /* BUF is page-aligned, so we can do i/o directly to the device, or - it is small enough that it doesn't matter. */ - err = dev_write(dev, buf, block_len, offs); - else - /* Argh! BUF isn't page aligned! We must filter the i/o though an - intermediate buffer... */ - err = copying_block_write(dev, staging_buf, - buf, block_len, block_len, offs); - - if (*offs - start_offs < left_in_staging_buf + block_len) - /* Didn't write out all the blocks, so suppress buffering the rest. */ - len = 0; - else - len = excess; - } - - /* At this point, LEN should be < BLOCK_SIZE, so we use buffering again. */ - if (!err && len > 0) - { - bcopy((char *)staging_buf, (char *)buf, len); - *offs += len; - } - - *amount = *offs - start_offs; - if (*amount > 0) - /* If an error occurred, but we successfully wrote *something*, then - pretend nothing bad happened; the error will probably get caught next - time. */ - err = 0; - - return err; -} - -/* ---------------------------------------------------------------- */ - -/* Reads AMOUNT bytes from DEV and returns them in BUF and BUF_LEN (using the - standard mach out-array conventions), using STAGING_BUF to do buffering of - partial blocks. *OFFS is incremented to reflect the amount read/written. - If an error occurs, the error code is returned, otherwise 0. */ -error_t -buffered_read (struct dev *dev, vm_address_t staging_buf, - vm_address_t *buf, vm_size_t *buf_len, vm_size_t amount, - vm_offset_t *offs) -{ - error_t err = 0; - int bsize = dev->block_size; - vm_offset_t start_offs = *offs; - int staging_buf_loc = *offs % bsize; - int from_staging_buf = bsize - staging_buf_loc; - vm_address_t block_buf = *buf; - vm_size_t block_buf_size = *buf_len; - vm_size_t block_amount = amount; - - if (staging_buf_loc > 0) - { - /* Read into a temporary buffer. */ - block_buf = 0; - block_buf_size = 0; - - if (from_staging_buf > amount) - from_staging_buf = amount; - - block_amount -= from_staging_buf; - } - else - from_staging_buf = 0; - - /* Read any new block required. */ - if (block_amount > 0) - { - /* We read enough to get every full block of BLOCK_AMOUNT, plus an - additional whole block if there's any more; we just copy any excess - from that last block into STAGING_BUF for next time. */ - block_amount = ((block_amount + bsize - 1) / bsize) * bsize; - - err = dev_read(dev, &block_buf, &block_buf_size, block_amount, offs); - if (err && staging_buf_loc > 0) - /* We got an error, but don't abort, since we did get the bit from - the buffer. */ - { - err = 0; - amount = from_staging_buf; - block_amount = 0; - } - - if (amount > *offs - start_offs) - /* If we read less than we hoped, reflect this down below. */ - amount = *offs - start_offs; - } - - if (staging_buf_loc > 0) - /* Coalesce what we have in STAGING_BUF with what we read. */ - { - err = allocate(buf, buf_len, amount); - assert_perror(err); - bcopy((char *)staging_buf + staging_buf_loc, (char *)*buf, - from_staging_buf); - - if (block_amount > 0) - bcopy((char *)block_buf, (char *)*buf + from_staging_buf, - amount - from_staging_buf); - } - else - /* Otherwise, BLOCK_BUF should already contain the correct data. */ - { - *buf = block_buf; - *buf_len = block_buf_size; - } - - if (*offs - start_offs > amount) - /* We've read too far, so put some amount from the end back into - STAGING_BUF. */ - { - int excess = (*offs - start_offs) - amount; - - bcopy((char *)block_buf + amount, - (char *)staging_buf + bsize - excess, - excess); - *offs -= excess; - - if (excess >= vm_page_size) - deallocate_excess(*buf, *buf_len, excess); - *buf_len -= excess; - } - - /* Deallocate any extra copy buffer if necessary. */ - if (*buf != block_buf) - vm_deallocate(mach_task_self(), block_buf, block_buf_size); - - return err; -} - -/* ---------------------------------------------------------------- */ - -/* Write BUF_LEN bytes from BUF to DEV, padding with zeros as necessary to - write whole blocks, and returning the amount actually written in AMOUNT. - If successful, 0 is returned, otherwise an error code is returned. *OFFS - is incremented by the change in device location. */ -error_t -raw_write(struct dev *dev, - vm_address_t buf, vm_size_t buf_len, - vm_size_t *amount, vm_offset_t *offs) -{ - error_t err; - int bsize = dev->block_size; - int block_amount = ((buf_len + bsize - 1) / bsize) * bsize; - vm_offset_t start_offs = *offs; - - if (start_offs % bsize != 0) - return EINVAL; - - if (block_amount == buf_len && dev_write_valid(dev, buf, block_amount, offs)) - /* BUF is page-aligned, so we can do i/o directly to the device, or - it is small enough that it doesn't matter. */ - err = dev_write(dev, buf, block_amount, offs); - else - /* Argh! BUF isn't page aligned! We must filter the i/o though an - intermediate buffer... [We use DEV's io_state buffer, as we know - that the io_state is locked in open_rdwr, and it isn't otherwise - used...] */ - err = copying_block_write(dev, dev->io_state.buffer, - buf, buf_len, block_amount, offs); - - if (!err && *offs - start_offs < buf_len) - *amount = *offs - start_offs; - else - *amount = buf_len; - - return err; -} - -/* Read AMOUNT bytes from DEV into BUF and BUF_LEN; only whole blocks are - read, but anything greater than *AMOUNT bytes is discarded. The standard - mach out-array convention is used to return the data in BUF and BUF_LEN. - If successful, 0 is returned, otherwise an error code is returned. *OFFS - is incremented by the change in device location. */ -error_t -raw_read(struct dev *dev, - vm_address_t *buf, vm_size_t *buf_len, - vm_size_t amount, vm_offset_t *offs) -{ - error_t err; - int bsize = dev->block_size; - int block_amount = ((amount + bsize - 1) / bsize) * bsize; - - if (*offs % bsize != 0) - return EINVAL; - - err = dev_read(dev, buf, buf_len, block_amount, offs); - if (!err) - { - int excess = *buf_len - amount; - if (excess > vm_page_size) - deallocate_excess(*buf, *buf_len, excess); - if (excess > 0) - *buf_len = amount; - } - - return err; -} - -/* ---------------------------------------------------------------- */ - -struct rdwr_state -{ - struct dev *dev; - off_t user_offs; - vm_offset_t *offs_p; - struct io_state *io_state; -}; - -/* Setup state needed for I/O to/from OPEN, putting it into STATE. OFFS - should be the original user-supplied offset. */ -static void -rdwr_state_init(struct rdwr_state *state, struct open *open, off_t offs) -{ - state->dev = open->dev; - state->io_state = open_get_io_state(open); - state->user_offs = offs; - - if (dev_is(state->dev, DEV_SERIAL)) - /* For serial i/o, we always ignore the proffered offs, and use the - actual device offset. */ - state->user_offs = -1; - - if (state->user_offs == -1 || !dev_is(state->dev, DEV_BUFFERED)) - /* If we're going to use some bit of IO_STATE, lock it first. This - should only not happen if we're going to used windowed i/o with an - explicit offset. */ - io_state_lock(state->io_state); - - if (state->user_offs == -1) - state->offs_p = &state->io_state->location; - else - state->offs_p = (vm_offset_t *)&state->user_offs; -} - -/* Destroy any state created by rdwr_state_init. */ -static void -rdwr_state_finalize(struct rdwr_state *state) -{ - if (state->user_offs == -1 || !dev_is(state->dev, DEV_BUFFERED)) - io_state_unlock(state->io_state); -} - -/* ---------------------------------------------------------------- */ - -/* Writes up to LEN bytes from BUF to OPEN's device at device offset OFFS - (which may be ignored if the device doesn't support random access), - and returns the number of bytes written in AMOUNT. If no error occurs, - zero is returned, otherwise the error code is returned. */ -error_t -open_write(struct open *open, vm_address_t buf, vm_size_t len, - vm_size_t *amount, off_t offs) -{ - error_t err; - struct rdwr_state state; - struct dev *dev = open->dev; - - rdwr_state_init(&state, open, offs); - - offs = *state.offs_p; - if (offs < 0) - err = EINVAL; - if (offs + len > dev->size) - err = EIO; - else if (!dev_is(dev, DEV_BUFFERED)) - err = raw_write(dev, buf, len, amount, state.offs_p); - else if (dev_is(dev, DEV_SERIAL)) - { - state.io_state->buffer_use = IO_STATE_BUFFERED_WRITE; - err = buffered_write(dev, state.io_state->buffer, buf, len, - amount, state.offs_p); - } - else - err = window_write(open->window, buf, len, amount, state.offs_p); - - rdwr_state_finalize(&state); - - return err; -} - -/* Reads up to AMOUNT bytes from the device into BUF and BUF_LEN using the - standard mach out-array convention. If no error occurs, zero is returned, - otherwise the error code is returned. */ -error_t -open_read(struct open *open, vm_address_t *buf, vm_size_t *buf_len, - vm_size_t amount, off_t offs) -{ - error_t err; - struct rdwr_state state; - struct dev *dev = open->dev; - - rdwr_state_init(&state, open, offs); - - offs = *state.offs_p; - if (offs < 0) - err = EINVAL; - if (offs + amount > dev->size) - err = EIO; - else if (!dev_is(dev, DEV_BUFFERED)) - err = raw_read(dev, buf, buf_len, amount, state.offs_p); - else if (dev_is(dev, DEV_SERIAL)) - { - state.io_state->buffer_use = IO_STATE_BUFFERED_READ; - err = buffered_read(dev, state.io_state->buffer, buf, buf_len, - amount, state.offs_p); - } - else - err = window_read(open->window, buf, buf_len, amount, state.offs_p); - - rdwr_state_finalize(&state); - - return err; -} - -/* Set OPEN's location to OFFS, interpreted according to WHENCE as by seek. - The new absolute location is returned in NEW_OFFS (and may not be the same - as OFFS). If no error occurs, zero is returned, otherwise the error code - is returned. */ -error_t -open_seek (struct open *open, off_t offs, int whence, off_t *new_offs) -{ - error_t err = 0; - struct io_state *io_state = open_get_io_state (open); - - if (!dev_is (open->dev, DEV_SEEKABLE)) - return ESPIPE; - - io_state_lock (io_state); - - switch (whence) - { - case SEEK_SET: - *new_offs = offs; break; - case SEEK_CUR: - *new_offs = io_state->location + offs; break; - case SEEK_END: - *new_offs = open->dev->size - offs; break; - default: - err = EINVAL; - } - - if (!err) - { - if (!dev_is (open->dev, DEV_BUFFERED)) - /* On unbuffered devices force seeks to the nearest block boundary. */ - *new_offs -= *new_offs % open->dev->block_size; - io_state->location = *new_offs; - } - - io_state_unlock (io_state); - - return err; -} diff --git a/devio/window.c b/devio/window.c deleted file mode 100644 index f7df045d..00000000 --- a/devio/window.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Window management routines for buffered I/O using VM. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 - -#include "window.h" -#include "mem.h" - -/* ---------------------------------------------------------------- */ - -/* Create a VM window onto the memory object MEMOBJ, and return it in WIN. - MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window - will shrink/grow to (a value of 0 will use some default). */ -error_t -window_create(mach_port_t memobj, vm_offset_t max_pos, - vm_size_t min_size, vm_size_t max_size, int read_only, - struct window **win) -{ - *win = malloc(sizeof(struct window)); - if (*win == NULL) - return ENOMEM; - - if (min_size < max_size) - min_size = max_size; - - (*win)->pos = 0; - (*win)->max_pos = max_pos; - (*win)->size = 0; - (*win)->memobj = memobj; - (*win)->min_size = (min_size < vm_page_size ? vm_page_size : min_size); - (*win)->max_size = (max_size < vm_page_size ? vm_page_size : max_size); - (*win)->read_only = read_only; - - return 0; -} - -/* Free WIN and any resources it holds. */ -void -window_free(struct window *win) -{ - if (win->size > 0) - vm_deallocate(mach_task_self(), win->buffer, win->size); - mach_port_destroy(mach_task_self(), win->memobj); - free(win); -} - -/* ---------------------------------------------------------------- */ - -/* Makes sure that WIN's memory window contains at least positions POS - through POS + LEN on the device WIN's mapping. If an error occurs in the - process, the error code is returned (and WIN may not map the desired - locations), otherwise 0. WIN is assumed to already be locked when this is - called. */ -static error_t -position(struct window *win, vm_offset_t pos, vm_size_t len) -{ - vm_offset_t end = pos + len; - vm_offset_t win_beg = win->pos; - vm_offset_t win_end = win_beg + win->size; - - if (pos >= win_beg && end <= win_end) - /* The request is totally satisfied by our current position. */ - return 0; - else -#if 0 /* XXXXXXX */ - if (end < win_beg || pos >= win_end) - /* The desired locations are entirely outside our current window, so just - trash it, and map a new buffer anywhere. */ -#endif - { - int prot = VM_PROT_READ | (win->read_only ? 0 : VM_PROT_WRITE); - - if (win->size > 0) - vm_deallocate(mach_task_self(), win->buffer, win->size); - - win->pos = trunc_page(pos); - win->size = round_page(len + (pos - win->pos)); - win->buffer = 0; - - if (win->size < win->min_size) - win->size = win->min_size; - - if (win->pos + win->size > win->max_pos) - win->size = win->max_pos - win->pos; - - return - vm_map(mach_task_self(), &win->buffer, win->size, 0, 1, - win->memobj, win->pos, 0, prot, prot, VM_INHERIT_NONE); - } - - return 0; -} - -/* ---------------------------------------------------------------- */ - -/* Write up to BUF_LEN bytes from BUF to the device that WIN is a window on, - at offset *OFFS, using memory-mapped buffered I/O. If successful, 0 is - returned, otherwise an error code is returned. *OFFS is incremented by - the amount sucessfully written. */ -error_t -window_write(struct window *win, - vm_address_t buf, vm_size_t buf_len, vm_size_t *amount, - vm_offset_t *offs) -{ - error_t err; - - mutex_lock(&win->lock); - - err = position(win, *offs, buf_len); - if (!err) - { - bcopy((char *)buf, - (char *)win->buffer + (*offs - win->pos), - buf_len); - *amount = buf_len; - *offs += buf_len; - } - - mutex_unlock(&win->lock); - - return err; -} - -/* Read up to AMOUNT bytes from the device that WIN is a window on, at offset - *OFFS, into BUF and BUF_LEN (using the standard mach out-array - conventions), using memory-mapped buffered I/O. If successful, 0 is - returned, otherwise an error code is returned. *OFFS is incremented by - the amount sucessfully written. */ -error_t -window_read(struct window *win, - vm_address_t *buf, vm_size_t *buf_len, - vm_size_t amount, vm_offset_t *offs) -{ - error_t err; - - mutex_lock(&win->lock); - - err = position(win, *offs, amount); - if (!err) - { - err = allocate(buf, buf_len, amount); - if (!err) - { - bcopy((char *)win->buffer + (*offs - win->pos), - (char *)*buf, - amount); - *offs += amount; - } - } - - mutex_unlock(&win->lock); - - return err; -} diff --git a/devio/window.h b/devio/window.h deleted file mode 100644 index c15ebd9e..00000000 --- a/devio/window.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Window management routines for buffered I/O using VM. - - Copyright (C) 1995 Free Software Foundation, Inc. - - Written by Miles Bader - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, 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 __WINDOW_H__ -#define __WINDOW_H__ - -#include - -/* ---------------------------------------------------------------- */ - -/* A structure describing a memory window used to do buffered random access - device i/o through the device pager. */ -struct window -{ - /* The currently allocated vm window backed by the device pager. */ - vm_address_t buffer; - - /* The device offset of the window. */ - vm_offset_t pos; - /* The end of the device. */ - vm_offset_t max_pos; - - /* The length of the window (should be a multiple of __vm_page_size). If - this is 0, this window isn't allocated. */ - vm_size_t size; - /* If SIZE < MIN_SIZE we won't shrink the window. */ - vm_size_t min_size; - /* If SIZE > MAX_SIZE, we'll try and shrink the window to fit. */ - vm_size_t max_size; - - /* The device pager providing backing store for this window. */ - mach_port_t memobj; - /* True if the mapping should be read_only. */ - int read_only; - - /* Lock this if you want to read/write some field(s) here. */ - struct mutex lock; -}; - -/* Create a VM window onto the memory object MEMOBJ, and return it in WIN. - MIN_SIZE and MAX_SIZE are the minimum and maximum sizes that the window - will shrink/grow to. */ -error_t window_create(mach_port_t memobj, vm_offset_t max_pos, - vm_size_t min_size, vm_size_t max_size, int read_only, - struct window **win); - -/* Free WIN and any resources it holds. */ -void window_free(struct window *win); - -/* Write up to BUF_LEN bytes from BUF to the device that WIN is a window on, - at offset *OFFS, using memory-mapped buffered I/O. If successful, 0 is - returned, otherwise an error code is returned. *OFFS is incremented by - the amount sucessfully written. */ -error_t window_write(struct window *win, - vm_address_t buf, vm_size_t buf_len, vm_size_t *amount, - vm_offset_t *offs); - -/* Read up to AMOUNT bytes from the device that WIN is a window on, at offset - *OFFS, into BUF and BUF_LEN (using the standard mach out-array - conventions), using memory-mapped buffered I/O. If successful, 0 is - returned, otherwise an error code is returned. *OFFS is incremented by - the amount sucessfully written. */ -error_t window_read(struct window *win, - vm_address_t *buf, vm_size_t *buf_len, - vm_size_t amount, vm_offset_t *offs); - -#endif /* !__WINDOW_H__ */ -- cgit v1.2.3 From 68de70d85b5a804c85b5e6890a236bd3c770759c Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:24:24 +0000 Subject: (pager_read_page, pager_write_page, pager_unlock_page): Adjust device addresses for possible differences between DEV_BSIZE & device block size. --- ufs/pager.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ufs/pager.c b/ufs/pager.c index 11d5eade..afb34839 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -1,5 +1,5 @@ /* Pager for ufs - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -166,7 +166,8 @@ pager_read_page (struct user_pager_info *pager, if (addr) { size_t read = 0; - err = store_read (store, addr, disksize, (void **)buf, &read); + err = store_read (store, addr << log2_dev_blocks_per_dev_bsize, + disksize, (void **)buf, &read); if (read != disksize) err = EIO; if (!err && disksize != __vm_page_size) @@ -208,7 +209,8 @@ pager_write_page (struct user_pager_info *pager, if (addr) { size_t wrote; - err = store_write (store, addr, (void *)buf, disksize, &wrote); + err = store_write (store, addr << log2_dev_blocks_per_dev_bsize, + (void *)buf, disksize, &wrote); if (wrote != disksize) err = EIO; } @@ -310,7 +312,9 @@ pager_unlock_page (struct user_pager_info *pager, goto out; assert (lblkno (sblock, address) < NDADDR); - err = store_write (store, fsbtodb (sblock, bno), + err = store_write (store, + fsbtodb (sblock, bno) + << log2_dev_blocks_per_dev_bsize, zeroblock, sblock->fs_bsize, &wrote); if (!err && wrote != sblock->fs_bsize) err = EIO; @@ -398,7 +402,9 @@ pager_unlock_page (struct user_pager_info *pager, if (err) goto out; - err = store_write (store, fsbtodb (sblock, bno), + err = store_write (store, + fsbtodb (sblock, bno) + << log2_dev_blocks_per_dev_bsize, zeroblock, sblock->fs_bsize, &wrote); if (!err && wrote != sblock->fs_bsize) err = EIO; -- cgit v1.2.3 From 102ca48a3c04c37a4c500ebc9ceb3b4cfc8b1df9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:24:43 +0000 Subject: (diskfs_S_file_get_storage_info): Adjust device addresses for possible differences between DEV_BSIZE & device block size. --- ufs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index 2965114f..fe5abbb9 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -683,6 +683,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, (((i + 1) * sblock->fs_bsize > np->allocsize) ? np->allocsize - i * sblock->fs_bsize : sblock->fs_bsize); + start <<= log2_dev_blocks_per_dev_bsize; + length <<= log2_dev_blocks_per_dev_bsize; if (num_runs == 0 || run->start + run->length != start) *run++ = (struct store_run){ start, length }; else -- cgit v1.2.3 From cb252fa897afb4adb1b6a2a52c6573cb20328f6a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:25:28 +0000 Subject: (log2_dev_blocks_per_bsize): New declaration. --- ufs/ufs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index db2cf12b..1c44e5f5 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -130,6 +130,8 @@ int direct_symlink_extension; /* If this is set, then the disk is byteswapped from native order. */ int swab_disk; +/* Number of device blocks per DEV_BSIZE block. */ +unsigned log2_dev_blocks_per_dev_bsize; /* Handy macros */ #define DEV_BSIZE 512 -- cgit v1.2.3 From 8525a4a02951672e3938d03a95f10dc5fc57aa51 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:26:29 +0000 Subject: (log2_dev_blocks_per_bsize): New variable. (main): Only require device-block-size to be <= DEV_BSIZE. Get rid of device-block-size-is-power-of-2 check. Set LOG2_DEV_BLOCKS_PER_BSIZE. Exit with an error if the disk is too small rather than assert failing. --- ufs/main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index f0ffa3f5..61531c22 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -36,6 +36,9 @@ struct store_parsed *store_parsed = 0; char *diskfs_disk_name = 0; +/* Number of device blocks per DEV_BSIZE block. */ +unsigned log2_dev_blocks_per_dev_bsize = 0; + /* Set diskfs_root_node to the root inode. */ static void warp_root (void) @@ -190,14 +193,17 @@ main (int argc, char **argv) if (err) error (3, err, "%s", diskfs_disk_name); - if (store->block_size != DEV_BSIZE) - error (4, err, "%s: Bad device record size %d (should be %d)", + if (store->block_size > DEV_BSIZE) + error (4, err, "%s: Bad device block size %d (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); - if (store->log2_block_size == 0) - error (4, err, "%s: Device block size (%d) not a power of 2", - diskfs_disk_name, store->block_size); - - assert (store->size >= SBSIZE + SBOFF); + if (store->size < SBSIZE + SBOFF) + error (5, 0, "%s: Disk too small (%ld bytes)", diskfs_disk_name, + store->size); + + log2_dev_blocks_per_dev_bsize = 0; + while ((1 << log2_dev_blocks_per_dev_bsize) < DEV_BSIZE) + log2_dev_blocks_per_dev_bsize++; + log2_dev_blocks_per_dev_bsize -= store->log2_block_size; /* Map the entire disk. */ create_disk_pager (); -- cgit v1.2.3 From 50c06c73760f1d10924fe8e83b5d2633e9b2bad0 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:27:16 +0000 Subject: . --- ufs/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 323da685..debab075 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,17 @@ +1997-06-20 Miles Bader + + * hyper.c (diskfs_set_hypermetadata): Adjust device addresses for + possible differences between DEV_BSIZE & device block size. + * inode.c (diskfs_S_file_get_storage_info): Likewise. + * pager.c (pager_read_page, pager_write_page, pager_unlock_page): + Likewise. + * ufs.h (log2_dev_blocks_per_bsize): New declaration. + * main.c (main): Only require device-block-size to be <= DEV_BSIZE. + Get rid of device-block-size-is-power-of-2 check. + Set LOG2_DEV_BLOCKS_PER_BSIZE. + Exit with an error if the disk is too small rather than assert failing. + (log2_dev_blocks_per_bsize): New variable. + Thu Feb 6 01:56:27 1997 Miles Bader (diskfs_S_file_getfh, diskfs_S_fsys_getfile): Functions removed. -- cgit v1.2.3 From b1d444e7e11450dff9321706a2ae88af4a1c784b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:34:41 +0000 Subject: (diskfs_set_hypermetadata): Adjust device addresses for possible differences between DEV_BSIZE & device block size. --- ufs/hyper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ufs/hyper.c b/ufs/hyper.c index 052bc220..500934eb 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -1,5 +1,5 @@ /* Fetching and storing the hypermetadata (superblock and cg summary info). - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -292,8 +292,10 @@ diskfs_set_hypermetadata (int wait, int clean) size_t read = 0; size_t bufsize = round_page (fragroundup (sblock, sblock->fs_cssize)); - err = store_read (store, fsbtodb (sblock, sblock->fs_csaddr), bufsize, - &buf, &read); + err = store_read (store, + fsbtodb (sblock, sblock->fs_csaddr) + << log2_dev_blocks_per_dev_bsize, + bufsize, &buf, &read); if (err) return err; else if (read != bufsize) @@ -304,7 +306,9 @@ diskfs_set_hypermetadata (int wait, int clean) bcopy (csum, buf, sblock->fs_cssize); if (swab_disk) swab_csums ((struct csum *)buf); - err = store_write (store, fsbtodb (sblock, sblock->fs_csaddr), + err = store_write (store, + fsbtodb (sblock, sblock->fs_csaddr) + << log2_dev_blocks_per_dev_bsize, buf, bufsize, &wrote); if (!err && wrote != bufsize) err = EIO; -- cgit v1.2.3 From 5bcdfac58a18134e87b40153bb501d6b3fced484 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 20 Jun 1997 19:49:11 +0000 Subject: Fri Jun 20 15:37:15 1997 Thomas Bushnell, n/BSG * bootstrap.c (main/script_paging_file): Instead of returning an error use new variable `had_a_partition' to record whether we successfully opened a partition. (main/script_default_pager): Only start pager if HAD_A_PARTITION; otherwise print warning message. Mon Jun 16 11:52:40 1997 Thomas Bushnell, n/BSG * Makefile (installationdir): Use `=' to set this instead of :=; $(prefix) is not yet available and `=' postpones the evaluation properly. Reported by Marcus G. Daniels, marcus@cathcart.sysc.pdx.edu. --- serverboot/ChangeLog | 15 +++++++++++++++ serverboot/Makefile | 2 +- serverboot/bootstrap.c | 18 +++++++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 79b9c123..01b8065b 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,18 @@ +Fri Jun 20 15:37:15 1997 Thomas Bushnell, n/BSG + + * bootstrap.c (main/script_paging_file): Instead of returning an + error use new variable `had_a_partition' to record whether we + successfully opened a partition. + (main/script_default_pager): Only start pager if HAD_A_PARTITION; + otherwise print warning message. + +Mon Jun 16 11:52:40 1997 Thomas Bushnell, n/BSG + + * Makefile (installationdir): Use `=' to set this instead of :=; + $(prefix) is not yet available and `=' postpones the evaluation + properly. Reported by Marcus G. Daniels, + marcus@cathcart.sysc.pdx.edu. + Tue Jun 10 21:54:52 1997 Thomas Bushnell, n/BSG * disk_inode.h (struct icommon): Use short instead of uid_t/gid_t diff --git a/serverboot/Makefile b/serverboot/Makefile index bb5553fa..ebb0b8be 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -30,7 +30,7 @@ LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.h \ disk_inode.h file_io.h minix_super.h translate_root.h mach-exec.h target = serverboot HURDLIBS = threads -installationdir := $(prefix)/boot +installationdir = $(prefix)/boot vpath boot_script.c $(srcdir)/../boot diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index d238e8bb..5a104bf7 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -139,19 +139,23 @@ main(argc, argv) char **argv; { int doing_default_pager = 0; + int had_a_partition = 0; int script_paging_file (const struct cmd *cmd, int *val) { if (add_paging_file (bootstrap_master_device_port, cmd->path)) - { - printf ("(bootstrap): %s: Cannot add paging file\n", cmd->path); - return BOOT_SCRIPT_MACH_ERROR; - } - return 0; + printf ("(bootstrap): %s: Cannot add paging file\n", cmd->path); + else + had_a_partition = 1; } int script_default_pager (const struct cmd *cmd, int *val) { - default_pager_initialize(bootstrap_master_host_port); - doing_default_pager = 1; + if (had_a_partition) + { + default_pager_initialize(bootstrap_master_host_port); + doing_default_pager = 1; + } + else + printf ("(bootstrap): Running without any paging\n"); return 0; } -- cgit v1.2.3 From e94252fe692a5638429cbe4fdf9e2a37c3a7b2bb Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 23 Jun 1997 17:35:12 +0000 Subject: *** empty log message *** --- ufs/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index 61531c22..e6a7e303 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -223,6 +223,8 @@ main (int argc, char **argv) outside world. */ diskfs_startup_diskfs (bootstrap, 0); + /* SET HOST NAME */ + /* And this thread is done with its work. */ cthread_exit (0); -- cgit v1.2.3 From 5846b573b26adc645606225d38f883dc0dc36b47 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 23 Jun 1997 17:35:37 +0000 Subject: Fri Jun 20 13:39:02 1997 Thomas Bushnell, n/BSG * mkfs.c (mkfs): Set SBLOCK.fs_clean. New file systems are always clean. --- ufs-utils/ChangeLog | 5 +++++ ufs-utils/mkfs.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 656a25ec..997bb089 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +Fri Jun 20 13:39:02 1997 Thomas Bushnell, n/BSG + + * mkfs.c (mkfs): Set SBLOCK.fs_clean. New file systems are always + clean. + Thu Apr 10 13:54:31 1997 Thomas Bushnell, n/BSG * dlabel.c: Don't include . diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index b6303e86..5770293a 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.16 1997/02/20 04:15:02 miles Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.17 1997/06/23 17:35:37 thomas Exp $"; #endif /* not lint */ #include @@ -863,6 +863,7 @@ next: sblock.fs_cstotal.cs_nffree = 0; sblock.fs_fmod = 0; sblock.fs_ronly = 0; + sblock.fs_clean = 1; /* * Dump out summary information about file system. -- cgit v1.2.3 From b3c14dc05fa82774cd9e83233ba5c4f66b076ba4 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 30 Jun 1997 21:59:32 +0000 Subject: Mon Jun 30 17:38:57 1997 Thomas Bushnell, n/BSG * main.c (main): If the store cannot be made writable, then set diskfs_hard_readonly and diskfs_readonly. --- ufs/ChangeLog | 5 +++++ ufs/main.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index debab075..ca832c8e 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 30 17:38:57 1997 Thomas Bushnell, n/BSG + + * main.c (main): If the store cannot be made writable, then set + diskfs_hard_readonly and diskfs_readonly. + 1997-06-20 Miles Bader * hyper.c (diskfs_set_hypermetadata): Adjust device addresses for diff --git a/ufs/main.c b/ufs/main.c index e6a7e303..6116792b 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -205,6 +205,9 @@ main (int argc, char **argv) log2_dev_blocks_per_dev_bsize++; log2_dev_blocks_per_dev_bsize -= store->log2_block_size; + if (store->flags & STORE_HARD_READONLY) + diskfs_readonly = diskfs_hard_readonly = 1; + /* Map the entire disk. */ create_disk_pager (); -- cgit v1.2.3 From 7d435aab2c0aea9ee54250a3b2ce750ad6acd0f5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 8 Jul 1997 22:39:36 +0000 Subject: (SRCS): Remove translate_root.c. (LCLHDRS): Remove translate_root.h. --- serverboot/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serverboot/Makefile b/serverboot/Makefile index ebb0b8be..12ff6375 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -21,13 +21,13 @@ makemode := utility SRCS = bootstrap.c ffs_compat.c load.c wiring.c def_pager_setup.c \ ffs_file_io.c minix_ffs_compat.c default_pager.c file_io.c\ minix_file_io.c ext2_file_io.c kalloc.c strfcns.c exec.c \ - translate_root.c panic.c elf-load.c + panic.c elf-load.c OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ default_pagerServer.o excServer.o bootstrapServer.o \ memory_object_defaultServer.o LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.h \ minix_ffs_compat.h wiring.h dir.h ffs_compat.h minix_fs.h \ - disk_inode.h file_io.h minix_super.h translate_root.h mach-exec.h + disk_inode.h file_io.h minix_super.h mach-exec.h target = serverboot HURDLIBS = threads installationdir = $(prefix)/boot -- cgit v1.2.3 From 6e8b197f0670db36e886ffc027215505ae7684df Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 8 Jul 1997 22:40:01 +0000 Subject: (safe_gets): Make sure a newline exists before removing it. Ensure that the cursor moves to the beginning of the next line. (main): Don't call translate_root. Pass more than a single character to safe_gets. (DEFAULT_ROOT): New macro. Don't include "translate_root.h". --- serverboot/bootstrap.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 5a104bf7..fd69f5d9 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -35,7 +35,10 @@ #include #include "../boot/boot_script.h" -#include "translate_root.h" + +/* Use this device if no root specified. */ +#define DEFAULT_ROOT "hd0a" + #if 0 /* @@ -114,7 +117,9 @@ safe_gets (char *str, int maxlen) { char *c; c = index (fgets (str, maxlen, stdin), '\n'); - *c = '\0'; + if (c) + *c = '\0'; + printf ("\r\n"); } printf_init (device_t master) @@ -168,8 +173,6 @@ main(argc, argv) boolean_t ask_boot_script = 0; - static char new_root[16]; - /* * Use 4Kbyte cthread wait stacks. */ @@ -232,14 +235,14 @@ main(argc, argv) */ if (index(flag_string, 'a')) { - printf("root device? [%s] ", root_name); - safe_gets(new_root, sizeof(new_root)); - } + static char new_root[16]; - if (new_root[0] == '\0') - strcpy(new_root, root_name); + printf("root device? [%s] ", root_name); + safe_gets(new_root, sizeof(new_root)); - root_name = translate_root(new_root); + if (new_root[0] != '\0') + strcpy (root_name, new_root); + } (void) strbuild(boot_script_name, "/dev/", @@ -323,9 +326,9 @@ main(argc, argv) if (index (flag_string, 'd')) { - char c; + char xx[5]; printf ("Hit return to boot..."); - safe_gets (&c, 1); + safe_gets (xx, sizeof xx); } /* -- cgit v1.2.3 From 87644e75e5e95a6327b354f1bc722ab901d25618 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 8 Jul 1997 22:40:25 +0000 Subject: . --- serverboot/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 01b8065b..034e06c1 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,15 @@ +1997-07-08 Miles Bader + + * bootstrap.c: Don't include "translate_root.h". + (main): Don't call translate_root. + Pass more than a single character to safe_gets. + (DEFAULT_ROOT): New macro. + (safe_gets): Make sure a newline exists before removing it. + Ensure that the cursor moves to the beginning of the next line. + * translate_root.c, translate_root.h: Files removed. + * Makefile (SRCS): Remove translate_root.c. + (LCLHDRS): Remove translate_root.h. + Fri Jun 20 15:37:15 1997 Thomas Bushnell, n/BSG * bootstrap.c (main/script_paging_file): Instead of returning an -- cgit v1.2.3 From 745d89448eb5c78fe17bb4cb1305f5713c107b3b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 8 Jul 1997 22:40:52 +0000 Subject: Not used anymore --- serverboot/translate_root.c | 124 -------------------------------------------- serverboot/translate_root.h | 41 --------------- 2 files changed, 165 deletions(-) delete mode 100644 serverboot/translate_root.c delete mode 100644 serverboot/translate_root.h diff --git a/serverboot/translate_root.c b/serverboot/translate_root.c deleted file mode 100644 index b544d5c8..00000000 --- a/serverboot/translate_root.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 1995 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: Stephen Clawson, University of Utah CSL - */ - - -#include "translate_root.h" - -unsigned int atoh(ap) - char *ap; -{ - register char *p; - register unsigned int n; - register int digit,lcase; - - p = ap; - n = 0; - while(*p == ' ') - p++; - while ((digit = (*p >= '0' && *p <= '9')) || - (lcase = (*p >= 'a' && *p <= 'f')) || - (*p >= 'A' && *p <= 'F')) { - n *= 16; - if (digit) n += *p++ - '0'; - else if (lcase) n += 10 + (*p++ - 'a'); - else n += 10 + (*p++ - 'A'); - } - return(n); -} - -/* - * Translate the root device from whatever strange encoding we might - * be given. Currently that includes BSD's slightly different name - * for IDE devices, and Linux's device number encoding (since that's - * what LILO passes us, for whatever reason). - */ -char * -translate_root(root_string) - char *root_string; -{ - int linuxdev = atoh(root_string); - - /* LILO passes us a string representing the linux device number of - * our root device. Since this is _not_ what we want, we'll make - * a stab at converting it. - * - * Linux major numbers we care about: - * - * 2 = fd - * 3 = hd[ab] (IDE channel 1) - * 8 = sd - * 22 = hd[cd] (IDE channel 2) - * - */ - if (linuxdev) { - if (LINUX_MAJOR(linuxdev) == 2) { - root_string[0] = 'f'; - root_string[1] = 'd'; - root_string[2] = LINUX_FD_DEVICE_NR(linuxdev) + '0'; - root_string[3] = '\0'; - } else { - int shift; - - switch (LINUX_MAJOR(linuxdev)) { - case 3: - case 22: - shift = 6; - root_string[0] = 'h'; - break; - case 8: - shift = 4; - root_string[0] = 's'; - break; - default: - printf("Unknown linux device" - "(major = %d, minor = %d) passed as " - "root argument!\n" - "using hd0a as default.\n", - LINUX_MAJOR(linuxdev), - LINUX_MINOR(linuxdev)); - shift = 1; - root_string[0] = 'h'; - linuxdev = 1; - } - - root_string[1] = 'd'; - root_string[2] = LINUX_DEVICE_NR(linuxdev, shift)+'0'; - root_string[3] = LINUX_PARTN(linuxdev, shift)+'a' - 1; - root_string[4] = '\0'; - } - } else - /* This could be handled much simpler in the BSD boot - * adapter code, but baford insists that the boot - * adapter code shouldn't be tainted by Mach's notion - * of the `correct' device naming. Thus, we get wdxx - * instead of hdxx if booted from the BSD bootblocks, - * and this is the lame hack that tries to convert it. - */ - if (root_string[0] == 'w' && root_string[1] == 'd') - root_string[0] = 'h'; - - return root_string; -} - - - diff --git a/serverboot/translate_root.h b/serverboot/translate_root.h deleted file mode 100644 index e5bab70a..00000000 --- a/serverboot/translate_root.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1995 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: Stephen Clawson, University of Utah CSL - */ - -#ifndef _TRANSLATE_ROOT_H_ -#define _TRANSLATE_ROOT_H_ - -#define DEFAULT_ROOT "hd0a" - -extern char *translate_root(char *); - -#define LINUX_MAJOR(a) (int)((unsigned short)(a) >> 8) -#define LINUX_MINOR(a) (int)((unsigned short)(a) & 0xFF) - -#define LINUX_PARTN(device, shift) \ - (LINUX_MINOR(device) & ((1 << (shift)) - 1)) -#define LINUX_DEVICE_NR(device, shift) \ - (LINUX_MINOR(device) >> (shift)) -#define LINUX_FD_DEVICE_NR(device) \ - ( ((device) & 3) | (((device) & 0x80 ) >> 5 )) - -#endif /* _TRANSLATE_ROOT_H_ */ -- cgit v1.2.3 From 82533a1bdee3be7e2bf5666d0ce2a29ccc9f4f56 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 9 Jul 1997 20:20:03 +0000 Subject: (main): Don't exit if no paging partition. --- serverboot/bootstrap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index fd69f5d9..680b6b04 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -389,8 +389,10 @@ main(argc, argv) } #endif +#if 0 /* Always stick around to handle swapon requests */ if (! doing_default_pager) task_terminate (mach_task_self ()); +#endif /* * Become the default pager -- cgit v1.2.3 From 499032ae469aa2c3ffa13ff877891e625dcee137 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 9 Jul 1997 20:23:25 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 034e06c1..9805e082 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +1997-07-09 Miles Bader + + * bootstrap.c (main): Don't exit when no paging partition. + 1997-07-08 Miles Bader * bootstrap.c: Don't include "translate_root.h". -- cgit v1.2.3 From dfaca19f19b2b5f3773a806c65dc3bae1ed865c5 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 15 Jul 1997 22:32:41 +0000 Subject: (boot_script_exec_cmd): Change "(bootstrap)" to "(serverboot)" in msgs. --- serverboot/load.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serverboot/load.c b/serverboot/load.c index 36e8307b..a4bb43c3 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -217,9 +217,9 @@ boot_script_exec_cmd (task_t user_task, st.aout_strtab_size = 0; result = exec_load(prog_read, prog_read_exec, &st, &info); if (result) - panic("(bootstrap) exec_load %s: error %d", namebuf, result); + panic("(serverboot) exec_load %s: error %d", namebuf, result); #if 0 - printf("(bootstrap): loaded %s; entrypoint %08x\n", namebuf, info.entry); + printf("(serverboot): loaded %s; entrypoint %08x\n", namebuf, info.entry); #endif /* @@ -234,7 +234,7 @@ boot_script_exec_cmd (task_t user_task, * Read symbols from the executable file. */ #if 0 - printf("(bootstrap): loading symbols from %s\n", namebuf); + printf("(serverboot): loading symbols from %s\n", namebuf); read_symtab_from_file(&file, bootstrap_master_host_port, user_task, namebuf, &st); #endif -- cgit v1.2.3 From ceb1b1c8ea96ce2453b9d54519d62cd059bd2ae9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 15 Jul 1997 22:56:20 +0000 Subject: (safe_gets): Use strchr instead of index. (main): Rearrange default pager initialization. Change "(bootstrap)" to "(serverboot)" in msgs. Include --- serverboot/bootstrap.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 680b6b04..fb4e0ccb 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -33,6 +33,7 @@ #include #include +#include #include "../boot/boot_script.h" @@ -116,7 +117,7 @@ void safe_gets (char *str, int maxlen) { char *c; - c = index (fgets (str, maxlen, stdin), '\n'); + c = strchr (fgets (str, maxlen, stdin), '\n'); if (c) *c = '\0'; printf ("\r\n"); @@ -148,19 +149,13 @@ main(argc, argv) int script_paging_file (const struct cmd *cmd, int *val) { if (add_paging_file (bootstrap_master_device_port, cmd->path)) - printf ("(bootstrap): %s: Cannot add paging file\n", cmd->path); + printf ("(serverboot): %s: Cannot add paging file\n", cmd->path); else had_a_partition = 1; } int script_default_pager (const struct cmd *cmd, int *val) { - if (had_a_partition) - { - default_pager_initialize(bootstrap_master_host_port); - doing_default_pager = 1; - } - else - printf ("(bootstrap): Running without any paging\n"); + doing_default_pager = 1; return 0; } @@ -389,16 +384,23 @@ main(argc, argv) } #endif + if (had_a_partition) + doing_default_pager = 1; + else + printf ("(serverboot): Running without any paging\n"); + #if 0 /* Always stick around to handle swapon requests */ - if (! doing_default_pager) - task_terminate (mach_task_self ()); + if (! doing_default_pager) + task_terminate (mach_task_self ()); #endif - /* - * Become the default pager - */ - default_pager(); - /*NOTREACHED*/ + default_pager_initialize (bootstrap_master_host_port); + + /* + * Become the default pager + */ + default_pager(); + /*NOTREACHED*/ } /* Parse the boot script. */ -- cgit v1.2.3 From 1381e9510c775d885af784bcaea3db26b18b5857 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 15 Jul 1997 22:58:09 +0000 Subject: . --- serverboot/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 9805e082..bb6d188a 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,13 @@ +1997-07-15 Miles Bader + + * bootstrap.c (main): Rearrange default pager initialization. + + * bootstrap.c (safe_gets): Use strchr instead of index. + : Include + + * bootstrap.c (main): Change "(bootstrap)" to "(serverboot)" in msgs. + * load.c (boot_script_exec_cmd): Likewise. + 1997-07-09 Miles Bader * bootstrap.c (main): Don't exit when no paging partition. -- cgit v1.2.3 From c6358909aa9e73d34a5da39e3ea945c9c07b9e1a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 20 Aug 1997 19:06:42 +0000 Subject: Wed Aug 20 14:34:24 1997 Thomas Bushnell, n/BSG * dir.c (diskfs_lookup_hard): Cope with error return from diskfs_get_filemap. * sizes.c (diskfs_grow): Likewise. * dir.c (diskfs_dirempty): Cope (poorly) with error return from diskfs_get_filemap. * sizes.c (diskfs_truncate): Likewise. (block_extended): Likewise. * pager.c (diskfs_get_filemap): If pager_create fails, return error to caller. --- ufs/ChangeLog | 13 +++++++++++++ ufs/dir.c | 11 ++++++++++- ufs/pager.c | 7 +++++++ ufs/sizes.c | 22 +++++++++++++++++----- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index ca832c8e..3a225552 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,16 @@ +Wed Aug 20 14:34:24 1997 Thomas Bushnell, n/BSG + + * dir.c (diskfs_lookup_hard): Cope with error return from + diskfs_get_filemap. + * sizes.c (diskfs_grow): Likewise. + * dir.c (diskfs_dirempty): Cope (poorly) with error return from + diskfs_get_filemap. + * sizes.c (diskfs_truncate): Likewise. + (block_extended): Likewise. + + * pager.c (diskfs_get_filemap): If pager_create fails, return + error to caller. + Mon Jun 30 17:38:57 1997 Thomas Bushnell, n/BSG * main.c (main): If the store cannot be made writable, then set diff --git a/ufs/dir.c b/ufs/dir.c index 6c44932d..bdf84be6 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -145,6 +145,10 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, /* Map in the directory contents. */ memobj = diskfs_get_filemap (dp, prot); + + if (memobj == MACH_PORT_NULL) + return errno; + buf = 0; /* We allow extra space in case we have to do an EXTEND. */ buflen = round_page (dp->dn_stat.st_size + DIRBLKSIZ); @@ -727,6 +731,11 @@ diskfs_dirempty(struct node *dp, error_t err; memobj = diskfs_get_filemap (dp, VM_PROT_READ); + + if (memobj == MACH_PORT_NULL) + /* XXX should reflect error properly */ + return 0; + buf = 0; err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, diff --git a/ufs/pager.c b/ufs/pager.c index afb34839..61695db6 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -569,6 +569,13 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) diskfs_nref_light (np); upi->p = pager_create (upi, pager_bucket, MAY_CACHE, MEMORY_OBJECT_COPY_DELAY); + if (upi->p == 0) + { + diskfs_nrele_light (np); + free (upi); + spin_unlock (&node2pagelock); + return MACH_PORT_NULL; + } np->dn->fileinfo = upi; right = pager_get_port (np->dn->fileinfo->p); ports_port_deref (np->dn->fileinfo->p); diff --git a/ufs/sizes.c b/ufs/sizes.c index 84c2493d..5c3d12f0 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -1,5 +1,5 @@ /* File growth and truncation - Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation This file is part of the GNU Hurd. @@ -104,10 +104,14 @@ diskfs_truncate (struct node *np, pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); - poke_pages (obj, round_page (length), round_page (np->allocsize)); - mach_port_deallocate (mach_task_self (), obj); - pager_flush_some (upi->p, round_page (length), - np->allocsize - length, 1); + if (obj != MACH_PORT_NULL) + { + /* XXX should cope with errors from diskfs_get_filemap */ + poke_pages (obj, round_page (length), round_page (np->allocsize)); + mach_port_deallocate (mach_task_self (), obj); + pager_flush_some (upi->p, round_page (length), + np->allocsize - length, 1); + } ports_port_deref (upi->p); } @@ -400,6 +404,11 @@ block_extended (struct node *np, /* Map in this part of the file */ mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ); + + /* XXX Should cope with errors from diskfs_get_filemap and back + out the operation here. */ + assert (mapobj); + err = vm_map (mach_task_self (), &mapaddr, round_page (old_size), 0, 1, mapobj, lbn * sblock->fs_bsize, 0, VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, 0); @@ -477,6 +486,9 @@ diskfs_grow (struct node *np, /* This reference will ensure that NP->dn->fileinfo stays allocated. */ pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ); + if (pagerpt == MACH_PORT_NULL) + return errno; + /* The new last block of the file. */ lbn = lblkno (sblock, end - 1); -- cgit v1.2.3 From b6b4205cbf0551528e954065d33b930a7355c0eb Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 23 Apr 1998 00:52:19 +0000 Subject: 1998-04-02 Gordon Matzigkeit * Makefile (srcdir): Don't set srcdir, since this is either done in the generated Makefile or in Makeconf. Just include ./Makeconf directly. * configure.in (makefiles): Check for $ac_unique_file, rather than doing string comparisons to determine if we are configured in the source directory. This works for silly things like `srcdir=./.'. --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 8f55c4c1..ff28fde5 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.11 1997/05/23 16:39:25 thomas Exp $]) +AC_REVISION([$Id: configure.in,v 1.12 1998/04/23 00:52:19 tb Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -48,7 +48,7 @@ LIBS="$LIBCRYPT $LIBS" AC_CHECK_FUNCS(crypt) LIBS="$_SAVE_LIBS" -if test $srcdir = .; then +if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. makefiles= else -- cgit v1.2.3 From 0c096a2f51a56c929a68d06f8f053faec86409fd Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 24 Apr 1998 19:47:37 +0000 Subject: *** empty log message *** --- libmom/mom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmom/mom.h b/libmom/mom.h index 75d4b08d..6d04f1d5 100644 --- a/libmom/mom.h +++ b/libmom/mom.h @@ -63,7 +63,7 @@ void mom_ref_destroy (struct mom_port_ref *obj); /* Memory management */ -/* Size of a physical page; mom memory management calls must be in +/* Size of a "physical" page; mom memory management calls must be in aligned multiples of this value. */ extern size_t mom_page_size; -- cgit v1.2.3 From 1a6f43dec4834aad6e3ed41dc52a912c8ff87e95 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 12 May 1998 17:15:17 +0000 Subject: Tue May 12 12:11:36 1998 Thomas Bushnell, n/BSG * bootstrap.c (parse_script): Free BUF before returning. Reported by Katusya Tanaka (wyvern@pb3.so-net.ne.jp). --- serverboot/ChangeLog | 5 +++++ serverboot/bootstrap.c | 1 + 2 files changed, 6 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index bb6d188a..8c20e4f0 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +Tue May 12 12:11:36 1998 Thomas Bushnell, n/BSG + + * bootstrap.c (parse_script): Free BUF before returning. Reported + by Katusya Tanaka (wyvern@pb3.so-net.ne.jp). + 1997-07-15 Miles Bader * bootstrap.c (main): Rearrange default pager initialization. diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index fb4e0ccb..3fa0f404 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -428,4 +428,5 @@ parse_script (struct file *f) line = ++p; } + free (buf); } -- cgit v1.2.3 From 9763c693eac4c288ee508aff493ff98cd7cdb6fe Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 20 Jul 1998 04:55:13 +0000 Subject: 1998-07-20 Roland McGrath * configure.in: Grok --{en,dis}able-profile, default enable. * config.make.in (build-profiled): New variable, from @enable_profile@. * Makeconf (no_prof): Set to t if $(build-profiled) is not no. --- configure.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index ff28fde5..1dad5b58 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.12 1998/04/23 00:52:19 tb Exp $]) +AC_REVISION([$Id: configure.in,v 1.13 1998/07/20 04:55:13 roland Exp $]) AC_PREREQ(2.4) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -19,6 +19,11 @@ i[[3456]]86) esac AC_SUBST(asm_syntax) +AC_ARG_ENABLE(profile, +[ --disable-profile do not build profiled libraries and programs],, + enable_profile=yes) +AC_SUBST(enable_profile) + AC_PROG_INSTALL AC_CHECK_TOOL(CC, gcc) -- cgit v1.2.3 From 84e55b0f8b7fe743eff6221de7c67efcac5b3345 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 25 Jul 1998 07:58:46 +0000 Subject: 1998-07-25 Roland McGrath * default_pager.c (pager_read_offset): Cast NO_BLOCK twice, to real return type of this function. --- serverboot/default_pager.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 302cf3f0..159cd576 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -689,7 +689,7 @@ pager_extend(pager, new_size) pager->writer = FALSE; #endif mutex_unlock(&pager->lock); - ddprintf ("pager_extend 1 mapptr %x [3b] = %x\n", new_mapptr, + ddprintf ("pager_extend 1 mapptr %x [3b] = %x\n", new_mapptr, new_mapptr[0x3b]); if (new_mapptr[0x3b].indirect > 0x10000 && new_mapptr[0x3b].indirect != NO_BLOCK) @@ -717,7 +717,7 @@ pager_extend(pager, new_size) kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); old_mapptr = new_mapptr; - ddprintf ("pager_extend 2 mapptr %x [3b] = %x\n", new_mapptr, + ddprintf ("pager_extend 2 mapptr %x [3b] = %x\n", new_mapptr, new_mapptr[0x3b]); if (new_mapptr[0x3b].indirect > 0x10000 && new_mapptr[0x3b].indirect != NO_BLOCK) @@ -819,7 +819,7 @@ pager_read_offset(pager, offset) { ddprintf ("%spager_read_offset pager %x: bad page %d >= size %d", my_name, pager, f_page, pager->size); - return (union dp_map *) NO_BLOCK; + return (union dp_map) (union dp_map *) NO_BLOCK; #if 0 panic("%spager_read_offset",my_name); #endif @@ -1082,7 +1082,7 @@ pager_write_offset(pager, offset) while (f_page >= pager->size) { ddprintf ("pager_write_offset: extending: %x %x\n", f_page, pager->size); - + /* * Paging object must be extended. * Remember that offset is 0-based, but size is 1-based. @@ -1192,11 +1192,11 @@ 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, + ddprintf ("pager_write_offset: mapptr %x [3b] = %x\n", mapptr, mapptr[0x3b]); ddprintf ("pager_write_offset: block is finally %x\n", block); } - + out: #if DEBUG_READER_CONFLICTS @@ -1431,7 +1431,7 @@ default_write(ds, addr, size, offset) register int rc; ddprintf ("default_write: pager offset %x\n", offset); - + /* * Find block in paging partition */ @@ -2454,7 +2454,7 @@ ddprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err); 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); @@ -2464,7 +2464,7 @@ ddprintf ("seqnos_memory_object_data_write <%p>: 3\n", &err); 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); @@ -2513,10 +2513,10 @@ 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); -- cgit v1.2.3 From e6317fbbb4e43225250b1ac2b9827c3e6d8c7fb9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 25 Jul 1998 08:00:16 +0000 Subject: . --- serverboot/ChangeLog | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 8c20e4f0..1ae6ff1e 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1998-07-25 Roland McGrath + + * default_pager.c (pager_read_offset): Cast NO_BLOCK twice, to real + return type of this function. + Tue May 12 12:11:36 1998 Thomas Bushnell, n/BSG * bootstrap.c (parse_script): Free BUF before returning. Reported @@ -42,13 +47,13 @@ Mon Jun 16 11:52:40 1997 Thomas Bushnell, n/BSG * Makefile (installationdir): Use `=' to set this instead of :=; $(prefix) is not yet available and `=' postpones the evaluation properly. Reported by Marcus G. Daniels, - marcus@cathcart.sysc.pdx.edu. + marcus@cathcart.sysc.pdx.edu. Tue Jun 10 21:54:52 1997 Thomas Bushnell, n/BSG * disk_inode.h (struct icommon): Use short instead of uid_t/gid_t in structure definition; those are now 32 bit types. - + * bootstrap.c (main): Support running from command line too; this is useful at least for simple debugging. @@ -95,7 +100,7 @@ Thu Apr 3 20:00:58 1997 Thomas Bushnell, n/BSG * elf-load.c (exec_load): Include instead of . Include "mach-exec.h" instead of - . + . (exec_load) [i386]: Check for i386 types directly; abandon old MY_EI_DATA and MY_E_MACHINE. * load.c: Include "mach-exec.h" instead of . @@ -110,10 +115,10 @@ Wed Mar 19 14:45:27 1997 Thomas Bushnell, n/BSG Mon Mar 17 13:13:50 1997 Thomas Bushnell, n/BSG * wiring.c (wire_all_memory): Don't attempt wire if PROTECTION is - VM_PROT_NONE. + VM_PROT_NONE. * panic.c (panic): Be more informative about where the error is - coming from. + coming from. * default_pager.c (create_paging_partition): Don't print gratuitous output noise. @@ -122,7 +127,7 @@ Mon Mar 17 13:13:50 1997 Thomas Bushnell, n/BSG Wed Mar 12 10:53:00 1997 Thomas Bushnell, n/BSG * ext2_file_io.c (ext2_open_file): Clear FP before beginning - work. + work. * ffs_file_io.c (ffs_open_file): Likewise. * minix_file_io.c (minix_open_file): Likewise. @@ -136,14 +141,14 @@ Wed Mar 12 10:53:00 1997 Thomas Bushnell, n/BSG * defs.h: Comment out redefinitions of common types. * default_pager.c: Include instead of - . + . * file_io.h: Likewise. * kalloc.c: Likewise. * panic.c: Include instead of . * default_pager.c (pager_read_offset): Cast return of NO_BLOCK - properly. + properly. Mon Mar 10 17:07:50 1997 Thomas Bushnell, n/BSG @@ -154,4 +159,3 @@ Mon Mar 10 17:07:50 1997 Thomas Bushnell, n/BSG * strfcns.c: Include instead of . * load.c: Likewise. - -- cgit v1.2.3 From 908fcafdfb95fb87a022200e3f9644174f959faa Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 12 Aug 1998 20:56:17 +0000 Subject: 1998-08-12 Roland McGrath * aclocal.m4 (AC_PROG_CC_LOCAL): Renamed to hurd_PROG_CC. (AC_PROG_CC_WORKS_LOCAL): Renamed to hurd_PROG_CC_WORKS. * configure.in: Use hurd_PROG_CC instead of AC_PROG_CC_LOCAL. (AC_PREREQ): Require 2.12. (AC_CANONICAL_HOST): Give helpful error messages for likely cases of bogus host specs. (crypt check): Don't do AC_CHECK_FUNCS to get HAVE_CRYPT, just check for -lcrypt to set $LIBCRYPT. --- configure.in | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/configure.in b/configure.in index 1dad5b58..64960998 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.13 1998/07/20 04:55:13 roland Exp $]) -AC_PREREQ(2.4) dnl Minimum Autoconf version required. +AC_REVISION([$Id: configure.in,v 1.14 1998/08/12 20:56:17 roland Exp $]) +AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local. @@ -8,14 +8,20 @@ AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local. AC_CANONICAL_HOST case "$host_os" in gnu*) ;; -*) AC_MSG_ERROR([sorry, this is the gnu os, not $host_os]) ;; +none) AC_MSG_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.]) ;; +*) AC_MSG_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.]) ;; esac case "$host_cpu" in -i[[3456]]86) - asm_syntax=i386 - ;; -*) AC_MSG_ERROR([unspported CPU type]) ;; +i?86) asm_syntax=i386 ;; +*) AC_MSG_ERROR([unsupported CPU type]) ;; esac AC_SUBST(asm_syntax) @@ -29,7 +35,7 @@ AC_PROG_INSTALL AC_CHECK_TOOL(CC, gcc) # That check handles cross-compilation well, but AC_PROG_CC tests for GCC # and sets default CFLAGS nicely for us, so do that too. -AC_PROG_CC_LOCAL +hurd_PROG_CC # Require GCC. if test x$GCC != xyes; then AC_MSG_ERROR([this code uses GNU C extensions, you must compile with GCC]) @@ -44,14 +50,9 @@ AC_CHECK_TOOL(MIG, mig) dnl Let these propagate from the environment. AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) -# See if there's a separate libcrypt (many systems put crypt there) +# See if there's a separate libcrypt (many systems put crypt there). AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) AC_SUBST(LIBCRYPT) -# Look for the crypt function itself (in libcrypt if possible) -_SAVE_LIBS="$LIBS" -LIBS="$LIBCRYPT $LIBS" -AC_CHECK_FUNCS(crypt) -LIBS="$_SAVE_LIBS" if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. -- cgit v1.2.3 From 291dcfb19c661c9f91e015ad9beb39aac737926b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Oct 1998 09:48:26 +0000 Subject: Add braces to silence gcc warnings. --- ufs-utils/ChangeLog | 9 ++++++--- ufs-utils/mkfs.c | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 997bb089..9e402e66 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,7 @@ +1998-09-04 Roland McGrath + + * mkfs.c (main): Fix return type to int, use return. + Fri Jun 20 13:39:02 1997 Thomas Bushnell, n/BSG * mkfs.c (mkfs): Set SBLOCK.fs_clean. New file systems are always @@ -100,7 +104,7 @@ Thu Nov 24 18:39:30 1994 Roland McGrath Wed Oct 12 12:59:01 1994 Michael I Bushnell - * mkfs.c (main): MAXCONTIG should be zero because we don't + * mkfs.c (main): MAXCONTIG should be zero because we don't do clustering. Fri Sep 9 09:45:23 1994 Michael I Bushnell @@ -117,7 +121,7 @@ Fri Sep 9 09:45:23 1994 Michael I Bushnell (main): Comment out check for already-mounted partition. (main): Comment out MFS specific open of FSI. - * mkfs.c (fsinit): Use DI_MODE to read mode from NODE, and + * mkfs.c (fsinit): Use DI_MODE to read mode from NODE, and set di_model and di_modeh instead of di_mode. (mkfs): Don't set fields in *PP. @@ -129,4 +133,3 @@ Thu Sep 8 15:52:05 1994 Michael I Bushnell * mkfs.c: Include ufs header files with "../ufs/foo.h" instead of . Don't include . - diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 5770293a..e8513b70 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.17 1997/06/23 17:35:37 thomas Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.18 1998/10/20 09:46:39 roland Exp $"; #endif /* not lint */ #include @@ -63,7 +63,7 @@ static char *rcsid = "$Id: mkfs.c,v 1.17 1997/06/23 17:35:37 thomas Exp $"; /* Begin misc additions for GNU Hurd */ -/* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD +/* For GNU Hurd: the ufs DIRSIZ macro is different than the BSD 4.4 version that mkfs expects. So we provide here the BSD version. */ #undef DIRSIZ #if (BYTE_ORDER == LITTLE_ENDIAN) @@ -174,22 +174,22 @@ static const struct argp_option options[] = { {"just-print", 'N', 0, 0, "Just print the file system parameters that would be used"}, {"old-format", 'O', 0, 0, "Create a 4.3BSD format filesystem"}, - {"max-contig", 'a', "BLOCKS", 0, + {"max-contig", 'a', "BLOCKS", 0, "The maximum number of contiguous blocks that will be laid out before" " forcing a rotational delay; the default is no limit"}, {"block-size", 'b', "BYTES", 0, "The block size of the file system"}, {"group-cylinders", 'c', "N", 0, "The number of cylinders per cylinder group; the default 16"}, - {"rot-delay", 'd', "MSEC", 0, + {"rot-delay", 'd', "MSEC", 0, "The expected time to service a transfer completion interrupt and" " initiate a new transfer on the same disk; the default is 0"}, - {"max-bpg", 'e', "BLOCKS", 0, + {"max-bpg", 'e', "BLOCKS", 0, "Maximum number of blocks any single file can allocate out of a cylinder" " group before it is forced to begin allocating blocks from another" " cylinder group; the default is about one quarter of the total blocks" " in a cylinder group"}, {"frag-size", 'f', "BYTES", 0, "The fragment size"}, - {"inode-density", 'i', "BYTES", 0, + {"inode-density", 'i', "BYTES", 0, "The density of inodes in the file system, in bytes of data space per" " inode; the default is one inode per 4 filesystem frags"}, {"minfree", 'm', "PERCENT", 0, @@ -211,7 +211,7 @@ static const struct argp_option options[] = { {"tracks", 't', "N", 0, "The number of tracks/cylinder"}, {"sectors", 'u', "N", 0, "The number of sectors per track (does not include sectors reserved for" - " bad block replacement"}, + " bad block replacement"}, {"spare-sectors", 'p', "N", 0, "Spare sectors (for bad sector replacement) at the end of each track"}, {"cyl-spare-sectors", 'x', "N", 0, @@ -261,7 +261,7 @@ char *device = 0; #define deverr(code, err, fmt, args...) \ error (code, err, "%s: " fmt, device , ##args) -void +int main (int argc, char **argv) { int fdo, fdi; @@ -277,7 +277,7 @@ main (int argc, char **argv) { case 'N': Nflag = 1; break; case 'O': Oflag = 1; break; - + /* Mark &VAR as being a uparam, and return a lvalue for VAR. */ #define UP(var) (amarks_add (&uparams, &var), var) /* Record an integer uparam into VAR. */ @@ -302,7 +302,7 @@ main (int argc, char **argv) case 'p': UP_INT (nspares); break; case 'x': UP_INT (ncspares); break; - case 'o': + case 'o': amarks_add (&uparams, &opt); if (strcmp (arg, "time") == 0) opt = FS_OPTTIME; @@ -413,7 +413,7 @@ main (int argc, char **argv) nphyssectors = nsectors + nspares; secpercyl = nsectors * ntracks; - + DEFAULT (rpm, DL_INT (0, d_rpm)); DEFAULT (interleave, DL_INT (0, d_interleave)); DEFAULT (trackskew, DL_SECS (0, d_trackskew)); @@ -422,7 +422,7 @@ main (int argc, char **argv) DEFAULT (fsize, 1024); DEFAULT (bsize, 8192); - + DEFAULT (cpg, 16); DEFAULT (minfree, MINFREE); DEFAULT (opt, DEFAULTOPT); @@ -439,7 +439,7 @@ main (int argc, char **argv) mkfs (0, device, fdi, fdo); - exit (0); + return 0; } void @@ -656,7 +656,7 @@ mkfs(pp, fsys, fi, fo) } else exit(23); - /* + /* * Calculate the number of cylinders per group */ sblock.fs_cpg = cpg; @@ -905,7 +905,7 @@ next: sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize, ((char *)fscs) + i); - /* + /* * Write out the duplicate super blocks */ for (cylno = 0; cylno < sblock.fs_ncg; cylno++) @@ -963,7 +963,7 @@ initcg(cylno, utime) acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; acg.cg_btotoff = &acg.cg_space[0] - (u_char *)(&acg.cg_link); acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(long); - acg.cg_iusedoff = acg.cg_boff + + acg.cg_iusedoff = acg.cg_boff + sblock.fs_cpg * sblock.fs_nrpos * sizeof(short); acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, NBBY); if (sblock.fs_contigsumsize <= 0) { -- cgit v1.2.3 From 0d3ef933e246eb5279b84b2dff6615698428f4c3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Oct 1998 19:20:07 +0000 Subject: 1998-09-04 Roland McGrath * dir.c (diskfs_lookup_hard): Fix defn with `const'. (diskfs_direnter_hard): Likewise. (dirscanblock): Likewise. * inode.c (diskfs_create_symlink_hook, create_symlink_hook): Likewise. (diskfs_set_translator): Likewise. --- ufs/dir.c | 172 ++++++++++++++++++++++++++++++------------------------------ ufs/inode.c | 98 +++++++++++++++++----------------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index bdf84be6..01432829 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1998 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 @@ -64,8 +64,8 @@ struct dirstat /* Index of this directory block. */ int idx; - - /* For stat COMPRESS, this is the address (inside mapbuf) + + /* For stat COMPRESS, this is the address (inside mapbuf) of the first direct in the directory block to be compressed. */ /* For stat HERE_TIS, SHRINK, and TAKE, this is the entry referenced. */ struct directory_entry *entry; @@ -82,21 +82,21 @@ struct dirstat size_t diskfs_dirstat_size = sizeof (struct dirstat); /* Initialize DS such that diskfs_drop_dirstat will ignore it. */ -void +void diskfs_null_dirstat (struct dirstat *ds) { ds->type = LOOKUP; } -static error_t -dirscanblock (vm_address_t blockoff, struct node *dp, int idx, char *name, - int namelen, enum lookup_type type, struct dirstat *ds, - ino_t *inum); +static error_t +dirscanblock (vm_address_t blockoff, struct node *dp, int idx, + const char *name, int namelen, enum lookup_type type, + struct dirstat *ds, ino_t *inum); /* Implement the diskfs_lookup from the diskfs library. See for the interface specification. */ error_t -diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, +diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, struct node **npp, struct dirstat *ds, struct protid *cred) { error_t err; @@ -113,7 +113,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, int blockaddr; int idx, lastidx; int looped; - + if ((type == REMOVE) || (type == RENAME)) assert (npp); @@ -122,12 +122,12 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, spec_dotdot = type & SPEC_DOTDOT; type &= ~SPEC_DOTDOT; - + namelen = strlen (name); if (namelen > MAXNAMLEN) return ENAMETOOLONG; - + try_again: if (ds) { @@ -157,10 +157,10 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, mach_port_deallocate (mach_task_self (), memobj); inum = 0; - + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; - + /* Start the lookup at DP->dn->dir_idx. */ idx = dp->dn->dir_idx; if (idx * DIRBLKSIZ > dp->dn_stat.st_size) @@ -221,7 +221,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, goto out; } } - + /* We are looking up .. */ /* Check to see if this is the root of the filesystem. */ else if (dp->dn->number == 2) @@ -229,7 +229,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, err = EAGAIN; goto out; } - + /* We can't just do diskfs_cached_lookup, because we would then deadlock. So we do this. Ick. */ else if (retry_dotdot) @@ -263,11 +263,11 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, retry_dotdot = inum; goto try_again; } - + /* Here below are the spec dotdot cases. */ else if (type == RENAME || type == REMOVE) np = ifind (inum); - + else if (type == LOOKUP) { diskfs_nput (dp); @@ -278,7 +278,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, else assert (0); } - + if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING) { /* We didn't find any room, so mark ds to extend the dir */ @@ -304,7 +304,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, ds->mapbuf = buf; ds->mapextent = buflen; } - + if (np) { assert (npp); @@ -338,8 +338,8 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, diskfs_lookup. If found, set *INUM to the inode number, else return ENOENT. */ static error_t -dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, - int namelen, enum lookup_type type, +dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, + const char *name, int namelen, enum lookup_type type, struct dirstat *ds, ino_t *inum) { int nfree = 0; @@ -351,7 +351,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, int looking = 0; int countcopies = 0; int consider_compress = 0; - + if (ds && (ds->stat == LOOKING || ds->stat == COMPRESS)) { @@ -365,11 +365,11 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, prevoff = currentoff, currentoff += read_disk_entry (entry->d_reclen)) { entry = (struct directory_entry *)currentoff; - + if (!entry->d_reclen || read_disk_entry (entry->d_reclen) % 4 || DIRECT_NAMLEN (entry) > MAXNAMLEN - || (currentoff + read_disk_entry (entry->d_reclen) + || (currentoff + read_disk_entry (entry->d_reclen) > blockaddr + DIRBLKSIZ) || entry->d_name[DIRECT_NAMLEN (entry)] || DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen) @@ -379,16 +379,16 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ); return ENOENT; } - + if (looking || countcopies) { int thisfree; - + /* Count how much free space this entry has in it. */ if (entry->d_ino == 0) thisfree = read_disk_entry (entry->d_reclen); else - thisfree = (read_disk_entry (entry->d_reclen) + thisfree = (read_disk_entry (entry->d_reclen) - DIRSIZ (DIRECT_NAMLEN (entry))); /* If this isn't at the front of the block, then it will @@ -396,9 +396,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, number of bytes there too. */ if (countcopies && currentoff != blockaddr) nbytes += DIRSIZ (DIRECT_NAMLEN (entry)); - + if (ds->stat == COMPRESS && nbytes > ds->nbytes) - /* The previously found compress is better than + /* The previously found compress is better than this one, so don't bother counting any more. */ countcopies = 0; @@ -415,9 +415,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, nfree += thisfree; if (nfree >= needed) consider_compress = 1; - } + } } - + if (entry->d_ino) nentries++; @@ -428,7 +428,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, break; } - if (consider_compress + if (consider_compress && (ds->type == LOOKING || (ds->type == COMPRESS && ds->nbytes > nbytes))) { @@ -438,7 +438,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, ds->idx = idx; ds->nbytes = nbytes; } - + if (currentoff >= blockaddr + DIRBLKSIZ) { int i; @@ -448,9 +448,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, down how many entries there were. */ if (!dp->dn->dirents) { - dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ) + dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ) * sizeof (int)); - for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++) + for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; } /* Make sure the count is correct if there is one now. */ @@ -460,7 +460,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, return ENOENT; } - + /* We have found the required name. */ if (ds && type == CREATE) @@ -486,7 +486,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name, the preceding lookup call, and only if that call returned ENOENT. */ error_t diskfs_direnter_hard(struct node *dp, - char *name, + const char *name, struct node *np, struct dirstat *ds, struct protid *cred) @@ -496,21 +496,21 @@ diskfs_direnter_hard(struct node *dp, int needed = DIRSIZ (namelen); int oldneeded; vm_address_t fromoff, tooff; - int totfreed; + int totfreed; error_t err; off_t oldsize = 0; assert (ds->type == CREATE); - + dp->dn_set_mtime = 1; switch (ds->stat) { case TAKE: /* We are supposed to consume this slot. */ - assert (ds->entry->d_ino == 0 + assert (ds->entry->d_ino == 0 && read_disk_entry (ds->entry->d_reclen) >= needed); - + write_disk_entry (ds->entry->d_ino, np->dn->number); DIRECT_NAMLEN (ds->entry) = namelen; if (direct_symlink_extension) @@ -518,27 +518,27 @@ diskfs_direnter_hard(struct node *dp, bcopy (name, ds->entry->d_name, namelen + 1); break; - + case SHRINK: /* We are supposed to take the extra space at the end of this slot. */ oldneeded = DIRSIZ (DIRECT_NAMLEN (ds->entry)); assert (read_disk_entry (ds->entry->d_reclen) - oldneeded >= needed); - + new = (struct directory_entry *) ((vm_address_t) ds->entry + oldneeded); write_disk_entry (new->d_ino, np->dn->number); - write_disk_entry (new->d_reclen, + write_disk_entry (new->d_reclen, read_disk_entry (ds->entry->d_reclen) - oldneeded); DIRECT_NAMLEN (new) = namelen; if (direct_symlink_extension) new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); - + write_disk_entry (ds->entry->d_reclen, oldneeded); - + break; - + case COMPRESS: /* We are supposed to move all the entries to the front of the block, giving each the minimum @@ -566,7 +566,7 @@ diskfs_direnter_hard(struct node *dp, totfreed = (vm_address_t) ds->entry + DIRBLKSIZ - tooff; assert (totfreed >= needed); - + new = (struct directory_entry *) tooff; write_disk_entry (new->d_ino, np->dn->number); write_disk_entry (new->d_reclen, totfreed); @@ -579,7 +579,7 @@ diskfs_direnter_hard(struct node *dp, case EXTEND: /* Extend the file. */ assert (needed <= DIRBLKSIZ); - + oldsize = dp->dn_stat.st_size; while (oldsize + DIRBLKSIZ > dp->allocsize) { @@ -603,7 +603,7 @@ diskfs_direnter_hard(struct node *dp, new->d_type = IFTODT (np->dn_stat.st_mode); bcopy (name, new->d_name, namelen + 1); break; - + default: assert (0); } @@ -611,10 +611,10 @@ diskfs_direnter_hard(struct node *dp, dp->dn_set_mtime = 1; vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); - + if (ds->stat != EXTEND) { - /* If we are keeping count of this block, then keep the count up + /* If we are keeping count of this block, then keep the count up to date. */ if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1) dp->dn->dirents[ds->idx]++; @@ -626,10 +626,10 @@ diskfs_direnter_hard(struct node *dp, anything at all. */ if (dp->dn->dirents) { - dp->dn->dirents = realloc (dp->dn->dirents, + dp->dn->dirents = realloc (dp->dn->dirents, (dp->dn_stat.st_size / DIRBLKSIZ * sizeof (int))); - for (i = oldsize / DIRBLKSIZ; + for (i = oldsize / DIRBLKSIZ; i < dp->dn_stat.st_size / DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; @@ -638,14 +638,14 @@ diskfs_direnter_hard(struct node *dp, } else { - dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ + dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ * sizeof (int)); for (i = 0; i < dp->dn_stat.st_size / DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; dp->dn->dirents[ds->idx] = 1; } } - + diskfs_file_update (dp, 1); return 0; @@ -662,7 +662,7 @@ diskfs_dirremove_hard(struct node *dp, { assert (ds->type == REMOVE); assert (ds->stat == HERE_TIS); - + dp->dn_set_mtime = 1; if (ds->preventry == 0) @@ -671,7 +671,7 @@ diskfs_dirremove_hard(struct node *dp, { assert ((vm_address_t) ds->entry - (vm_address_t) ds->preventry == read_disk_entry (ds->preventry->d_reclen)); - write_disk_entry (ds->preventry->d_reclen, + write_disk_entry (ds->preventry->d_reclen, (read_disk_entry (ds->preventry->d_reclen) + read_disk_entry (ds->entry->d_reclen))); } @@ -684,27 +684,27 @@ diskfs_dirremove_hard(struct node *dp, to date. */ if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1) dp->dn->dirents[ds->idx]--; - + diskfs_file_update (dp, 1); return 0; } - + /* Following a lookup call for RENAME, this changes the inode number - on a directory entry. DP is the directory being changed; NP is - the new node being linked in; DP is the cached information returned + on a directory entry. DP is the directory being changed; NP is + the new node being linked in; DP is the cached information returned by lookup. This call is only valid if the directory has been locked continuously since the call to lookup, and only if that call succeeded. */ error_t -diskfs_dirrewrite_hard(struct node *dp, +diskfs_dirrewrite_hard(struct node *dp, struct node *np, struct dirstat *ds) { assert (ds->type == RENAME); assert (ds->stat == HERE_TIS); - + dp->dn_set_mtime = 1; write_disk_entry (ds->entry->d_ino, np->dn->number); if (direct_symlink_extension) @@ -712,7 +712,7 @@ diskfs_dirrewrite_hard(struct node *dp, dp->dn_set_mtime = 1; vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); - + diskfs_file_update (dp, 1); return 0; @@ -737,7 +737,7 @@ diskfs_dirempty(struct node *dp, return 0; buf = 0; - + err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0, 1, memobj, 0, 0, VM_PROT_READ, VM_PROT_READ, 0); mach_port_deallocate (mach_task_self (), memobj); @@ -746,7 +746,7 @@ diskfs_dirempty(struct node *dp, if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; - for (curoff = buf; + for (curoff = buf; curoff < buf + dp->dn_stat.st_size; curoff += read_disk_entry (entry->d_reclen)) { @@ -766,7 +766,7 @@ diskfs_dirempty(struct node *dp, return 0; } } - if (!diskfs_check_readonly ()) + if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; if (diskfs_synchronous) diskfs_node_update (dp, 1); @@ -802,12 +802,12 @@ count_dirents (struct node *dp, int nb, char *buf) assert (dp->dn->dirents); assert ((nb + 1) * DIRBLKSIZ <= dp->dn_stat.st_size); - + err = diskfs_node_rdwr (dp, buf, nb * DIRBLKSIZ, DIRBLKSIZ, 0, 0, &amt); if (err) return err; assert (amt == DIRBLKSIZ); - + for (offinblk = buf; offinblk < buf + DIRBLKSIZ; offinblk += read_disk_entry (entry->d_reclen)) @@ -816,7 +816,7 @@ count_dirents (struct node *dp, int nb, char *buf) if (entry->d_ino) count++; } - + assert (dp->dn->dirents[nb] == -1 || dp->dn->dirents[nb] == count); dp->dn->dirents[nb] = count; return 0; @@ -825,8 +825,8 @@ count_dirents (struct node *dp, int nb, char *buf) /* Implement the disikfs_get_directs callback as described in . */ error_t -diskfs_get_directs (struct node *dp, - int entry, +diskfs_get_directs (struct node *dp, + int entry, int nentries, char **data, u_int *datacnt, @@ -846,7 +846,7 @@ diskfs_get_directs (struct node *dp, int allocsize; int checklen; struct dirent *userp; - + nblks = dp->dn_stat.st_size/DIRBLKSIZ; if (!dp->dn->dirents) @@ -864,7 +864,7 @@ diskfs_get_directs (struct node *dp, if (allocsize > *datacnt) vm_allocate (mach_task_self (), (vm_address_t *) data, allocsize, 1); - + /* Scan through the entries to find ENTRY. If we encounter a -1 in the process then stop to fill it. When we run off the end, ENTRY is too big. */ @@ -885,10 +885,10 @@ diskfs_get_directs (struct node *dp, break; curentry += dp->dn->dirents[blkno]; - + bufvalid = 0; } - + if (blkno == nblks) { *datacnt = 0; @@ -911,15 +911,15 @@ diskfs_get_directs (struct node *dp, assert (checklen == DIRBLKSIZ); bufvalid = 1; } - for (i = 0, bufp = buf; - i < entry - curentry && bufp - buf < DIRBLKSIZ; + for (i = 0, bufp = buf; + i < entry - curentry && bufp - buf < DIRBLKSIZ; (bufp - += read_disk_entry (((struct directory_entry *)bufp)->d_reclen)), + += read_disk_entry (((struct directory_entry *)bufp)->d_reclen)), i++) ; /* Make sure we didn't run off the end. */ assert (bufp - buf < DIRBLKSIZ); - } + } i = 0; datap = *data; @@ -931,7 +931,7 @@ diskfs_get_directs (struct node *dp, { if (!bufvalid) { - err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ, + err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ, 0, 0, &checklen); if (err) return err; @@ -962,17 +962,17 @@ diskfs_get_directs (struct node *dp, bufvalid = 0; } } - + /* We've copied all we can. If we allocated our own array but didn't fill all of it, then free whatever memory we didn't use. */ if (allocsize > *datacnt) { if (round_page (datap - *data) < allocsize) - vm_deallocate (mach_task_self (), + vm_deallocate (mach_task_self (), (vm_address_t) (*data + round_page (datap - *data)), allocsize - round_page (datap - *data)); } - + /* Set variables for return */ *datacnt = datap - *data; *amt = i; diff --git a/ufs/inode.c b/ufs/inode.c index fe5abbb9..658d6187 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1998 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 @@ -44,9 +44,9 @@ inode_init () nodehash[n] = 0; } -/* Fetch inode INUM, set *NPP to the node structure; +/* Fetch inode INUM, set *NPP to the node structure; gain one user reference and lock the node. */ -error_t +error_t diskfs_cached_lookup (int inum, struct node **npp) { struct disknode *dn; @@ -88,7 +88,7 @@ diskfs_cached_lookup (int inum, struct node **npp) spin_unlock (&diskfs_node_refcnt_lock); err = read_disknode (np); - + if (!diskfs_check_readonly () && !np->dn_stat.st_gen) { spin_lock (&gennumberlock); @@ -98,7 +98,7 @@ diskfs_cached_lookup (int inum, struct node **npp) spin_unlock (&gennumberlock); np->dn_set_ctime = 1; } - + if (err) return err; else @@ -114,13 +114,13 @@ struct node * ifind (ino_t inum) { struct node *np; - + spin_lock (&diskfs_node_refcnt_lock); for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext) { if (np->dn->number != inum) continue; - + assert (np->references); spin_unlock (&diskfs_node_refcnt_lock); return np; @@ -130,7 +130,7 @@ ifind (ino_t inum) /* The last reference to a node has gone away; drop it from the hash table and clean all state in the dn structure. */ -void +void diskfs_node_norefs (struct node *np) { *np->dn->hprevp = np->dn->hnext; @@ -158,7 +158,7 @@ diskfs_lost_hardrefs (struct node *np) #ifdef notanymore struct port_info *pi; struct pager *p; - + /* Check and see if there is a pager which has only one reference (ours). If so, then drop that reference, breaking the cycle. The complexity in this routine @@ -170,17 +170,17 @@ diskfs_lost_hardrefs (struct node *np) pi = (struct port_info *) np->dn->fileinfo->p; if (pi->refcnt == 1) { - + /* The only way to get a new reference to the pager in this state is to call diskfs_get_filemap; this can't happen as long as we hold NP locked. So we can safely unlock _libports_portrefcntlock for the following call. */ spin_unlock (&_libports_portrefcntlock); - + /* Right now the node is locked with no hard refs; this is an anomolous situation. Before messing with - the reference count on the file pager, we have to + 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 unreference. */ @@ -216,7 +216,7 @@ read_disknode (struct node *np) struct stat *st = &np->dn_stat; struct dinode *di = dino (np->dn->number); error_t err; - + err = diskfs_catch_exception (); if (err) return err; @@ -232,7 +232,7 @@ read_disknode (struct node *np) st->st_ino = np->dn->number; st->st_gen = read_disk_entry (di->di_gen); st->st_rdev = read_disk_entry(di->di_rdev); - st->st_mode = (((read_disk_entry (di->di_model) + st->st_mode = (((read_disk_entry (di->di_model) | (read_disk_entry (di->di_modeh) << 16)) & ~S_ITRANS) | (di->di_trans ? S_IPTRANS : 0)); @@ -249,11 +249,11 @@ read_disknode (struct node *np) st->st_mtime_usec = read_disk_entry (di->di_mtime.tv_nsec) / 1000; st->st_ctime = read_disk_entry (di->di_ctime.tv_sec); st->st_ctime_usec = read_disk_entry (di->di_ctime.tv_nsec) / 1000; -#endif +#endif st->st_blksize = sblock->fs_bsize; st->st_blocks = read_disk_entry (di->di_blocks); st->st_flags = read_disk_entry (di->di_flags); - + if (sblock->fs_inodefmt < FS_44INODEFMT) { st->st_uid = read_disk_entry (di->di_ouid); @@ -274,8 +274,8 @@ read_disknode (struct node *np) if (!S_ISBLK (st->st_mode) && !S_ISCHR (st->st_mode)) st->st_rdev = 0; - if (S_ISLNK (st->st_mode) - && direct_symlink_extension + if (S_ISLNK (st->st_mode) + && direct_symlink_extension && st->st_size < sblock->fs_maxsymlinklen) np->allocsize = 0; else @@ -319,7 +319,7 @@ write_node (struct node *np) struct stat *st = &np->dn_stat; struct dinode *di = dino (np->dn->number); error_t err; - + assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); if (np->dn_stat_dirty) { @@ -328,9 +328,9 @@ write_node (struct node *np) err = diskfs_catch_exception (); if (err) return; - + write_disk_entry (di->di_gen, st->st_gen); - + if (S_ISBLK (st->st_mode) || S_ISCHR (st->st_mode)) write_disk_entry (di->di_rdev, st->st_rdev); @@ -343,7 +343,7 @@ write_node (struct node *np) write_disk_entry (di->di_model, mode & 0xffff); write_disk_entry (di->di_modeh, (mode >> 16) & 0xffff); } - else + else { write_disk_entry (di->di_model, st->st_mode & 0xffff & ~S_ITRANS); di->di_modeh = 0; @@ -354,7 +354,7 @@ write_node (struct node *np) write_disk_entry (di->di_uid, st->st_uid); write_disk_entry (di->di_gid, st->st_gid); } - + if (sblock->fs_inodefmt < FS_44INODEFMT) { write_disk_entry (di->di_ouid, st->st_uid & 0xffff); @@ -376,38 +376,38 @@ write_node (struct node *np) write_disk_entry (di->di_mtime.tv_nsec, st->st_mtime_usec * 1000); write_disk_entry (di->di_ctime.tv_sec, st->st_ctime); write_disk_entry (di->di_ctime.tv_nsec, st->st_ctime_usec * 1000); -#endif +#endif write_disk_entry (di->di_blocks, st->st_blocks); write_disk_entry (di->di_flags, st->st_flags); - + diskfs_end_catch_exception (); np->dn_stat_dirty = 0; record_poke (di, sizeof (struct dinode)); } -} +} /* See if we should create a symlink by writing it directly into the block pointer array. Returning EINVAL tells diskfs to do it the usual way. */ static error_t -create_symlink_hook (struct node *np, char *target) +create_symlink_hook (struct node *np, const char *target) { int len = strlen (target); error_t err; struct dinode *di; - + if (!direct_symlink_extension) return EINVAL; - + assert (compat_mode != COMPAT_BSD42); if (len >= sblock->fs_maxsymlinklen) return EINVAL; - + err = diskfs_catch_exception (); if (err) return err; - + di = dino (np->dn->number); bcopy (target, di->di_shortlink, len); np->dn_stat.st_size = len; @@ -418,25 +418,25 @@ create_symlink_hook (struct node *np, char *target) diskfs_end_catch_exception (); return 0; } -error_t (*diskfs_create_symlink_hook)(struct node *, char *) +error_t (*diskfs_create_symlink_hook)(struct node *, const char *) = create_symlink_hook; /* Check if this symlink is stored directly in the block pointer array. Returning EINVAL tells diskfs to do it the usual way. */ -static error_t +static error_t read_symlink_hook (struct node *np, char *buf) { error_t err; - - if (!direct_symlink_extension + + if (!direct_symlink_extension || np->dn_stat.st_size >= sblock->fs_maxsymlinklen) return EINVAL; err = diskfs_catch_exception (); if (err) return err; - + bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); if (! diskfs_check_readonly ()) @@ -456,7 +456,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) struct item *i; error_t err; int n; - + /* Acquire a reference on all the nodes in the hash table and enter them into a list on the stack. */ spin_lock (&diskfs_node_refcnt_lock); @@ -496,10 +496,10 @@ write_all_disknodes () write_node (np); return 0; } - + diskfs_node_iterate (helper); } - + void diskfs_write_disknode (struct node *np, int wait) { @@ -530,7 +530,7 @@ diskfs_set_statfs (struct statfs *st) /* Implement the diskfs_set_translator callback from the diskfs library; see for the interface description. */ error_t -diskfs_set_translator (struct node *np, char *name, u_int namelen, +diskfs_set_translator (struct node *np, const char *name, u_int namelen, struct protid *cred) { daddr_t blkno; @@ -547,10 +547,10 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, err = diskfs_catch_exception (); if (err) return err; - + di = dino (np->dn->number); blkno = read_disk_entry (di->di_trans); - + if (namelen && !blkno) { /* Allocate block for translator */ @@ -574,7 +574,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, np->dn_stat.st_mode &= ~S_IPTRANS; np->dn_set_ctime = 1; } - + if (namelen) { bcopy (&namelen, buf, sizeof (u_int)); @@ -586,7 +586,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen, np->dn_stat.st_mode |= S_IPTRANS; np->dn_set_ctime = 1; } - + diskfs_end_catch_exception (); return err; } @@ -608,7 +608,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) blkno = read_disk_entry ((dino (np->dn->number))->di_trans); assert (blkno); transloc = disk_image + fsaddr (sblock, blkno); - + datalen = *(u_int *)transloc; *namep = malloc (datalen); bcopy (transloc + sizeof (u_int), *namep, datalen); @@ -649,13 +649,13 @@ diskfs_S_file_get_storage_info (struct protid *cred, struct store *file_store; struct store_run runs[NDADDR]; size_t num_runs = 0; - + if (! cred) return EOPNOTSUPP; np = cred->po->np; mutex_lock (&np->lock); - + /* See if this file fits in the direct block pointers. If not, punt for now. (Reading indir blocks is a pain, and I'm postponing pain.) XXX */ @@ -679,7 +679,7 @@ diskfs_S_file_get_storage_info (struct protid *cred, for (i = 0; i < NDADDR; i++) { off_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); - off_t length = + off_t length = (((i + 1) * sblock->fs_bsize > np->allocsize) ? np->allocsize - i * sblock->fs_bsize : sblock->fs_bsize); @@ -694,7 +694,7 @@ diskfs_S_file_get_storage_info (struct protid *cred, diskfs_end_catch_exception (); mutex_unlock (&np->lock); - + if (! err) err = store_clone (store, &file_store); if (! err) -- cgit v1.2.3 From e818daa7d08698dd88b0f52a2fc8faffd8b3c279 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Oct 1998 21:19:27 +0000 Subject: . --- ufs/ChangeLog | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 3a225552..e4f3ce9d 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,10 +1,18 @@ +1998-09-04 Roland McGrath + + * dir.c (diskfs_lookup_hard): Fix defn with `const'. + (diskfs_direnter_hard): Likewise. + (dirscanblock): Likewise. + * inode.c (diskfs_create_symlink_hook, create_symlink_hook): Likewise. + (diskfs_set_translator): Likewise. + Wed Aug 20 14:34:24 1997 Thomas Bushnell, n/BSG * dir.c (diskfs_lookup_hard): Cope with error return from - diskfs_get_filemap. + diskfs_get_filemap. * sizes.c (diskfs_grow): Likewise. * dir.c (diskfs_dirempty): Cope (poorly) with error return from - diskfs_get_filemap. + diskfs_get_filemap. * sizes.c (diskfs_truncate): Likewise. (block_extended): Likewise. @@ -53,14 +61,14 @@ Mon Nov 18 17:10:00 1996 Miles Bader Sat Nov 16 17:21:40 1996 Thomas Bushnell, n/BSG - * inode.c (diskfs_S_fsys_getfile): Delete var `fakecred'. + * inode.c (diskfs_S_fsys_getfile): Delete var `fakecred'. diskfs_access -> fshelp_access. * alloc.c (ffs_alloc): diskfs_isuid -> idvec_contains. (ffs_realloccg): Likewise. Thu Nov 14 16:43:36 1996 Thomas Bushnell, n/BSG - * inode.c (diskfs_S_file_getfh): diskfs_isuid -> idvec_contains. + * inode.c (diskfs_S_file_getfh): diskfs_isuid -> idvec_contains. (diskfs_S_fsys_getfile): Use idvecs and iousers. Thu Oct 24 16:07:17 1996 Miles Bader @@ -157,21 +165,21 @@ Fri Sep 6 16:00:42 1996 Thomas Bushnell, n/BSG * consts.c: Include . (diskfs_major_version, diskfs_minor_version, diskfs_edit_version): - Deleted variables. + Deleted variables. (diskfs_server_version): New variable. Thu Aug 29 16:07:07 1996 Thomas Bushnell, n/BSG * dir.c (diskfs_lookup_hard): When setting ds->stat to EXTEND, set ds->idx by looking at the size of the file. (IDX itself is no - longer at the end because of the change on Aug 16 1996.) + longer at the end because of the change on Aug 16 1996.) Wed Aug 28 12:15:15 1996 Thomas Bushnell, n/BSG * dir.c (dirscanblock): Size dirents correctly when mallocing it. (diskfs_direnter_hard): Be more careful when sizing or resizing dirents. Correctly set to -1 all the new entries we create after - realloc call. + realloc call. Fri Aug 16 18:51:31 1996 Thomas Bushnell, n/BSG @@ -192,10 +200,10 @@ Wed Aug 7 13:00:30 1996 Thomas Bushnell, n/BSG bsize to be fs_fsize, not fs_bsize. * hyper.c (diskfs_set_hypermetadata): Return an error as - appropriate. - + appropriate. + * inode.c (struct ufs_fhandle): Layout filehandle more like Unixy - NFSD. + NFSD. (diskfs_S_file_getfh): Bother to clear unused parts of a file handle so that they always compare equal. @@ -296,8 +304,8 @@ Mon May 6 14:23:54 1996 Michael I. Bushnell, p/BSG Fri May 3 09:15:33 1996 Michael I. Bushnell, p/BSG * sizes.c (block_extended): Rewrite code that moves pages - to be more efficient, and not deadlock too, using unlocked - pagein permission feature (read "hack"). Return value + to be more efficient, and not deadlock too, using unlocked + pagein permission feature (read "hack"). Return value now indicates whether we expect a sync. (diskfs_grow): If a call to block_extended returns nonzero, then sync the file before returning. @@ -339,9 +347,9 @@ Wed Apr 24 14:05:48 1996 Michael I. Bushnell, p/BSG case where it was written on a little endian machine without the extension. (DIRECT_NAMLEN) [LITTLE_ENDIAN]: Deal with case correctly where it - was written without the extension on a big endian machine. + was written without the extension on a big endian machine. * dir.c (dirscanblock): Use read/write_disk_entry when reading or - writing fields from directory entries. + writing fields from directory entries. (diskfs_direnter_hard): Likewise. (diskfs_dirremove_hard): Likewise. (diskfs_dirrewrite_hard): Likewise. @@ -363,8 +371,8 @@ Tue Apr 23 11:28:42 1996 Michael I. Bushnell, p/BSG (swab_short, swab_long, swab_long_long): New functions. (read_disk_entry, write_disk_entry): New macros. * alloc.c (ffs_realloccg): Use read/write_disk_entry when - reading/writing on-disk inode fields. - * bmap.c (fetch_indir_spec): Likewise. + reading/writing on-disk inode fields. + * bmap.c (fetch_indir_spec): Likewise. * inode.c (read_disknode): Likewise. (write_node): Likewise. (diskfs_set_translator): Likewise. @@ -380,11 +388,11 @@ Tue Apr 23 11:28:42 1996 Michael I. Bushnell, p/BSG (diskfs_grow): Likewise. * pager.c (pager_unlock_page): Likewise. * alloc.c: Include - (ffs_blkpref): Use read_disk_entry when reading from BAP array. + (ffs_blkpref): Use read_disk_entry when reading from BAP array. (swab_cg, read_cg, release_cg): New functions. (ffs_fragextend, ffs_alloccg, ffs_nodealloccg, ffs_blkfree, - diskfs_free_node): Use new cg access functions. - + diskfs_free_node): Use new cg access functions. + Thu Apr 18 14:50:30 1996 Michael I. Bushnell, p/BSG * sizes.c (diskfs_grow): New variable `pagerpt'. @@ -439,7 +447,7 @@ Fri Mar 22 23:43:53 1996 Miles Bader Wed Mar 20 14:36:31 1996 Michael I. Bushnell, p/BSG * dir.c (diskfs_lookup_hard): Don't do initial or final permission - checking here. + checking here. * dir.c (diskfs_dirrewrite_hard): Renamed from diskfs_dirrewrite. No longer call modification tracking routines. (diskfs_dirremove_hard): Renamed from diskfs_dirremove. No longer call @@ -454,7 +462,7 @@ Mon Mar 18 19:50:41 1996 Miles Bader Mon Mar 18 12:33:06 1996 Michael I. Bushnell, p/BSG - * pager.c (diskfs_max_user_pager_prot) [add_pager_max_prot]: + * pager.c (diskfs_max_user_pager_prot) [add_pager_max_prot]: (a == b) ? 1 : 0 ====> (a == b). Fri Feb 23 15:27:05 1996 Roland McGrath @@ -1795,4 +1803,3 @@ Thu May 5 19:06:54 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) Thu May 5 07:39:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) * Makefile ($(OBJS)): Use $(includedir) instead of $(headers) in deps. - -- cgit v1.2.3 From d2d38a4c423435d8b8fea4630d484cd1dab01bab Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 20 Dec 1998 20:51:02 +0000 Subject: 1998-12-20 Roland McGrath * alloc.c (diskfs_alloc_node): Fix printf format to silence warning. * hyper.c (get_hypermetadata): Likewise. --- ufs/alloc.c | 86 ++++++++++++++++++++++++++++++------------------------------- ufs/hyper.c | 16 ++++++------ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index ac72c928..e76b7703 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,5 +1,5 @@ /* Disk allocation routines - Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1993, 94, 95, 96, 98 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -8,7 +8,7 @@ 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, +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. @@ -67,7 +67,7 @@ extern u_long nextgennumber; spin_lock_t alloclock = SPIN_LOCK_INITIALIZER; /* Forward declarations */ -static u_long ffs_hashalloc (struct node *, int, long, int, +static u_long ffs_hashalloc (struct node *, int, long, int, u_long (*)(struct node *, int, daddr_t, int)); static u_long ffs_alloccg (struct node *, int, daddr_t, int); static daddr_t ffs_fragextend (struct node *, int, long, int, int); @@ -96,7 +96,7 @@ void swab_cg (struct cg *cg) { int i, j; - + if (swab_long (cg->cg_magic) == CG_MAGIC || cg->cg_magic == CG_MAGIC) { @@ -125,12 +125,12 @@ swab_cg (struct cg *cg) /* blktot map */ for (i = 0; i < cg->cg_ncyl; i++) cg_blktot(cg)[i] = swab_long (cg_blktot(cg)[i]); - + /* blks map */ for (i = 0; i < cg->cg_ncyl; i++) for (j = 0; j < sblock->fs_nrpos; j++) cg_blks(sblock, cg, i)[j] = swab_short (cg_blks (sblock, cg, i)[j]); - + for (i = 0; i < sblock->fs_contigsumsize; i++) cg_clustersum(cg)[i] = swab_long (cg_clustersum(cg)[i]); @@ -140,11 +140,11 @@ swab_cg (struct cg *cg) { /* Old format cylinder group... */ struct ocg *ocg = (struct ocg *) cg; - + if (swab_long (ocg->cg_magic) != CG_MAGIC && ocg->cg_magic != CG_MAGIC) return; - + ocg->cg_time = swab_long (ocg->cg_time); ocg->cg_cgx = swab_long (ocg->cg_cgx); ocg->cg_ncyl = swab_short (ocg->cg_ncyl); @@ -176,7 +176,7 @@ int read_cg (int cg, struct cg **cgpp) { struct cg *diskcg = cg_locate (cg); - + if (swab_disk) { *cgpp = malloc (sblock->fs_cgsize); @@ -205,7 +205,7 @@ release_cg (struct cg *cgp) /* * Allocate a block in the file system. - * + * * The size of the requested block is given, which must be some * multiple of fs_fsize and <= fs_bsize. * A preference may be optionally specified. If a preference is given @@ -224,7 +224,7 @@ release_cg (struct cg *cgp) */ error_t ffs_alloc(register struct node *np, - daddr_t lbn, + daddr_t lbn, daddr_t bpref, int size, daddr_t *bnp, @@ -233,7 +233,7 @@ ffs_alloc(register struct node *np, register struct fs *fs; daddr_t bno; int cg; - + *bnp = 0; fs = sblock; #ifdef DIAGNOSTIC @@ -297,7 +297,7 @@ error_t ffs_realloccg(register struct node *np, daddr_t lbprev, volatile daddr_t bpref, - int osize, + int osize, int nsize, daddr_t *pbn, struct protid *cred) @@ -306,7 +306,7 @@ ffs_realloccg(register struct node *np, int cg, error; volatile int request; daddr_t bprev, bno; - + *pbn = 0; fs = sblock; #ifdef DIAGNOSTIC @@ -322,8 +322,8 @@ ffs_realloccg(register struct node *np, #endif /* DIAGNOSTIC */ spin_lock (&alloclock); - - if (!idvec_contains (cred->user->uids, 0) + + if (!idvec_contains (cred->user->uids, 0) && freespace(fs, fs->fs_minfree) <= 0) goto nospace; error = diskfs_catch_exception (); @@ -378,8 +378,8 @@ ffs_realloccg(register struct node *np, switch ((int)fs->fs_optim) { case FS_OPTSPACE: /* - * Allocate an exact sized fragment. Although this makes - * best use of space, we will waste time relocating it if + * Allocate an exact sized fragment. Although this makes + * best use of space, we will waste time relocating it if * the file continues to grow. If the fragmentation is * less than half of the minimum free reserve, we choose * to begin optimizing for time. @@ -419,7 +419,7 @@ ffs_realloccg(register struct node *np, bno = (daddr_t)ffs_hashalloc(np, cg, (long)bpref, request, (u_long (*)())ffs_alloccg); if (bno > 0) { -#if 0 /* Not necessary in GNU Hurd ufs */ +#if 0 /* Not necessary in GNU Hurd ufs */ bp->b_blkno = fsbtodb(fs, bno); (void) vnode_pager_uncache(ITOV(ip)); #endif @@ -585,7 +585,7 @@ ffs_reallocblks(ap) * Next we must write out the modified inode and indirect blocks. * For strict correctness, the writes should be synchronous since * the old block values may have been written to disk. In practise - * they are almost never written, but if we are concerned about + * they are almost never written, but if we are concerned about * strict correctness, the `doasyncfree' flag should be set to zero. * * The test on `doasyncfree' should be changed to test a flag @@ -631,7 +631,7 @@ fail: /* * Allocate an inode in the file system. - * + * * If allocating a directory, use ffs_dirpref to select the inode. * If allocating in a directory, the following hierarchy is followed: * 1) allocate the preferred inode. @@ -644,7 +644,7 @@ fail: * 2) quadradically rehash into other cylinder groups, until an * available inode is located. */ -/* This is now the diskfs_alloc_node callback from the diskfs library +/* This is now the diskfs_alloc_node callback from the diskfs library (described in ). It used to be ffs_valloc in BSD. */ error_t diskfs_alloc_node (struct node *dir, @@ -656,7 +656,7 @@ diskfs_alloc_node (struct node *dir, ino_t ino, ipref; int cg, error; int sex; - + fs = sblock; @@ -685,7 +685,7 @@ diskfs_alloc_node (struct node *dir, assert ("duplicate allocation" && !np->dn_stat.st_mode); assert (! (np->dn_stat.st_mode & S_IPTRANS)); if (np->dn_stat.st_blocks) { - printf("free inode %d had %d blocks\n", + printf("free inode %d had %ld blocks\n", ino, np->dn_stat.st_blocks); np->dn_stat.st_blocks = 0; np->dn_set_ctime = 1; @@ -700,7 +700,7 @@ diskfs_alloc_node (struct node *dir, nextgennumber = sex; np->dn_stat.st_gen = nextgennumber; spin_unlock (&gennumberlock); - + *npp = np; alloc_sync (np); return (0); @@ -739,7 +739,7 @@ ffs_dirpref(register struct fs *fs) * Select the desired position for the next block in a file. The file is * logically divided into sections. The first section is composed of the * direct blocks. Each additional section contains fs_maxbpg blocks. - * + * * If no blocks have been allocated in the first section, the policy is to * request a block in the same cylinder group as the inode that describes * the file. If no blocks have been allocated in any other section, the @@ -753,7 +753,7 @@ ffs_dirpref(register struct fs *fs) * indirect block, the information on the previous allocation is unavailable; * here a best guess is made based upon the logical block number being * allocated. - * + * * If a section is already partially allocated, the policy is to * contiguously allocate fs_maxcontig blocks. The end of one of these * contiguous blocks and the beginning of the next is physically separated @@ -786,10 +786,10 @@ ffs_blkpref(struct node *np, */ if (indx == 0 || bap[indx - 1] == 0) startcg = - (ino_to_cg(fs, np->dn->number) + (ino_to_cg(fs, np->dn->number) + lbn / fs->fs_maxbpg); else - startcg = dtog(fs, + startcg = dtog(fs, read_disk_entry (bap[indx - 1])) + 1; startcg %= fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; @@ -892,14 +892,14 @@ ffs_hashalloc(struct node *np, /* * Determine whether a fragment can be extended. * - * Check to see if the necessary fragments are available, and + * Check to see if the necessary fragments are available, and * if they are, allocate them. */ static daddr_t ffs_fragextend(struct node *np, int cg, long bprev, - int osize, + int osize, int nsize) { register struct fs *fs; @@ -1016,7 +1016,7 @@ ffs_alloccg(struct node *np, bno = ffs_alloccgblk(fs, cgp, bpref); /* bdwrite(bp); */ if (releasecg) - release_cg (cgp); + release_cg (cgp); return (bno); } /* @@ -1030,7 +1030,7 @@ ffs_alloccg(struct node *np, break; if (allocsiz == fs->fs_frag) { /* - * no fragments were available, so a block will be + * no fragments were available, so a block will be * allocated, and hacked up */ if (cgp->cg_cs.cs_nbfree == 0) { @@ -1049,7 +1049,7 @@ ffs_alloccg(struct node *np, csum[cg].cs_nffree += i; fs->fs_fmod = 1; cgp->cg_frsum[i]++; - + if (releasecg) release_cg (cgp); record_poke (cgp, sblock->fs_cgsize); @@ -1127,7 +1127,7 @@ ffs_alloccgblk(register struct fs *fs, /* * Block layout information is not available. * Leaving bpref unchanged means we take the - * next available free block following the one + * next available free block following the one * we just allocated. Hopefully this will at * least hit a track cache on drives of unknown * geometry (e.g. SCSI). @@ -1135,7 +1135,7 @@ ffs_alloccgblk(register struct fs *fs, goto norot; } /* - * check the summary information to see if a block is + * check the summary information to see if a block is * available in the requested cylinder starting at the * requested rotational position and proceeding around. */ @@ -1285,7 +1285,7 @@ fail: brelse(bp); return (0); } -#endif +#endif /* * Determine whether an inode can be allocated. @@ -1377,7 +1377,7 @@ gotit: * Free a block or fragment. * * The specified block or fragment is placed back in the - * free map. If a fragment is deallocated, a possible + * free map. If a fragment is deallocated, a possible * block reassembly is checked. */ void @@ -1409,7 +1409,7 @@ ffs_blkfree(register struct node *np, cgp = (struct cg *)bp->b_data; #else releasecg = read_cg (cg, &cgp); -#endif +#endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ if (releasecg) @@ -1484,7 +1484,7 @@ ffs_blkfree(register struct node *np, * * The specified inode is placed back in the free map. */ -/* Implement diskfs call back diskfs_free_node (described in +/* Implement diskfs call back diskfs_free_node (described in . This was called ffs_vfree in BSD. */ void diskfs_free_node (struct node *np, mode_t mode) @@ -1508,11 +1508,11 @@ diskfs_free_node (struct node *np, mode_t mode) cgp = (struct cg *)bp->b_data; #else releasecg = read_cg (cg, &cgp); -#endif +#endif if (!cg_chkmagic(cgp)) { /* brelse(bp); */ if (releasecg) - release_cg (cgp); + release_cg (cgp); return; } cgp->cg_time = diskfs_mtime->seconds; @@ -1687,7 +1687,7 @@ ffs_clusteracct(struct fs *fs, #if 0 /* * Fserr prints the name of a file system with an error diagnostic. - * + * * The form of the error message is: * fs: error message */ diff --git a/ufs/hyper.c b/ufs/hyper.c index 500934eb..2a43bfed 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -1,5 +1,5 @@ /* Fetching and storing the hypermetadata (superblock and cg summary info). - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 95, 96, 97, 98 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 @@ -34,7 +34,7 @@ void swab_sblock (struct fs *sblock) { int i, j; - + sblock->fs_sblkno = swab_long (sblock->fs_sblkno); sblock->fs_cblkno = swab_long (sblock->fs_cblkno); sblock->fs_iblkno = swab_long (sblock->fs_iblkno); @@ -108,24 +108,24 @@ swab_sblock (struct fs *sblock) else for (i = 0; i < sblock->fs_cpc; i++) for (j = 0; j < sblock->fs_nrpos; j++) - fs_postbl(sblock, j)[i] + fs_postbl(sblock, j)[i] = swab_short (fs_postbl (sblock, j)[i]); /* The rot table is all chars */ } - + void swab_csums (struct csum *csum) { int i; - + for (i = 0; i < sblock->fs_ncg; i++) { csum[i].cs_ndir = swab_long (csum[i].cs_ndir); csum[i].cs_nbfree = swab_long (csum[i].cs_nbfree); csum[i].cs_nifree = swab_long (csum[i].cs_nifree); csum[i].cs_nffree = swab_long (csum[i].cs_nffree); - } + } } void @@ -252,7 +252,7 @@ get_hypermetadata (void) if (store->size < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size (%Zd) less than necessary " + "Disk size (%ld) less than necessary " "(superblock says we need %ld)\n", store->size, sblock->fs_size * sblock->fs_fsize); exit (1); @@ -315,7 +315,7 @@ diskfs_set_hypermetadata (int wait, int clean) } vm_deallocate (mach_task_self (), (vm_address_t)buf, read); - + if (err) { spin_unlock (&alloclock); -- cgit v1.2.3 From 7d20ee2f3d07b1a609814cb8ee83d712d0581f24 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 20 Dec 1998 21:00:36 +0000 Subject: . --- ufs/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index e4f3ce9d..14f11053 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +1998-12-20 Roland McGrath + + * alloc.c (diskfs_alloc_node): Fix printf format to silence warning. + * hyper.c (get_hypermetadata): Likewise. + 1998-09-04 Roland McGrath * dir.c (diskfs_lookup_hard): Fix defn with `const'. -- cgit v1.2.3 From 3c3060eb5246ef3fb3ccd2c1b80236bdb8b96e8b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 27 Dec 1998 08:41:51 +0000 Subject: 1998-12-27 Roland McGrath * main.c (main): Pass ARGP_IN_ORDER flag to argp_parse because diskfs options need it. --- ufs/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 6116792b..dfbfeda3 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 95, 96, 97, 98 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 @@ -162,7 +162,8 @@ main (int argc, char **argv) mach_port_t bootstrap; struct store_argp_params store_params = { 0 }; - argp_parse (&startup_argp, argc, argv, 0, 0, &store_params); + /* XXX diskfs's --boot-command needs us to use ARGP_IN_ORDER */ + argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, NULL, &store_params); store_parsed = store_params.result; err = store_parsed_name (store_parsed, &diskfs_disk_name); -- cgit v1.2.3 From 8fb12c8cdd3e204dd1918be1e8ec8836dcebc286 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 27 Dec 1998 08:45:04 +0000 Subject: . --- ufs/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 14f11053..bd8e6358 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +1998-12-27 Roland McGrath + + * main.c (main): Pass ARGP_IN_ORDER flag to argp_parse because + diskfs options need it. + 1998-12-20 Roland McGrath * alloc.c (diskfs_alloc_node): Fix printf format to silence warning. -- cgit v1.2.3 From 341e44275812fb922644389f10e33ecf2f7b221c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 27 Dec 1998 10:20:53 +0000 Subject: 1998-12-27 Roland McGrath * inode.c (diskfs_set_statfs): Remove __ from struct members. 1998-12-21 Mark Kettenis * inode.c (diskfs_set_statfs): Fill in statfs members that are used to implement statvfs. --- ufs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ufs/inode.c b/ufs/inode.c index 658d6187..1901788e 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -524,6 +524,8 @@ diskfs_set_statfs (struct statfs *st) st->f_ffree = sblock->fs_cstotal.cs_nifree; st->f_fsid = getpid (); st->f_namelen = 0; + st->f_favail = st->f_ffree; + st->f_frsize = sblock->fs_fsize; return 0; } -- cgit v1.2.3 From a09e62adf5ee1e122cec5cea8594ba8a7b3cdafa Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 27 Dec 1998 10:29:29 +0000 Subject: . --- ufs/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index bd8e6358..7d280a4a 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,12 @@ +1998-12-27 Roland McGrath + + * inode.c (diskfs_set_statfs): Remove __ from struct members. + +1998-12-21 Mark Kettenis + + * inode.c (diskfs_set_statfs): Fill in statfs members that are + used to implement statvfs. + 1998-12-27 Roland McGrath * main.c (main): Pass ARGP_IN_ORDER flag to argp_parse because -- cgit v1.2.3 From d387913db19bebfdbc2860084242a05ec6439fd5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 24 Jan 1999 02:43:43 +0000 Subject: 1999-01-23 Roland McGrath * main.c (main): Use diskfs_init_main. --- ufs/main.c | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index dfbfeda3..29b22d11 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -160,39 +160,11 @@ main (int argc, char **argv) { error_t err; mach_port_t bootstrap; - struct store_argp_params store_params = { 0 }; - /* XXX diskfs's --boot-command needs us to use ARGP_IN_ORDER */ - argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, NULL, &store_params); - store_parsed = store_params.result; - - err = store_parsed_name (store_parsed, &diskfs_disk_name); - if (err) - error (2, err, "store_parsed_name"); - - /* This must come after the args have been parsed, as this is where the - host priv ports are set for booting. */ - diskfs_console_stdio (); - - if (diskfs_boot_flags) - /* We are the bootstrap filesystem. */ - bootstrap = MACH_PORT_NULL; - else - { - task_get_bootstrap_port (mach_task_self (), &bootstrap); - if (bootstrap == MACH_PORT_NULL) - error (2, 0, "Must be started as a translator"); - } - - /* Initialize the diskfs library. Must come before any other diskfs call. */ - err = diskfs_init_diskfs (); - if (err) - error (4, err, "init"); - - err = store_parsed_open (store_parsed, diskfs_readonly ? STORE_READONLY : 0, - &store); - if (err) - error (3, err, "%s", diskfs_disk_name); + /* Initialize the diskfs library, parse arguments, and open the store. + This starts the first diskfs thread for us. */ + store = diskfs_init_main (&startup_argp, argc, argv, + &store_parsed, &bootstrap); if (store->block_size > DEV_BSIZE) error (4, err, "%s: Bad device block size %d (should be <= %d)", @@ -206,15 +178,9 @@ main (int argc, char **argv) log2_dev_blocks_per_dev_bsize++; log2_dev_blocks_per_dev_bsize -= store->log2_block_size; - if (store->flags & STORE_HARD_READONLY) - diskfs_readonly = diskfs_hard_readonly = 1; - /* Map the entire disk. */ create_disk_pager (); - /* Start the first request thread, to handle RPCs and page requests. */ - diskfs_spawn_first_thread (); - get_hypermetadata (); inode_init (); -- cgit v1.2.3 From 094eae6ae91ebff7210cab489cb8ff214bfccfab Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 24 Jan 1999 02:52:44 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 7d280a4a..7d6c0800 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +1999-01-23 Roland McGrath + + * main.c (main): Use diskfs_init_main. + 1998-12-27 Roland McGrath * inode.c (diskfs_set_statfs): Remove __ from struct members. -- cgit v1.2.3 From ed5cad08a83dd3263ce16f2056990b6fb4bdb510 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 27 Jan 1999 20:48:21 +0000 Subject: 1999-01-24 Roland McGrath * configure.in: Add AC_PROG_AWK. * config.make.in (AWK): New variable, substituted by configure. --- configure.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 64960998..f291b665 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.14 1998/08/12 20:56:17 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.15 1999/01/27 20:48:21 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -31,6 +31,7 @@ AC_ARG_ENABLE(profile, AC_SUBST(enable_profile) AC_PROG_INSTALL +AC_PROG_AWK AC_CHECK_TOOL(CC, gcc) # That check handles cross-compilation well, but AC_PROG_CC tests for GCC -- cgit v1.2.3 From 9b92bf03fc2dca2451cccdfb2ec5702c05c50e55 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 16 Feb 1999 08:08:20 +0000 Subject: Tue Feb 16 02:31:06 1999 Thomas Bushnell, BSG * Makeconf ($(libname).so): Include $(hurd-version) as part of the soname. ($(libdir)/$(libname).so.$(hurd-version)): New rule. ($(libdir)/$(libname).so): Only create a symlink to the version-numbered name. (install) [makemode == library]: Add the versioned name $(libdir)/$(libname.so).$(hurd-version). * version.h.in: New file. * versioh.h, sh-version.sed: Deleted files. * Makeconf (hurd-version): New variable. * Makefile ($(subdirs)): Depend on version.h. (version.h): New rule. (DIST_FILES): Delete version.h and sh-version.sed. Add version.h.in. --- sh-version.sed | 1 - version.h | 32 -------------------------------- 2 files changed, 33 deletions(-) delete mode 100644 sh-version.sed delete mode 100644 version.h diff --git a/sh-version.sed b/sh-version.sed deleted file mode 100644 index d13c94d0..00000000 --- a/sh-version.sed +++ /dev/null @@ -1 +0,0 @@ -s/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 (GNU Hurd) 0.2/ diff --git a/version.h b/version.h deleted file mode 100644 index ab6c5b2b..00000000 --- a/version.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Hurd version - Copyright (C) 1996, 1997 Free Software Foundation, Inc. - Written by Thomas Bushnell, n/BSG. - - 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. */ - -/* See sh-version.sed for duplicates of this information. */ - -#ifndef HURD_VERSION -#define HURD_VERSION "0.2" -#endif - -/* The standard way to print versions for --version. */ -#define _SHV_SEP "; " -#define STANDARD_HURD_VERSION(s, extra...) \ - #s " (GNU Hurd" _SHV_SEP ##extra ") " HURD_VERSION - - -- cgit v1.2.3 From 0e4057bc0e1b9618be4c2fe761d685f4e98b8ddf Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 22 Feb 1999 10:45:04 +0000 Subject: Maintain debian package info here now. --- debian/README.Debian | 7 +++ debian/TODO | 5 ++ debian/changelog | 66 +++++++++++++++++++++++ debian/conffiles | 1 + debian/control | 24 +++++++++ debian/copyright | 29 ++++++++++ debian/rules | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++ debian/servers.boot | 16 ++++++ 8 files changed, 298 insertions(+) create mode 100644 debian/README.Debian create mode 100644 debian/TODO create mode 100644 debian/changelog create mode 100644 debian/conffiles create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 debian/servers.boot diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 00000000..6d0c3b8b --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,7 @@ +GNU Hurd for Debian +------------------- + +This is the Hurd release for Debian GNU/Hurd. +It contains essential system software and libraries. + +GNU Hurd Maintainers diff --git a/debian/TODO b/debian/TODO new file mode 100644 index 00000000..f6e20d74 --- /dev/null +++ b/debian/TODO @@ -0,0 +1,5 @@ +* daemons/rc +* splitting in multiple packages +* postinst script for translators + +shlibdeps! diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..02112bda --- /dev/null +++ b/debian/changelog @@ -0,0 +1,66 @@ +hurd (19990221-1) unstable; urgency=low + + * New version from CVS. + * Put shared library symlinks into the hurd-dev package. + + -- + +hurd (19990212-2) unstable; urgency=low + + * debian/control: Added Depends line for Hurd. + * Update docs to reflect new group maintainership. + * debian/copyright: Hurd libraries are *not* under the LGPL, so add a + clarifying note. + * Put static libraries and header files into /usr/lib and /usr/include + for people without the /usr symlink. + + -- Gordon Matzigkeit Wed, 17 Feb 1999 15:40:44 -0600 + +hurd (19990212-1) unstable; urgency=low + + * New upstream version from CVS. + * Deleted old libthreads... there's no going back now. + + -- Gordon Matzigkeit Fri, 12 Feb 1999 03:25:55 -0600 + +hurd (19981204-1) unstable; urgency=low + + * New upstream release, supposed to work with glibc 2.0.106. + * Commented out use of old libthreads. + + -- Marcus Brinkmann Sun, 20 Dec 1998 04:24:40 +0100 + +hurd (19980915-2) unstable; urgency=low + + * exec/hashexec.c: Applied patch by Thomas Bushnell to fix make. + + -- Marcus Brinkmann Fri, 6 Nov 1998 23:10:11 +0100 + +hurd (19980915-1) unstable; urgency=low + + * New upstream release. + * debian/rules: Strip all binaries. + * debian/TODO: New file. + + -- Marcus Brinkmann Thu, 8 Oct 1998 03:34:40 +0200 + +hurd (19980716-2) unstable; urgency=low + + * Reverted libthreads to provide threadsafe malloc, as we use older + version of glibc2 for now. + * Do not remove size 0 files in 'rules clean', because hurd depends on + them. + * Do not build profiling libraries. + + -- Marcus Brinkmann Tue, 4 Aug 1998 21:58:55 +0200 + +hurd (19980716-1) unstable; urgency=low + + * Initial Version. + + -- Marcus Brinkmann Tue, 4 Aug 1998 21:58:55 +0200 + +Local variables: +mode: debian-changelog +add-log-mailing-address: "bug-hurd@gnu.org" +End: diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 00000000..0610053f --- /dev/null +++ b/debian/conffiles @@ -0,0 +1 @@ +/boot/servers.boot diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..f50f9fe3 --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: hurd +Section: base +Priority: required +Maintainer: GNU Hurd Maintainers +Standards-Version: 2.5.0.0 + +Package: hurd +Priority: required +Section: base +Essential: yes +Depends: ${shlibs:Depends} +Provides: makedev +Architecture: hurd-i386 +Description: The GNU Hurd + This is the GNU Hurd package. It contains essential system software and + libraries. + +Package: hurd-dev +Priority: standard +Section: devel +Architecture: hurd-i386 +Depends: hurd +Description: The GNU Hurd (development files) + This package includes the header files and the static libraries. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..784f5768 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,29 @@ +This package was debianized by Marcus Brinkmann +on Tue, 4 Aug 1998 21:52:45 +0200 + +It is currently maintained by its upstream authors, who can be reached +via . + +Sources are available from ftp://alpha.gnu.org/pub/hurd/src/ + +Copyright statement: + +Note that the libraries distributed with the GNU Hurd are placed under +the standard GNU General Public License (*not* the Library General +Public License). + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/doc/copyright/GPL'. diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..4c1dee8e --- /dev/null +++ b/debian/rules @@ -0,0 +1,150 @@ +#!/usr/bin/make -f +############################ -*- Mode: Makefile -*- ########################### +## rules --- +## Author : Marcus Brinkmann +## Created On : Sat, 1 Aug 1998 21:33:31 +0200 +## Created On Node : localhost +## Last Modified By : Marcus Brinkmann +## Last Modified On : Mon, 4 Jan 1999 03:37:08 +0100 +## Last Machine Used: localhost +## Update Count : 1 +## Status : Unknown, Use with caution! +## HISTORY : +## Description : +## +############################################################################### + +# The name of the package (for example, `emacs'). +package := hurd +BUILDARCH := $(DEB_BUILD_GNU_TYPE) +HOSTARCH := $(DEB_HOST_GNU_TYPE) + +# Configuration variables (these should be pretty generic) +CC = cc +CFLAGS = -O2 -g -pipe -Wall +LDFLAGS = -s +PREFIX = /usr +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/man +DOCDIR = $(PREFIX)/doc/$(package) + +# Package specific stuff. The idea is to try to make the rules +# generic (gradually). + +FILES_TO_CLEAN = debian/files include/*.h +DIRS_TO_CLEAN = debian/tmp debian/$(package)-dev build +STAMPS_TO_CLEAN = stamp-build + +install_file = install -o root -g root -m 644 +install_program = install -s -o root -g root -m 755 +make_directory = install -d -o root -g root -m 755 + +define checkdir + test -f debian/rules +endef + +define checkroot + @test 0 = "`id -u`" || (echo need root priviledges; exit 1) +endef + +all build: stamp-build + +configure: + aclocal + autoconf + +stamp-build: configure + $(checkdir) + mkdir build + cd build && ../configure --build=$(BUILDARCH) --host=$(HOSTARCH) --prefix= +# go and fetch a few beers now... + cd build && $(MAKE) no_prof=t + touch stamp-build + +clean: + $(checkdir) + -cd build && make clean no_deps=t + -rm -f $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN) + -rm -rf $(DIRS_TO_CLEAN) + for NAME in hurd/*.h; do \ + if [ -L $$NAME ] ; then \ + rm -f $$NAME ; \ + fi \ + done + -rm -f core `find . \( -name '*.o' -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -name '.SUMS' \) -print` + +binary: binary-indep binary-arch + +# Build architecture-independent files here. +binary-arch: build + $(checkdir) + $(checkroot) + -rm -rf debian/{tmp,$(package)-dev} + +# first the general install + $(make_directory) debian/tmp/boot + cd build && $(MAKE) install prefix=`pwd`/../debian/tmp no_prof=t +# kill the profiling libs + -rm -f debian/tmp/lib/*_p.a +# probably we'll make debug packages later, for now, strip'em + -strip --strip-unneeded debian/tmp/lib/lib*.so + -strip --strip-debug debian/tmp/lib/lib*.a + -strip --strip-all debian/tmp/bin/* + -strip --strip-all debian/tmp/sbin/* + -strip --strip-all debian/tmp/boot/* + -strip --strip-all debian/tmp/hurd/* + -strip --strip-all debian/tmp/libexec/* + chmod 0644 debian/tmp/lib/lib*.a + chmod 0755 debian/tmp/include debian/tmp/include/hurd debian/tmp/lib debian/tmp/hurd debian/tmp/bin debian/tmp/sbin debian/tmp/dev debian/tmp/libexec + +# now distribute the files +# first the source package + $(make_directory) debian/$(package)-dev/{DEBIAN,usr/{doc,bin,lib}} + ln -s $(package) debian/$(package)-dev/usr/doc/$(package)-dev + mv debian/tmp/include debian/$(package)-dev/usr/. + mv debian/tmp/lib/*.a debian/$(package)-dev/usr/lib/. + # Create development library links. + for file in `cd debian/tmp/lib && ls *.so.*`; do \ + linkname=`echo "$$file" | sed 's/\..*$/.so/'`; \ + ln -sf /lib/$$file debian/$(package)-dev/usr/lib/$$linkname; \\ + done + rm -f debian/tmp/lib/*.so + + dpkg-gencontrol -p$(package)-dev -Pdebian/$(package)-dev + chown -R root.root debian/$(package)-dev + dpkg --build debian/$(package)-dev .. + +# now the shared libs and other stuff + $(make_directory) debian/tmp/{DEBIAN,usr/doc/$(package)} +# kill some nonsense + rm -fr debian/tmp/root + -rm -f debian/tmp/etc/* +# Only found in CVS, not the distribution. +# $(install_file) BUGS debian/tmp$(DOCDIR) +# $(install_file) TODO debian/tmp$(DOCDIR) + $(install_file) INSTALL debian/tmp$(DOCDIR) + $(install_file) NEWS debian/tmp$(DOCDIR) + $(install_file) README debian/tmp$(DOCDIR) + $(install_file) tasks debian/tmp$(DOCDIR) + $(install_file) ChangeLog debian/tmp$(DOCDIR)/changelog + $(install_file) debian/README.Debian debian/tmp$(DOCDIR) + $(install_file) debian/changelog debian/tmp$(DOCDIR)/changelog.Debian + gzip -9frq debian/tmp$(DOCDIR)/. + $(install_file) debian/copyright debian/tmp$(DOCDIR) + + $(install_file) debian/servers.boot debian/tmp/boot/servers.boot + $(make_directory) debian/tmp/servers + + $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles + + dpkg-shlibdeps -p$(package) debian/tmp/bin/* debian/tmp/libexec/* debian/tmp/hurd/* debian/tmp/sbin/* + dpkg-gencontrol -p$(package) -Pdebian/tmp + chown -R root.root debian/tmp + dpkg --build debian/tmp .. + +binary-indep: build +# We have nothing to do here. + +.PHONY: build clean binary-indep binary-arch binary diff --git a/debian/servers.boot b/debian/servers.boot new file mode 100644 index 00000000..d25129d8 --- /dev/null +++ b/debian/servers.boot @@ -0,0 +1,16 @@ +# Boot script file for booting Debian GNU/Hurd. Each line specifies a file to +# be loaded by the boot loader (the first word), and actions to be done with it. + +# First, the bootstrap filesystem. It needs several ports as arguments, +# as well as the user flags from the boot loader. +/hurd/ext2fs.static --bootflags=${boot-args} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -Tdevice ${root-device} $(task-create) $(task-resume) + +# Now the exec server; to load the dynamically-linked exec server program, +# we have the boot loader in fact load and run ld.so, which in turn +# loads and runs /hurd/exec. This task is created, and its task port saved +# in ${exec-task} to be passed to the fs above, but it is left suspended; +# the fs will resume the exec task once it is ready. +/lib/ld.so.1 /hurd/exec $(exec-task=task-create) + +# default pager +#/dev/hd0s2 $(add-paging-file) $(default-pager) -- cgit v1.2.3 From 300ee2caf49d6afa4ed6228ccf0a8d266080bc5e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 27 Feb 1999 23:39:00 +0000 Subject: 1999-02-27 Roland McGrath * def_pager_setup.c (add_paging_file): New arg CHECK_LINUX_SIGNATURE, pass down to create_paging_partition. * default_pager.c (create_paging_partition): New arg CHECK_LINUX_SIGNATURE, pass down new_partition. (new_partition): New arg CHECK_LINUX_SIGNATURE: if not < 0, check first page of swap for Linux 2.0 or 2.2 signature page and obey its bad-block map; if > 0, refuse the partition if no signature found. * bootstrap.c (main): Add new boot script functions `add-raw-paging-file', `add-linux-paging-file'. Make those and `add-paging-file' all call add_paging_file with new LINUX_SIGNATURE arg of -1, 1, and 0, respectively. * default_pager.c (create_paging_partition): If new_partition returns null, return and do nothing more. --- serverboot/bootstrap.c | 36 ++++++++--- serverboot/def_pager_setup.c | 5 +- serverboot/default_pager.c | 145 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 172 insertions(+), 14 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 3fa0f404..5c4a0393 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -146,12 +146,25 @@ main(argc, argv) { int doing_default_pager = 0; int had_a_partition = 0; - int script_paging_file (const struct cmd *cmd, int *val) + int script_paging_file (const struct cmd *cmd, int linux_signature) { if (add_paging_file (bootstrap_master_device_port, cmd->path)) printf ("(serverboot): %s: Cannot add paging file\n", cmd->path); else had_a_partition = 1; + return 0; + } + int script_add_paging_file (const struct cmd *cmd, int *val) + { + return script_paging_file (cmd, 0); + } + int script_add_raw_paging_file (const struct cmd *cmd, int *val) + { + return script_paging_file (cmd, -1); + } + int script_add_linux_paging_file (const struct cmd *cmd, int *val) + { + return script_paging_file (cmd, 1); } int script_default_pager (const struct cmd *cmd, int *val) { @@ -178,9 +191,9 @@ main(argc, argv) */ if (argv[1][0] != '-') panic("bootstrap: no flags"); - + flag_string = argv[1]; - + /* * Parse the arguments. */ @@ -208,13 +221,13 @@ main(argc, argv) 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 @@ -275,7 +288,7 @@ main(argc, argv) } break; } - + /* * If the server boot script name was changed, * then use the new device name as the root device. @@ -309,7 +322,12 @@ main(argc, argv) || boot_script_set_variable ("boot-args", VAL_STR, (int) flag_string) || boot_script_define_function ("add-paging-file", VAL_NONE, - &script_paging_file) + &script_add_paging_file) + || boot_script_define_function ("add-raw-paging-file", VAL_NONE, + &script_add_raw_paging_file) + || boot_script_define_function ("add-linux-paging-file", + VAL_NONE, + &script_add_linux_paging_file) || boot_script_define_function ("default-pager", VAL_NONE, &script_default_pager) ) diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c index fe6b33ab..cd72acea 100644 --- a/serverboot/def_pager_setup.c +++ b/serverboot/def_pager_setup.c @@ -35,9 +35,10 @@ extern void *kalloc(); extern void create_paging_partition(); kern_return_t -add_paging_file(master_device_port, file_name) +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; @@ -68,7 +69,7 @@ add_paging_file(master_device_port, file_name) /* * Set up the default paging partition */ - create_paging_partition(file_name, fdp, isa_file); + create_paging_partition(file_name, fdp, isa_file, linux_signature); return result; } diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 159cd576..dc1e7ff6 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -163,10 +163,14 @@ partition_init() } static partition_t -new_partition (const char *name, struct file_direct *fdp) +new_partition (const char *name, struct file_direct *fdp, + int check_linux_signature) { register partition_t part; register vm_size_t size, bmsize; + vm_offset_t raddr; + mach_msg_type_number_t rsize; + int rc; size = atop(fdp->fd_size * fdp->fd_bsize); bmsize = howmany(size, NB_BM) * sizeof(bm_entry_t); @@ -182,6 +186,138 @@ new_partition (const char *name, struct file_direct *fdp) bzero((char *)part->bitmap, bmsize); + if (check_linux_signature < 0) + return part; + +#define LINUX_PAGE_SIZE 4096 /* size of pages in Linux swap partitions */ + rc = page_read_file_direct(part->file, + 0, LINUX_PAGE_SIZE, + &raddr, + &rsize); + if (rc) + panic("(default pager): cannot read first page of %s! rc=%#x\n", + name, rc); + if (rsize != LINUX_PAGE_SIZE) + panic("(default pager): bad read on first page of %s! size=%u\n", + name, rsize); + if (!memcmp("SWAP-SPACE", (char *) raddr + LINUX_PAGE_SIZE-10, 10)) + { + /* The partition's first page has a Linux swap signature. + This means the beginning of the page contains a bitmap + of good pages, and all others are bad. */ + unsigned int i, j, bad; + printf("(default pager): Found Linux 2.0 swap signature in %s...", + name); + part->bitmap[0] |= 1; /* first page unusable */ + part->free--; + bad = 0; + memset((char *) raddr + LINUX_PAGE_SIZE-10, 0, 10); + for (i = 0; i < LINUX_PAGE_SIZE / sizeof(bm_entry_t); ++i) + { + bm_entry_t bm = ((bm_entry_t *) raddr)[i]; + if (bm == BM_MASK) + continue; + /* There are some zero bits in this word. */ + for (j = 0; j < NB_BM; ++j) + if ((bm & (1 << j)) == 0) + { + ++bad; + part->bitmap[i] |= 1 << j; + } + } + part->free -= bad; + printf ("%dk swap-space (excludes %dk marked bad)\n", + part->free * (LINUX_PAGE_SIZE / 1024), + bad * (LINUX_PAGE_SIZE / 1024)); + if (part->total_size > 8 * LINUX_PAGE_SIZE) + { + unsigned int waste = part->total_size - (8 * LINUX_PAGE_SIZE); + part->free -= waste; + part->total_size -= waste; + printf("\ +(default pager): NOTE: wasting last %dk of %s past Linux max swapfile size\n", + waste * (LINUX_PAGE_SIZE / 1024), name); + } + } + else if (!memcmp("SWAPSPACE2", + (char *) raddr + LINUX_PAGE_SIZE-10, 10)) + { + struct + { + u_int8_t bootbits[1024]; + u_int32_t version; + u_int32_t last_page; + u_int32_t nr_badpages; + u_int32_t padding[125]; + u_int32_t badpages[1]; + } *hdr = (void *) raddr; + + printf("\ +(default pager): Found Linux 2.2 swap signature (v%u) in %s...", + name, hdr->version); + + part->bitmap[0] |= 1; /* first page unusable */ + part->free--; + + switch (hdr->version) + { + default: + if (check_linux_signature) + { + printf ("version %u unknown! SKIPPING %s!\n", + hdr->version, + name); + return 0; + } + else + printf ("version %u unknown! IGNORING SIGNATURE PAGE!" + " %dk swap-space\n", + hdr->version, + part->free * (LINUX_PAGE_SIZE / 1024)); + break; + + case 1: + { + unsigned int waste, i; + if (hdr->last_page > part->total_size) + { + printf ("signature says %uk, partition has only %uk! ", + hdr->last_page * (LINUX_PAGE_SIZE / 1024), + part->total_size * (LINUX_PAGE_SIZE / 1024)); + waste = 0; + } + else + { + waste = part->total_size - hdr->last_page; + part->total_size = hdr->last_page; + } + for (i = 0; i < hdr->nr_badpages; ++i) + { + const u_int32_t bad = hdr->badpages[i]; + part->bitmap[bad / NB_BM] |= 1 << (i % NB_BM); + part->free--; + } + printf ("%uk swap-space", + part->free * (LINUX_PAGE_SIZE / 1024)); + if (hdr->nr_badpages != 0) + printf (" (excludes %uk marked bad)", + hdr->nr_badpages * (LINUX_PAGE_SIZE / 1024)); + if (waste != 0) + printf (" (excludes %uk pages at end of partition)", + waste * (LINUX_PAGE_SIZE / 1024)); + printf ("\n"); + } + } + } + else if (check_linux_signature) + { + part = 0; + printf ("(default pager): " + "Cannot find Linux swap signature page! SKIPPING %s!", + name); + } + vm_deallocate(mach_task_self(), raddr, rsize); + return part; } @@ -192,11 +328,14 @@ new_partition (const char *name, struct file_direct *fdp) */ void create_paging_partition(const char *name, - struct file_direct *fdp, int isa_file) + struct file_direct *fdp, int isa_file, + int linux_signature) { register partition_t part; - part = new_partition (name, fdp); + part = new_partition (name, fdp, linux_signature); + if (!part) + return; mutex_lock(&all_partitions.lock); { -- cgit v1.2.3 From 4a7d9f2f96ed2bd00c6f48c5f32d2417525f3510 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 27 Feb 1999 23:41:32 +0000 Subject: . --- serverboot/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 1ae6ff1e..c41eee6f 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,19 @@ +1999-02-27 Roland McGrath + + * def_pager_setup.c (add_paging_file): New arg CHECK_LINUX_SIGNATURE, + pass down to create_paging_partition. + * default_pager.c (create_paging_partition): New arg + CHECK_LINUX_SIGNATURE, pass down new_partition. + (new_partition): New arg CHECK_LINUX_SIGNATURE: if not < 0, + check first page of swap for Linux 2.0 or 2.2 signature page and obey + its bad-block map; if > 0, refuse the partition if no signature found. + * bootstrap.c (main): Add new boot script functions + `add-raw-paging-file', `add-linux-paging-file'. Make those + and `add-paging-file' all call add_paging_file with new + LINUX_SIGNATURE arg of -1, 1, and 0, respectively. + * default_pager.c (create_paging_partition): If new_partition returns + null, return and do nothing more. + 1998-07-25 Roland McGrath * default_pager.c (pager_read_offset): Cast NO_BLOCK twice, to real -- cgit v1.2.3 From 118f1f2c9c33f8a0106cae3bc1c7623c272a6702 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Mar 1999 23:14:07 +0000 Subject: 1999-03-06 Roland McGrath * default_pager.c (default_pager_paging_file): Pass 0 for new LINUX_SIGNATURE arg to add_paging_file. --- serverboot/default_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index dc1e7ff6..eedd105e 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -3536,7 +3536,7 @@ dprintf("bmd %x md %x\n", bootstrap_master_device_port, mdport); #endif if (add) { kr = add_paging_file(bootstrap_master_device_port, - file_name); + file_name, 0); } else { kr = remove_paging_file(file_name); } -- cgit v1.2.3 From da4a1132e7beff676c24b0c8c60301c9a2084e78 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Mar 1999 23:14:49 +0000 Subject: 1999-03-06 Roland McGrath * bootstrap.c (main: scrript_paging_file): Pass LINUX_SIGNATURE arg through to add_paging_file. --- serverboot/bootstrap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 5c4a0393..73a712cb 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -148,7 +148,8 @@ main(argc, argv) int had_a_partition = 0; int script_paging_file (const struct cmd *cmd, int linux_signature) { - if (add_paging_file (bootstrap_master_device_port, cmd->path)) + if (add_paging_file (bootstrap_master_device_port, cmd->path, + linux_signature)) printf ("(serverboot): %s: Cannot add paging file\n", cmd->path); else had_a_partition = 1; -- cgit v1.2.3 From 9737205c6438925b48271bfbe98fe7532822ea86 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Mar 1999 23:14:59 +0000 Subject: 1999-03-06 Roland McGrath * def_pager_setup.c (default_pager_setup): #if 0 out unused function. --- serverboot/def_pager_setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c index cd72acea..194f0355 100644 --- a/serverboot/def_pager_setup.c +++ b/serverboot/def_pager_setup.c @@ -92,6 +92,7 @@ remove_paging_file(file_name) return kr; } +#if 0 /* no longer used */ /* * Set up default pager */ @@ -135,3 +136,4 @@ default_pager_setup(master_device_port, server_dir_name) return TRUE; } +#endif -- cgit v1.2.3 From 7eae5a81c0dcbf55b10898f83d1e27e89e18fd29 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 6 Mar 1999 23:15:35 +0000 Subject: . --- serverboot/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index c41eee6f..850a82dc 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,13 @@ +1999-03-06 Roland McGrath + + * def_pager_setup.c (default_pager_setup): #if 0 out unused function. + + * default_pager.c (default_pager_paging_file): Pass 0 for new + LINUX_SIGNATURE arg to add_paging_file. + + * bootstrap.c (main: scrript_paging_file): Pass LINUX_SIGNATURE arg + through to add_paging_file. + 1999-02-27 Roland McGrath * def_pager_setup.c (add_paging_file): New arg CHECK_LINUX_SIGNATURE, -- cgit v1.2.3 From cf4dca7d198ef7f761e9f8f527343fa4b068f7d7 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 17 Mar 1999 22:00:12 +0000 Subject: 1999-03-17 Gordon Matzigkeit * servers.boot: Clarify the default-pager description, and add a default `$(default-pager)' line. * Makefile: New file. --- debian/ChangeLog | 6 ++++++ debian/Makefile | 28 ++++++++++++++++++++++++++++ debian/TODO | 12 +++++++++--- debian/changelog | 4 ++-- debian/servers.boot | 23 ++++++++++++++--------- 5 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 debian/ChangeLog create mode 100644 debian/Makefile diff --git a/debian/ChangeLog b/debian/ChangeLog new file mode 100644 index 00000000..8d94aa55 --- /dev/null +++ b/debian/ChangeLog @@ -0,0 +1,6 @@ +1999-03-17 Gordon Matzigkeit + + * servers.boot: Clarify the default-pager description, and + add a default `$(default-pager)' line. + + * Makefile: New file. diff --git a/debian/Makefile b/debian/Makefile new file mode 100644 index 00000000..7afd6dc7 --- /dev/null +++ b/debian/Makefile @@ -0,0 +1,28 @@ +# Makefile for Debian Hurd packaging directory +# Copyright (C) 1999 Free Software Foundation, Inc. +# Gordon Matzigkeit , 1999-03-17 +# +# 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. + +dir := debian +makemode := misc + +# Just distribute the files we need. +DIST_FILES = README.Debian TODO changelog conffiles control copyright \ + rules servers.boot + +include ../Makeconf diff --git a/debian/TODO b/debian/TODO index f6e20d74..6ee9d28b 100644 --- a/debian/TODO +++ b/debian/TODO @@ -1,5 +1,11 @@ * daemons/rc -* splitting in multiple packages -* postinst script for translators -shlibdeps! +* Split into multiple packages, so that we can provide virtual + packages that correspond closer to the existing Debian GNU/Linux + ones. + +* A postinstallation script which sets up translators correctly. + +* Library dependencies. + +* Do something with the Texinfo documentation. diff --git a/debian/changelog b/debian/changelog index 02112bda..f96c9388 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ -hurd (19990221-1) unstable; urgency=low +hurd (19990317) unstable; urgency=low - * New version from CVS. * Put shared library symlinks into the hurd-dev package. + * Clarify instructions in provided servers.boot. -- diff --git a/debian/servers.boot b/debian/servers.boot index d25129d8..163389de 100644 --- a/debian/servers.boot +++ b/debian/servers.boot @@ -1,16 +1,21 @@ -# Boot script file for booting Debian GNU/Hurd. Each line specifies a file to -# be loaded by the boot loader (the first word), and actions to be done with it. +# GNU Mach boot script for Debian GNU/Hurd. Each line specifies a +# file for serverboot to load (the first word), and actions to be done +# with it. # First, the bootstrap filesystem. It needs several ports as arguments, # as well as the user flags from the boot loader. /hurd/ext2fs.static --bootflags=${boot-args} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -Tdevice ${root-device} $(task-create) $(task-resume) -# Now the exec server; to load the dynamically-linked exec server program, -# we have the boot loader in fact load and run ld.so, which in turn -# loads and runs /hurd/exec. This task is created, and its task port saved -# in ${exec-task} to be passed to the fs above, but it is left suspended; -# the fs will resume the exec task once it is ready. +# Now the exec server; to load the dynamically-linked exec server +# program, we have serverboot in fact load and run ld.so, which in +# turn loads and runs /hurd/exec. This task is created, and its task +# port saved in ${exec-task} to be passed to the fs above, but it is +# left suspended; the fs will resume the exec task once it is ready. /lib/ld.so.1 /hurd/exec $(exec-task=task-create) -# default pager -#/dev/hd0s2 $(add-paging-file) $(default-pager) +# Have serverboot act as our default pager. +$(default-pager) + +# To swap to a Linux swap partition, use something like the following +# instead of the above $(default-pager) line: +#/dev/hd0s2 $(add-linux-paging-file) $(default-pager) -- cgit v1.2.3 From 70379c15683c178a740f26a2a60e6b904cb2bb66 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 25 Mar 1999 07:44:33 +0000 Subject: 1999-03-25 Roland McGrath * setup.c (setup): Don't complain if the device is a block device. --- ufs-fsck/setup.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index d40cf70b..6309a901 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1996 Free Software Foundation, Inc. +/* + Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -51,7 +51,7 @@ setup (char *dev) struct stat st; int changedsb; size_t bmapsize; - + device_name = dev; if (stat (dev, &st) == -1) @@ -59,9 +59,9 @@ setup (char *dev) error (0, errno, "%s", dev); return 0; } - if (!S_ISCHR (st.st_mode)) + if (!S_ISCHR (st.st_mode) && !S_ISBLK (st.st_mode)) { - problem (1, "%s is not a character device", dev); + problem (1, "%s is not a character or block device", dev); if (! reply ("CONTINUE")) return 0; } @@ -88,7 +88,7 @@ setup (char *dev) if (preen == 0) printf ("\n"); - + lfdir = 0; /* We don't do the alternate superblock stuff here (yet). */ @@ -171,10 +171,10 @@ setup (char *dev) sblock->fs_qfmask = ~sblock->fs_fmask; newinofmt = 0; } - + if (changedsb) writeblock (SBLOCK, sblock, SBSIZE); - + /* Constants */ maxfsblock = sblock->fs_size; maxino = sblock->fs_ncg * sblock->fs_ipg; @@ -189,6 +189,3 @@ setup (char *dev) linkfound = calloc (maxino + 1, sizeof (nlink_t)); return 1; } - - - -- cgit v1.2.3 From 1f6c4b80360d8669e8710ad5e7292d31417a6bbc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 25 Mar 1999 07:45:34 +0000 Subject: . --- ufs-fsck/ChangeLog | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 7df8d5c0..93c2e4af 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +1999-03-25 Roland McGrath + + * setup.c (setup): Don't complain if the device is a block device. + Wed Feb 19 23:10:39 1997 Miles Bader * main.c (argp_program_version): Make const. @@ -17,8 +21,8 @@ Fri Sep 6 16:44:07 1996 Thomas Bushnell, n/BSG Thu Sep 5 11:42:21 1996 Thomas Bushnell, n/BSG * main.c: Include . - (argp_program_version): Define with STANDARD_HURD_VERSION. - + (argp_program_version): Define with STANDARD_HURD_VERSION. + Fri Aug 16 10:25:37 1996 Thomas Bushnell, n/BSG * dir.c (record_directory): Maximum number of block pointers to @@ -46,7 +50,7 @@ Sat Jul 6 19:59:27 1996 Miles Bader * main.c (argp_program_version): New variable. : New include. - + Mon Jul 1 12:55:48 1996 Michael I. Bushnell, p/BSG * pass2.c (pass2): Don't skip empty directories in `.' and `..' @@ -140,7 +144,7 @@ Fri Apr 26 16:20:37 1996 Michael I. Bushnell, p/BSG * inode.c (allocino): Parenthesize test correctly. * fsck.h (swab_disk): Define as constant zero. - + * pass5.c (pass5): If not marked clean, but now it is, then offer to mark it clean. * utilities.c (reply): Set fix_denied anytime we return 0. @@ -158,7 +162,7 @@ Tue Apr 23 10:11:49 1996 Michael I. Bushnell, p/BSG Mon Apr 15 12:51:41 1996 Michael I. Bushnell, p/BSG - * Makefile (vpath tables.c): Find ufs directory in $(top_srcdir). + * Makefile (vpath tables.c): Find ufs directory in $(top_srcdir). Tue Apr 2 09:00:53 1996 Michael I. Bushnell, p/BSG @@ -272,13 +276,13 @@ Mon Oct 17 16:07:56 1994 Michael I Bushnell * utilities.c (getinode): Multiple ino_to_fsbo by sizeof (struct dinode). (write_inode): Likewise. - (getinode): Inode buffer needs to be a full block, not a + (getinode): Inode buffer needs to be a full block, not a fragment. Fri Oct 14 21:07:09 1994 Michael I Bushnell * utilities.c (lastifrag): New variable. - (getinode): Use lastifrag instead of buf; Only I/O new block + (getinode): Use lastifrag instead of buf; Only I/O new block if lastifrag isn't what we want. (write_inode): Likewise. -- cgit v1.2.3 From a0734c3a5be5a15b978fa262ac2bfc2290f58fd9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 15 Apr 1999 05:08:12 +0000 Subject: 1999-04-15 Roland McGrath * control (Provides): Add login. (Replaces, Conflicts): New frobs, listing makedev. --- debian/control | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index f50f9fe3..a6b7a8e9 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,9 @@ Priority: required Section: base Essential: yes Depends: ${shlibs:Depends} -Provides: makedev +Provides: makedev, login +Replaces: makedev +Conflicts: makedev Architecture: hurd-i386 Description: The GNU Hurd This is the GNU Hurd package. It contains essential system software and -- cgit v1.2.3 From a0b535268ec58d094a7e90b05f78e921a1125509 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 15 Apr 1999 05:08:18 +0000 Subject: . --- debian/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 8d94aa55..85960e9b 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +1999-04-15 Roland McGrath + + * control (Provides): Add login. + (Replaces, Conflicts): New frobs, listing makedev. + 1999-03-17 Gordon Matzigkeit * servers.boot: Clarify the default-pager description, and -- cgit v1.2.3 From 659e491de8e00706c19ac3ee8fccb54ea0badb6d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 18 Apr 1999 22:38:35 +0000 Subject: 1999-04-18 Roland McGrath * rules (binary-arch): Fix $ -> $$ and \\ -> \. From Marcus Brinkmann. --- debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index 4c1dee8e..0c89770b 100755 --- a/debian/rules +++ b/debian/rules @@ -107,8 +107,8 @@ binary-arch: build mv debian/tmp/lib/*.a debian/$(package)-dev/usr/lib/. # Create development library links. for file in `cd debian/tmp/lib && ls *.so.*`; do \ - linkname=`echo "$$file" | sed 's/\..*$/.so/'`; \ - ln -sf /lib/$$file debian/$(package)-dev/usr/lib/$$linkname; \\ + linkname=`echo "$$file" | sed 's/\..*$$/.so/'`; \ + ln -sf /lib/$$file debian/$(package)-dev/usr/lib/$$linkname; \ done rm -f debian/tmp/lib/*.so -- cgit v1.2.3 From b69324f4732d8d8de3b6416c4c2be2c3ef5e108c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 18 Apr 1999 22:38:44 +0000 Subject: . --- debian/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 85960e9b..45e2c513 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +1999-04-18 Roland McGrath + + * rules (binary-arch): Fix $ -> $$ and \\ -> \. + From Marcus Brinkmann. + 1999-04-15 Roland McGrath * control (Provides): Add login. -- cgit v1.2.3 From ae93030e7740aef1b3159a9f69f8fc43bf2a022b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 25 Apr 1999 19:30:02 +0000 Subject: 1999-04-25 Roland McGrath * control (Depends): Change shlibs to hurd cause Marcus says so. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index a6b7a8e9..f941d21d 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Package: hurd Priority: required Section: base Essential: yes -Depends: ${shlibs:Depends} +Depends: ${hurd:Depends} Provides: makedev, login Replaces: makedev Conflicts: makedev -- cgit v1.2.3 From 5812fce5e7f2e950b56b805a66b6b34a69dcf5da Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 25 Apr 1999 19:30:06 +0000 Subject: . --- debian/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 45e2c513..f7cb8ab9 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +1999-04-25 Roland McGrath + + * control (Depends): Change shlibs to hurd cause Marcus says so. + 1999-04-18 Roland McGrath * rules (binary-arch): Fix $ -> $$ and \\ -> \. -- cgit v1.2.3 From 68f27e26de3508e78490b2f386c8a117ae347a02 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Mon, 26 Apr 1999 01:39:44 +0000 Subject: *** empty log message *** --- assigns | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 assigns diff --git a/assigns b/assigns new file mode 100644 index 00000000..ec8083c1 --- /dev/null +++ b/assigns @@ -0,0 +1,4 @@ +HURD Mark Kettenis Netherlands 1973 1999-03-11 +Assigns past and future changes (trans/password.c, pfinet/ethernet.c, +pfinet/options.c, minor revisions throughout). +kettenis@gnu.org, kettenis@wins.uva.nl -- cgit v1.2.3 From 72a891925dd88220dc3e88bc359c7c02c7f92f4a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 28 Apr 1999 06:54:22 +0000 Subject: Wed Apr 28 02:44:13 1999 Thomas Bushnell, BSG * conffiles: Add contents of /etc/login. * rules: Add debian/tmp/etc and debian/tmp/etc/login to the list of things to be chmod 0755. * TODO: New item. All of these because Marcus says so. --- debian/ChangeLog | 8 ++++++++ debian/TODO | 2 ++ debian/conffiles | 5 +++++ debian/rules | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index f7cb8ab9..b4ddd3b5 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,11 @@ +Wed Apr 28 02:44:13 1999 Thomas Bushnell, BSG + + * conffiles: Add contents of /etc/login. + * rules: Add debian/tmp/etc and debian/tmp/etc/login to the list + of things to be chmod 0755. + * TODO: New item. + All of these because Marcus says so. + 1999-04-25 Roland McGrath * control (Depends): Change shlibs to hurd cause Marcus says so. diff --git a/debian/TODO b/debian/TODO index 6ee9d28b..32b6182a 100644 --- a/debian/TODO +++ b/debian/TODO @@ -9,3 +9,5 @@ * Library dependencies. * Do something with the Texinfo documentation. + +* Make use of suid-manager for all the setuid binaries. diff --git a/debian/conffiles b/debian/conffiles index 0610053f..baf9f8a4 100644 --- a/debian/conffiles +++ b/debian/conffiles @@ -1 +1,6 @@ /boot/servers.boot +/etc/login/.bash_login +/etc/login/.bashrc +/etc/login/.hushlogin +/etc/login/.profile +/etc/login/README diff --git a/debian/rules b/debian/rules index 0c89770b..be9677ce 100755 --- a/debian/rules +++ b/debian/rules @@ -97,7 +97,7 @@ binary-arch: build -strip --strip-all debian/tmp/hurd/* -strip --strip-all debian/tmp/libexec/* chmod 0644 debian/tmp/lib/lib*.a - chmod 0755 debian/tmp/include debian/tmp/include/hurd debian/tmp/lib debian/tmp/hurd debian/tmp/bin debian/tmp/sbin debian/tmp/dev debian/tmp/libexec + chmod 0755 debian/tmp/include debian/tmp/include/hurd debian/tmp/lib debian/tmp/hurd debian/tmp/bin debian/tmp/sbin debian/tmp/dev debian/tmp/libexec debian/tmp/etc debian/tmp/etc/login # now distribute the files # first the source package -- cgit v1.2.3 From 937e435fbf2df56fda35efb964b3623756ac2f14 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 29 Apr 1999 16:20:08 +0000 Subject: 1999-04-28 Roland McGrath * rules (binary-arch): Add etc, etc/login subdirs to chmod cmd. Use $(addprefix) fn to avoid repetition. --- debian/rules | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index be9677ce..5480046e 100755 --- a/debian/rules +++ b/debian/rules @@ -97,7 +97,10 @@ binary-arch: build -strip --strip-all debian/tmp/hurd/* -strip --strip-all debian/tmp/libexec/* chmod 0644 debian/tmp/lib/lib*.a - chmod 0755 debian/tmp/include debian/tmp/include/hurd debian/tmp/lib debian/tmp/hurd debian/tmp/bin debian/tmp/sbin debian/tmp/dev debian/tmp/libexec debian/tmp/etc debian/tmp/etc/login + chmod 0755 $(addprefix debian/tmp/, \ + include include/hurd \ + lib hurd bin sbin \ + dev libexec etc etc/login) # now distribute the files # first the source package -- cgit v1.2.3 From a45f97ca1a2a30f16fd5e329160c8dae7c7b6392 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 29 Apr 1999 16:20:14 +0000 Subject: . --- debian/ChangeLog | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index b4ddd3b5..e2eb5fe6 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,8 +1,13 @@ +1999-04-28 Roland McGrath + + * rules (binary-arch): Add etc, etc/login subdirs to chmod cmd. + Use $(addprefix) fn to avoid repetition. + + * conffiles: Add /etc/login files .bash_login, .bashrc, .hushlogin, + .profile and README. + Wed Apr 28 02:44:13 1999 Thomas Bushnell, BSG - * conffiles: Add contents of /etc/login. - * rules: Add debian/tmp/etc and debian/tmp/etc/login to the list - of things to be chmod 0755. * TODO: New item. All of these because Marcus says so. -- cgit v1.2.3 From d3fe02c2d320bfde339c87981c32f1d9b3581952 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 30 Apr 1999 11:04:07 +0000 Subject: 1998-09-06 OKUJI Yoshinori * bunzip2.c: New file. * load.c (GZIP) (BZIP2): New cpp constants. (boot_script_exec_cmd): If GZIP is defined, gunzip engine is enabled. If BZIP2 is defined, bunzip2 engine is enabled. * Makefile (SRCS): Add bunzip2.c. (UNZIP_OBJS): Add do-bunzip2.o. (CPPFLAGS): Add -DGZIP, -DBZIP2 and -DSMALL_BZIP2. 1998-09-03 OKUJI Yoshinori * gunzip.c: New file. Copy libstore/gunzip.c and modify for use in serverboot. * load.c (struct stuff): Add members, image_addr and image_size. (mem_read) (mem_read_exec): New functions. (boot_script_exec_cmd): Add gzexe feature. * Makefile: Add unzip stuffs. --- serverboot/ChangeLog | 19 ++++++ serverboot/Makefile | 16 +++-- serverboot/bunzip2.c | 169 +++++++++++++++++++++++++++++++++++++++++++++ serverboot/gunzip.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ serverboot/load.c | 134 ++++++++++++++++++++++++++++++++++++ 5 files changed, 522 insertions(+), 4 deletions(-) create mode 100644 serverboot/bunzip2.c create mode 100644 serverboot/gunzip.c diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 850a82dc..715145c4 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,22 @@ +1998-09-06 OKUJI Yoshinori + + * bunzip2.c: New file. + * load.c (GZIP) (BZIP2): New cpp constants. + (boot_script_exec_cmd): If GZIP is defined, gunzip engine is enabled. + If BZIP2 is defined, bunzip2 engine is enabled. + * Makefile (SRCS): Add bunzip2.c. + (UNZIP_OBJS): Add do-bunzip2.o. + (CPPFLAGS): Add -DGZIP, -DBZIP2 and -DSMALL_BZIP2. + +1998-09-03 OKUJI Yoshinori + + * gunzip.c: New file. + Copy libstore/gunzip.c and modify for use in serverboot. + * load.c (struct stuff): Add members, image_addr and image_size. + (mem_read) (mem_read_exec): New functions. + (boot_script_exec_cmd): Add gzexe feature. + * Makefile: Add unzip stuffs. + 1999-03-06 Roland McGrath * def_pager_setup.c (default_pager_setup): #if 0 out unused function. diff --git a/serverboot/Makefile b/serverboot/Makefile index 12ff6375..d2ab975d 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -21,10 +21,7 @@ makemode := utility SRCS = bootstrap.c ffs_compat.c load.c wiring.c def_pager_setup.c \ ffs_file_io.c minix_ffs_compat.c default_pager.c file_io.c\ minix_file_io.c ext2_file_io.c kalloc.c strfcns.c exec.c \ - panic.c elf-load.c -OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ - default_pagerServer.o excServer.o bootstrapServer.o \ - memory_object_defaultServer.o + panic.c elf-load.c gunzip.c bunzip2.c LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h ext2_fs.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 @@ -32,8 +29,19 @@ target = serverboot HURDLIBS = threads installationdir = $(prefix)/boot +UNZIP_OBJS = unzip.o inflate.o util.o do-bunzip2.o +OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ + default_pagerServer.o excServer.o bootstrapServer.o \ + memory_object_defaultServer.o $(UNZIP_OBJS) + vpath boot_script.c $(srcdir)/../boot +# Look for zip stuff +VPATH += $(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 + MIGSFLAGS = -DSEQNOS LDFLAGS += -static diff --git a/serverboot/bunzip2.c b/serverboot/bunzip2.c new file mode 100644 index 00000000..9f79ade5 --- /dev/null +++ b/serverboot/bunzip2.c @@ -0,0 +1,169 @@ +/* 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 + 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 +#include +#include +#include +#include + +#include + +#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/gunzip.c b/serverboot/gunzip.c new file mode 100644 index 00000000..f74da111 --- /dev/null +++ b/serverboot/gunzip.c @@ -0,0 +1,188 @@ +/* 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 + 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 +#include +#include +#include +#include + +#include + +/* 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 index a4bb43c3..878bddb9 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -41,6 +41,10 @@ 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; @@ -149,6 +153,86 @@ static int prog_read_exec(void *handle, vm_offset_t file_ofs, vm_size_t file_siz 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 */ @@ -216,6 +300,56 @@ boot_script_exec_cmd (task_t 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 *, void **, 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 *, void **, 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("(serverboot) exec_load %s: error %d", namebuf, result); #if 0 -- cgit v1.2.3 From 7709e52886ecdbc1a316dbe37f30eefe2a9b10dd Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 May 1999 19:54:32 +0000 Subject: 1999-05-02 Roland McGrath * main.c (main): Remove bogus uninitialized variable ERR. --- ufs/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 29b22d11..cc39019d 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,98,99 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 @@ -158,7 +158,6 @@ diskfs_append_args (char **argz, unsigned *argz_len) int main (int argc, char **argv) { - error_t err; mach_port_t bootstrap; /* Initialize the diskfs library, parse arguments, and open the store. @@ -167,7 +166,7 @@ main (int argc, char **argv) &store_parsed, &bootstrap); if (store->block_size > DEV_BSIZE) - error (4, err, "%s: Bad device block size %d (should be <= %d)", + error (4, 0, "%s: Bad device block size %d (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); if (store->size < SBSIZE + SBOFF) error (5, 0, "%s: Disk too small (%ld bytes)", diskfs_disk_name, -- cgit v1.2.3 From 7b4bf7ce4b982d503d8499b7beeaec4d3d9bdc19 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 May 1999 19:54:37 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 7d6c0800..16ae4238 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +1999-05-02 Roland McGrath + + * main.c (main): Remove bogus uninitialized variable ERR. + 1999-01-23 Roland McGrath * main.c (main): Use diskfs_init_main. -- cgit v1.2.3 From 55b7d72f9bf1b0d41a84be1d3669c39e74135b0a Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 6 May 1999 14:35:19 +0000 Subject: Thu May 6 10:25:27 1999 Thomas Bushnell, BSG * utilities.c (pextend): Free MORE before returning. * dir.c (linkup): Don't free tempname until after we're done using it in the call to warning. Reported by Katsuya Tanaka (tanaka@boarderz.com). --- ufs-fsck/ChangeLog | 7 +++++++ ufs-fsck/dir.c | 4 ++-- ufs-fsck/utilities.c | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 93c2e4af..0fede606 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,10 @@ +Thu May 6 10:25:27 1999 Thomas Bushnell, BSG + + * utilities.c (pextend): Free MORE before returning. + * dir.c (linkup): Don't free tempname until after we're done using + it in the call to warning. + Reported by Katsuya Tanaka (tanaka@boarderz.com). + 1999-03-25 Roland McGrath * setup.c (setup): Don't complain if the device is a block device. diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index b058fe9e..04541c4f 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -1,5 +1,5 @@ /* Directory management subroutines - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -519,8 +519,8 @@ linkup (ino_t ino, ino_t parent) } if (search_failed) { - free (tempname); warning (1, "FAILURE SEARCHING FOR `%s' IN `%s'", tempname, lfname); + free (tempname); return 0; } if (!makeentry (lfdir, ino, tempname)) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 4c515f61..2ccade06 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -1,5 +1,5 @@ /* Miscellaneous functions for fsck - Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1999 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -322,6 +322,7 @@ pextend (char *fmt, ...) strcpy (concat + strlen (concat), more); prob->desc = concat; + free (more); } /* Like problem, but as if immediately followed by pfail. */ -- cgit v1.2.3 From 6c4bc2723fa9f471045d2e1f0bfb9f67d4b87fd5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 May 1999 22:14:36 +0000 Subject: 1999-05-15 Roland McGrath * bootstrap.c (main): Remove vars HAD_A_PARITION, DOING_DEFAULT_PAGER. Remove $(default-pager) boot script tag. We always stick around and act as the default pager (this was already the case, just removed some dead code). Don't print anything about having no swap partitions, since that is a fine way to boot (just use swapon later). --- serverboot/bootstrap.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 73a712cb..d103e60f 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -144,15 +144,11 @@ main(argc, argv) int argc; char **argv; { - int doing_default_pager = 0; - int had_a_partition = 0; int script_paging_file (const struct cmd *cmd, int linux_signature) { if (add_paging_file (bootstrap_master_device_port, cmd->path, linux_signature)) printf ("(serverboot): %s: Cannot add paging file\n", cmd->path); - else - had_a_partition = 1; return 0; } int script_add_paging_file (const struct cmd *cmd, int *val) @@ -167,11 +163,6 @@ main(argc, argv) { return script_paging_file (cmd, 1); } - int script_default_pager (const struct cmd *cmd, int *val) - { - doing_default_pager = 1; - return 0; - } register kern_return_t result; struct file scriptf; @@ -329,8 +320,6 @@ main(argc, argv) || boot_script_define_function ("add-linux-paging-file", VAL_NONE, &script_add_linux_paging_file) - || boot_script_define_function ("default-pager", VAL_NONE, - &script_default_pager) ) panic ("bootstrap: error setting boot script variables"); @@ -403,16 +392,6 @@ main(argc, argv) } #endif - if (had_a_partition) - doing_default_pager = 1; - else - printf ("(serverboot): Running without any paging\n"); - -#if 0 /* Always stick around to handle swapon requests */ - if (! doing_default_pager) - task_terminate (mach_task_self ()); -#endif - default_pager_initialize (bootstrap_master_host_port); /* -- cgit v1.2.3 From 658dc14c319104e6d11e425d1cd3ceab5a754ea8 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 May 1999 22:14:40 +0000 Subject: 1999-05-15 Roland McGrath * default_pager.c (new_partition): Print out partition name and size when no signature. --- serverboot/default_pager.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index eedd105e..8fb8dfe1 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -303,7 +303,7 @@ new_partition (const char *name, struct file_direct *fdp, printf (" (excludes %uk marked bad)", hdr->nr_badpages * (LINUX_PAGE_SIZE / 1024)); if (waste != 0) - printf (" (excludes %uk pages at end of partition)", + printf (" (excludes %uk at end of partition)", waste * (LINUX_PAGE_SIZE / 1024)); printf ("\n"); } @@ -313,9 +313,15 @@ new_partition (const char *name, struct file_direct *fdp, { part = 0; printf ("(default pager): " - "Cannot find Linux swap signature page! SKIPPING %s!", - name); + "Cannot find Linux swap signature page! " + "SKIPPING %s (%uk partition)!", + name, part->total_size * (vm_page_size / 1024)); } + else + printf("(default pager): " + "Paging to raw partition %s (%uk paging space)\n", + name, part->total_size * (vm_page_size / 1024)); + vm_deallocate(mach_task_self(), raddr, rsize); return part; -- cgit v1.2.3 From 0605a5a60dad2d494dfb72a04cd7e481c072223d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 May 1999 22:14:52 +0000 Subject: . --- serverboot/ChangeLog | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 715145c4..0048e547 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,14 @@ +1999-05-15 Roland McGrath + + * bootstrap.c (main): Remove vars HAD_A_PARITION, DOING_DEFAULT_PAGER. + Remove $(default-pager) boot script tag. We always stick around and + act as the default pager (this was already the case, just removed some + dead code). Don't print anything about having no swap partitions, + since that is a fine way to boot (just use swapon later). + + * default_pager.c (new_partition): Print out partition name and size + when no signature. + 1998-09-06 OKUJI Yoshinori * bunzip2.c: New file. @@ -7,16 +18,16 @@ * Makefile (SRCS): Add bunzip2.c. (UNZIP_OBJS): Add do-bunzip2.o. (CPPFLAGS): Add -DGZIP, -DBZIP2 and -DSMALL_BZIP2. - + 1998-09-03 OKUJI Yoshinori - * gunzip.c: New file. + * gunzip.c: New file. Copy libstore/gunzip.c and modify for use in serverboot. * load.c (struct stuff): Add members, image_addr and image_size. (mem_read) (mem_read_exec): New functions. (boot_script_exec_cmd): Add gzexe feature. * Makefile: Add unzip stuffs. - + 1999-03-06 Roland McGrath * def_pager_setup.c (default_pager_setup): #if 0 out unused function. -- cgit v1.2.3 From 69fce3bb002e52d96dfcf700a95d6abe71537a01 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 May 1999 23:13:32 +0000 Subject: 1999-05-15 Roland McGrath * default_pager.c (new_partition): Check if requested partition is already in our list, and refuse it. --- serverboot/default_pager.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 8fb8dfe1..66ff94a0 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -171,6 +171,24 @@ new_partition (const char *name, struct file_direct *fdp, vm_offset_t raddr; mach_msg_type_number_t rsize; int rc; + unsigned int id = part_id(name); + + mutex_lock(&all_partitions.lock); + { + unsigned int i; + for (i = 0; i < all_partitions.n_partitions; i++) + { + part = partition_of(i); + if (part && part->id == id) + { + printf ("(default pager): Already paging to partition %s!\n", + name); + mutex_unlock(&all_partitions.lock); + return 0; + } + } + } + mutex_unlock(&all_partitions.lock); size = atop(fdp->fd_size * fdp->fd_bsize); bmsize = howmany(size, NB_BM) * sizeof(bm_entry_t); @@ -179,7 +197,7 @@ new_partition (const char *name, struct file_direct *fdp, mutex_init(&part->p_lock); part->total_size = size; part->free = size; - part->id = part_id(name); + part->id = id; part->bitmap = (bm_entry_t *)kalloc(bmsize); part->going_away= FALSE; part->file = fdp; -- cgit v1.2.3 From f8dade1b9a0082d32051adcde9a208564fa8df76 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 May 1999 23:13:39 +0000 Subject: . --- serverboot/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 0048e547..e3041954 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,8 @@ 1999-05-15 Roland McGrath + * default_pager.c (new_partition): Check if requested partition is + already in our list, and refuse it. + * bootstrap.c (main): Remove vars HAD_A_PARITION, DOING_DEFAULT_PAGER. Remove $(default-pager) boot script tag. We always stick around and act as the default pager (this was already the case, just removed some -- cgit v1.2.3 From 01815d9336f65407027a7875cc7eedf5eec5712d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 20 May 1999 06:44:53 +0000 Subject: 1999-05-20 Roland McGrath * default_pager.c (new_partition): Fix SWAP-SPACE page handling. --- serverboot/default_pager.c | 97 +++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 66ff94a0..7c5f60d1 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -205,7 +205,12 @@ new_partition (const char *name, struct file_direct *fdp, bzero((char *)part->bitmap, bmsize); if (check_linux_signature < 0) - return part; + { + printf("(default pager): " + "Paging to raw partition %s (%uk paging space)\n", + name, part->total_size * (vm_page_size / 1024)); + return part; + } #define LINUX_PAGE_SIZE 4096 /* size of pages in Linux swap partitions */ rc = page_read_file_direct(part->file, @@ -223,39 +228,71 @@ new_partition (const char *name, struct file_direct *fdp, /* The partition's first page has a Linux swap signature. This means the beginning of the page contains a bitmap of good pages, and all others are bad. */ - unsigned int i, j, bad; - printf("(default pager): Found Linux 2.0 swap signature in %s...", + unsigned int i, j, bad, waste, max; + + printf("(default pager): Found Linux 2.0 swap signature in %s\n", name); - part->bitmap[0] |= 1; /* first page unusable */ - part->free--; - bad = 0; + + /* The first page, and the pages corresponding to the bits + occupied by the signature in the final 10 bytes of the page, + are always unavailable ("bad"). */ + *(u_int32_t *)raddr &= ~(u_int32_t) 1; memset((char *) raddr + LINUX_PAGE_SIZE-10, 0, 10); - for (i = 0; i < LINUX_PAGE_SIZE / sizeof(bm_entry_t); ++i) + + max = LINUX_PAGE_SIZE / sizeof(u_int32_t); + if (max > (part->total_size + 31) / 32) + max = (part->total_size + 31) / 32; + + bad = 0; + for (i = 0; i < max; ++i) { - bm_entry_t bm = ((bm_entry_t *) raddr)[i]; - if (bm == BM_MASK) + u_int32_t bm = ((u_int32_t *) raddr)[i]; + if (bm == ~(u_int32_t) 0) continue; /* There are some zero bits in this word. */ - for (j = 0; j < NB_BM; ++j) + for (j = 0; j < 32; ++j) if ((bm & (1 << j)) == 0) { + unsigned int p = i*32 + j; + if (p >= part->total_size) + break; ++bad; - part->bitmap[i] |= 1 << j; + part->bitmap[p / NB_BM] |= 1 << (p % NB_BM); } } part->free -= bad; - printf ("%dk swap-space (excludes %dk marked bad)\n", - part->free * (LINUX_PAGE_SIZE / 1024), - bad * (LINUX_PAGE_SIZE / 1024)); - if (part->total_size > 8 * LINUX_PAGE_SIZE) + + --bad; /* Don't complain about first page. */ + waste = part->total_size - (8 * (LINUX_PAGE_SIZE-10)); + if (waste > 0) { - unsigned int waste = part->total_size - (8 * LINUX_PAGE_SIZE); - part->free -= waste; - part->total_size -= waste; - printf("\ -(default pager): NOTE: wasting last %dk of %s past Linux max swapfile size\n", - waste * (LINUX_PAGE_SIZE / 1024), name); + /* The wasted pages were already marked "bad". */ + bad -= waste; + if (bad > 0) + printf("\ +(default pager): Paging to %s, %dk swap-space (%dk bad, %dk wasted at end)\n", + name, + part->free * (LINUX_PAGE_SIZE / 1024), + bad * (LINUX_PAGE_SIZE / 1024), + waste * (LINUX_PAGE_SIZE / 1024)); + else + printf("\ +(default pager): Paging to %s, %dk swap-space (%dk wasted at end)\n", + name, + part->free * (LINUX_PAGE_SIZE / 1024), + waste * (LINUX_PAGE_SIZE / 1024)); } + else if (bad > 0) + printf("\ +(default pager): Paging to %s, %dk swap-space (excludes %dk marked bad)\n", + name, + part->free * (LINUX_PAGE_SIZE / 1024), + bad * (LINUX_PAGE_SIZE / 1024)); + else + printf("\ +(default pager): Paging to %s, %dk swap-space\n", + name, + part->free * (LINUX_PAGE_SIZE / 1024)); } else if (!memcmp("SWAPSPACE2", (char *) raddr + LINUX_PAGE_SIZE-10, 10)) @@ -285,13 +322,16 @@ new_partition (const char *name, struct file_direct *fdp, printf ("version %u unknown! SKIPPING %s!\n", hdr->version, name); + vm_deallocate(mach_task_self(), raddr, rsize); + kfree(part->bitmap, bmsize); + kfree(part, sizeof *part); return 0; } else - printf ("version %u unknown! IGNORING SIGNATURE PAGE!" - " %dk swap-space\n", - hdr->version, - part->free * (LINUX_PAGE_SIZE / 1024)); + printf ("version %u unknown! IGNORING SIGNATURE PAGE!" + " %dk swap-space\n", + hdr->version, + part->free * (LINUX_PAGE_SIZE / 1024)); break; case 1: @@ -308,11 +348,12 @@ new_partition (const char *name, struct file_direct *fdp, { waste = part->total_size - hdr->last_page; part->total_size = hdr->last_page; + part->free = part->total_size - 1; } for (i = 0; i < hdr->nr_badpages; ++i) { const u_int32_t bad = hdr->badpages[i]; - part->bitmap[bad / NB_BM] |= 1 << (i % NB_BM); + part->bitmap[bad / NB_BM] |= 1 << (bad % NB_BM); part->free--; } printf ("%uk swap-space", @@ -329,11 +370,13 @@ new_partition (const char *name, struct file_direct *fdp, } else if (check_linux_signature) { - part = 0; printf ("(default pager): " "Cannot find Linux swap signature page! " "SKIPPING %s (%uk partition)!", name, part->total_size * (vm_page_size / 1024)); + kfree(part->bitmap, bmsize); + kfree(part, sizeof *part); + part = 0; } else printf("(default pager): " -- cgit v1.2.3 From 71915ed295d1e10dec825e9c98f9109d0561c45e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 20 May 1999 06:45:00 +0000 Subject: . --- serverboot/ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index e3041954..1574a2d3 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,18 @@ +1999-05-20 Roland McGrath + + * default_pager.c (new_partition): Fix SWAP-SPACE page handling. + +1999-05-17 Roland McGrath + + * default_pager.c (new_partition): Deallocate signature page when + rejecting it for wrong version. Fix typo in SWAPSPACE2 v1 bad block + bitmap handling. Free bitmap and partition structure if we reject the + partition signature. + Reported by Kalle Olavi Niemitalo . + + * default_pager.c (new_partition): Print out for + CHECK_LINUX_SIGNATURE<0 case. + 1999-05-15 Roland McGrath * default_pager.c (new_partition): Check if requested partition is -- cgit v1.2.3 From 7f087a0efbc1507b1cbde6d4264648b20540bdda Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 23 May 1999 20:54:51 +0000 Subject: 1999-05-23 Roland McGrath * default_pager.c (new_partition): Fix arg order in printf for linux-2.2 signature page. --- serverboot/default_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 7c5f60d1..09bff076 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -309,7 +309,7 @@ new_partition (const char *name, struct file_direct *fdp, printf("\ (default pager): Found Linux 2.2 swap signature (v%u) in %s...", - name, hdr->version); + hdr->version, name); part->bitmap[0] |= 1; /* first page unusable */ part->free--; -- cgit v1.2.3 From dbe70c0074b4211dc9adfb9717d609170084052c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 23 May 1999 20:55:02 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 1574a2d3..bdf79946 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1999-05-23 Roland McGrath + + * default_pager.c (new_partition): Fix arg order in printf for + linux-2.2 signature page. + 1999-05-20 Roland McGrath * default_pager.c (new_partition): Fix SWAP-SPACE page handling. -- cgit v1.2.3 From a9c4e08360c60230800960b90d79788575fa33c1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 01:47:45 +0000 Subject: 1999-05-29 Roland McGrath * rules (binary-arch): Don't remove root and etc dirs. --- debian/rules | 3 --- 1 file changed, 3 deletions(-) diff --git a/debian/rules b/debian/rules index 5480046e..d77183d5 100755 --- a/debian/rules +++ b/debian/rules @@ -121,9 +121,6 @@ binary-arch: build # now the shared libs and other stuff $(make_directory) debian/tmp/{DEBIAN,usr/doc/$(package)} -# kill some nonsense - rm -fr debian/tmp/root - -rm -f debian/tmp/etc/* # Only found in CVS, not the distribution. # $(install_file) BUGS debian/tmp$(DOCDIR) # $(install_file) TODO debian/tmp$(DOCDIR) -- cgit v1.2.3 From 0869ffbf625c1ae9b608f4a69ffa10d1c42304d3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 01:47:46 +0000 Subject: 1999-05-29 Roland McGrath * conffiles: Add /etc/ttys. --- debian/conffiles | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/conffiles b/debian/conffiles index baf9f8a4..61edd051 100644 --- a/debian/conffiles +++ b/debian/conffiles @@ -1,4 +1,5 @@ /boot/servers.boot +/etc/ttys /etc/login/.bash_login /etc/login/.bashrc /etc/login/.hushlogin -- cgit v1.2.3 From d1d86177761eedee8267b48a1795440c30d55722 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 01:49:07 +0000 Subject: . --- debian/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index e2eb5fe6..d611996a 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,9 @@ +1999-05-29 Roland McGrath + + * rules (binary-arch): Don't remove root and etc dirs. + + * conffiles: Add /etc/ttys. + 1999-04-28 Roland McGrath * rules (binary-arch): Add etc, etc/login subdirs to chmod cmd. -- cgit v1.2.3 From 61854b5b1b5d082f9cfdf3c28e6761da3f85c978 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 03:01:22 +0000 Subject: 1999-05-29 Roland McGrath * bootstrap.c (main): Define $(serverboot) function for "serverboot controls", control command replacing the pathname. For command "die", terminate ourselves after running the boot script, no default pager. --- serverboot/bootstrap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index d103e60f..58096f21 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -144,6 +144,7 @@ main(argc, argv) int argc; char **argv; { + int die = 0; int script_paging_file (const struct cmd *cmd, int linux_signature) { if (add_paging_file (bootstrap_master_device_port, cmd->path, @@ -163,6 +164,15 @@ main(argc, argv) { return script_paging_file (cmd, 1); } + int script_serverboot_ctl (const struct cmd *cmd, int *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; + } register kern_return_t result; struct file scriptf; @@ -320,6 +330,9 @@ main(argc, argv) || boot_script_define_function ("add-linux-paging-file", VAL_NONE, &script_add_linux_paging_file) + || boot_script_define_function ("serverboot", + VAL_NONE, + &script_serverboot_ctl) ) panic ("bootstrap: error setting boot script variables"); @@ -392,6 +405,13 @@ main(argc, argv) } #endif + if (die) + { + printf ("(serverboot): terminating, not becoming default pager\n"); + while (1) + task_terminate (mach_task_self ()); + } + default_pager_initialize (bootstrap_master_host_port); /* -- cgit v1.2.3 From 89d54f9fd702591d6f1d76eeebab3b4f451de3b4 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 03:01:26 +0000 Subject: . --- serverboot/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index bdf79946..7649cc45 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,9 @@ +1999-05-29 Roland McGrath + + * bootstrap.c (main): Define $(serverboot) function for "serverboot + controls", control command replacing the pathname. For command "die", + terminate ourselves after running the boot script, no default pager. + 1999-05-23 Roland McGrath * default_pager.c (new_partition): Fix arg order in printf for -- cgit v1.2.3 From fe9a97ce96af057ebd6ecdfda0223d2e20d7806f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:25 +0000 Subject: 1999-06-01 Marcus Brinkmann * control: Add Replaces, Conflicts login, as done with makedev. --- debian/control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index f941d21d..9bdfb88e 100644 --- a/debian/control +++ b/debian/control @@ -10,8 +10,8 @@ Section: base Essential: yes Depends: ${hurd:Depends} Provides: makedev, login -Replaces: makedev -Conflicts: makedev +Replaces: makedev, login +Conflicts: makedev, login Architecture: hurd-i386 Description: The GNU Hurd This is the GNU Hurd package. It contains essential system software and -- cgit v1.2.3 From defd3331c298862ebd19e444328a38d7409b55d8 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:28 +0000 Subject: 1999-06-01 Marcus Brinkmann * changelog: Update to reflect the Debian releases done. --- debian/changelog | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index f96c9388..638509c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,43 @@ -hurd (19990317) unstable; urgency=low +hurd (19990601) unstable; urgency=low + + * New snapshot from CVS. + + -- Marcus Brinkmann Tue, 1 Jun 1999 19:25:37 +0200 + +hurd (19990524) unstable; urgency=low + + * New snapshot from CVS. + + -- Marcus Brinkmann Mon, 24 May 1999 15:09:45 +0200 + +hurd (19990523) unstable; urgency=low + + * New snapshot from CVS, fixes: #38062, #37670, #37878, #37944. + + -- Marcus Brinkmann Mon, 24 May 1999 01:08:26 +0200 + +hurd (19990517fixed) unstable; urgency=low + + * debian/shlibs: corrected. + * exec/hashexec.c: Applied patch by Roland to make it work. + + -- Marcus Brinkmann Sun, 17 May 1999 00:25:11 +0200 + +hurd (19990517) unstable; urgency=low + + * New snapshot from CVS. + * Add shlibs file. + + -- Marcus Brinkmann Sun, 16 May 1999 15:28:09 +0200 + +hurd (19990425-1) unstable; urgency=low * Put shared library symlinks into the hurd-dev package. * Clarify instructions in provided servers.boot. + * libfshelp/fetch-root.c: De-patched a change by tb which produced + strange errors. - -- + -- Marcus Brinkmann Thu, 29 Apr 1999 22:47:51 +0200 hurd (19990212-2) unstable; urgency=low -- cgit v1.2.3 From 1f4209980e72485818f05abc81971aa55e593811 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:29 +0000 Subject: 1999-06-01 Marcus Brinkmann * servers.boot: Remove obsolete $(default-pager) tag. --- debian/servers.boot | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/debian/servers.boot b/debian/servers.boot index 163389de..1ddd7b91 100644 --- a/debian/servers.boot +++ b/debian/servers.boot @@ -13,9 +13,7 @@ # left suspended; the fs will resume the exec task once it is ready. /lib/ld.so.1 /hurd/exec $(exec-task=task-create) -# Have serverboot act as our default pager. -$(default-pager) +# To swap to a Linux swap partition, use something like the following. +# You can also add swap partitions to /etc/fstab. +#/dev/hd0s2 $(add-linux-paging-file) -# To swap to a Linux swap partition, use something like the following -# instead of the above $(default-pager) line: -#/dev/hd0s2 $(add-linux-paging-file) $(default-pager) -- cgit v1.2.3 From f6b3d15394aceb4878641ceca8c0488b3a169b69 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:31 +0000 Subject: 1999-06-01 Marcus Brinkmann * TODO: Remove entry about shared library dependencies (see below). Remove entry about suid-manager. We don't need to register binaries which must be suid to operate. --- debian/TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/debian/TODO b/debian/TODO index 32b6182a..bc703349 100644 --- a/debian/TODO +++ b/debian/TODO @@ -6,8 +6,4 @@ * A postinstallation script which sets up translators correctly. -* Library dependencies. - * Do something with the Texinfo documentation. - -* Make use of suid-manager for all the setuid binaries. -- cgit v1.2.3 From 03ed384e37b129b77d728b1b6e5358e86f2b10fe Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:34 +0000 Subject: 1999-06-01 Marcus Brinkmann * shlibs.local: New file. This is a work around needed for cross compilation, so dpkg-shlibdeps does not make the Hurd package dependant on itself. --- debian/shlibs.local | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 debian/shlibs.local diff --git a/debian/shlibs.local b/debian/shlibs.local new file mode 100644 index 00000000..b4fbdcc5 --- /dev/null +++ b/debian/shlibs.local @@ -0,0 +1,16 @@ +libshouldbeinlibc 0.2 +libftpconn 0.2 +libports 0.2 +libmom 0.2 +libthreads 0.2 +libhurdbugaddr 0.2 +libstore 0.2 +libihash 0.2 +libpipe 0.2 +libtrivfs 0.2 +libpager 0.2 +libnetfs 0.2 +libiohelp 0.2 +libfshelp 0.2 +libps 0.2 +libdiskfs 0.2 -- cgit v1.2.3 From 6fc257abb1d4189e6edc19beda136920405bb515 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:38 +0000 Subject: 1999-06-01 Marcus Brinkmann * shlibs: New file. This makes Debian packages which use Hurd libraries dependant on the Hurd package. * rules: Add shlibs to the Hurd package. * shlibs.local: New file. This is a work around needed for cross compilation, so dpkg-shlibdeps does not make the Hurd package dependant on itself. --- debian/shlibs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 debian/shlibs diff --git a/debian/shlibs b/debian/shlibs new file mode 100644 index 00000000..cfa417e5 --- /dev/null +++ b/debian/shlibs @@ -0,0 +1,16 @@ +libshouldbeinlibc 0.2 hurd +libftpconn 0.2 hurd +libports 0.2 hurd +libmom 0.2 hurd +libthreads 0.2 hurd +libhurdbugaddr 0.2 hurd +libstore 0.2 hurd +libihash 0.2 hurd +libpipe 0.2 hurd +libtrivfs 0.2 hurd +libpager 0.2 hurd +libnetfs 0.2 hurd +libiohelp 0.2 hurd +libfshelp 0.2 hurd +libps 0.2 hurd +libdiskfs 0.2 hurd -- cgit v1.2.3 From c9a6c4460460bca6b780ea8170587da01335d2c9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:41 +0000 Subject: 1999-06-01 Marcus Brinkmann * shlibs: New file. This makes Debian packages which use Hurd libraries dependant on the Hurd package. * rules: Add shlibs to the Hurd package. --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index d77183d5..4e5ce53c 100755 --- a/debian/rules +++ b/debian/rules @@ -138,6 +138,7 @@ binary-arch: build $(make_directory) debian/tmp/servers $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles + $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs dpkg-shlibdeps -p$(package) debian/tmp/bin/* debian/tmp/libexec/* debian/tmp/hurd/* debian/tmp/sbin/* dpkg-gencontrol -p$(package) -Pdebian/tmp -- cgit v1.2.3 From 22709b1d6814e0a516a500f4e6385e02e9540f78 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 1999 22:07:44 +0000 Subject: . --- debian/ChangeLog | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index d611996a..c5084a4d 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,23 @@ +1999-06-01 Marcus Brinkmann + + * TODO: Remove entry about shared library dependencies (see below). + Remove entry about suid-manager. We don't need to register binaries + which must be suid to operate. + + * shlibs: New file. This makes Debian packages which use Hurd + libraries dependant on the Hurd package. + * rules: Add shlibs to the Hurd package. + + * changelog: Update to reflect the Debian releases done. + + * servers.boot: Remove obsolete $(default-pager) tag. + + * control: Add Replaces, Conflicts login, as done with makedev. + + * shlibs.local: New file. This is a work around needed for cross + compilation, so dpkg-shlibdeps does not make the Hurd package + dependant on itself. + 1999-05-29 Roland McGrath * rules (binary-arch): Don't remove root and etc dirs. -- cgit v1.2.3 From ee7847780e05f6d78ae014bad1ce798b370713ef Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jun 1999 06:56:34 +0000 Subject: 1999-06-02 Roland McGrath * load.c (boot_script_exec_cmd): Copy environment from our `environ' onto the new task's stack along with its arguments. --- serverboot/load.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/serverboot/load.c b/serverboot/load.c index 878bddb9..3898eac6 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -244,6 +244,9 @@ boot_script_exec_cmd (task_t user_task, { 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; @@ -273,15 +276,21 @@ boot_script_exec_cmd (task_t user_task, panic("openi %d", 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 - * dummy 0 pointer to environment variables + * environment variables + * trailing 0 pointer * and align to integer boundary */ - arg_len += sizeof(integer_t) + (2 + arg_count) * sizeof(char *); + 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); /* @@ -307,7 +316,7 @@ boot_script_exec_cmd (task_t user_task, * It might be gzip file. */ int err; - extern int + extern int serverboot_gunzip(struct file *, void **, size_t *); err = serverboot_gunzip(st.fp, @@ -332,7 +341,7 @@ boot_script_exec_cmd (task_t user_task, * It might be bzip2 file. */ int err; - extern int + extern int serverboot_bunzip2(struct file *, void **, size_t *); err = serverboot_bunzip2(st.fp, @@ -426,9 +435,11 @@ boot_script_exec_cmd (task_t user_task, * 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); @@ -442,13 +453,15 @@ boot_script_exec_cmd (task_t user_task, */ 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; - /* - * last, the trailing 0 argument and a null environment pointer. - */ - *k_ap++ = (char *)0; + 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. -- cgit v1.2.3 From 7eb2c13fb8d8a3ced09775a9c07201fbbcb0371a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jun 1999 06:56:37 +0000 Subject: 1999-06-02 Roland McGrath * bootstrap.c (main): If we have a MULTIBOOT_CMDLINE environment variable, set its value as ${kernel-command-line} for boot scripts. --- serverboot/bootstrap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 58096f21..292bf81b 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -314,6 +314,8 @@ main(argc, argv) partition_init(); { + char *cmdline; + /* Initialize boot script variables. */ if (boot_script_set_variable ("host-port", VAL_PORT, (int) bootstrap_master_host_port) @@ -336,6 +338,13 @@ main(argc, argv) ) panic ("bootstrap: error setting boot script variables"); + cmdline = getenv ("MULTIBOOT_CMDLINE"); + if (cmdline != NULL + && boot_script_set_variable ("kernel-command-line", + VAL_STR, + (int) cmdline)) + panic ("bootstrap: error setting boot script variables"); + parse_script (&scriptf); close_file (&scriptf); } -- cgit v1.2.3 From 7d140932f68fd01810d65b870357eeeaadbdbb7f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jun 1999 06:56:41 +0000 Subject: . --- serverboot/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 7649cc45..53d7dc08 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,11 @@ +1999-06-02 Roland McGrath + + * load.c (boot_script_exec_cmd): Copy environment from our `environ' + onto the new task's stack along with its arguments. + + * bootstrap.c (main): If we have a MULTIBOOT_CMDLINE environment + variable, set its value as ${kernel-command-line} for boot scripts. + 1999-05-29 Roland McGrath * bootstrap.c (main): Define $(serverboot) function for "serverboot -- cgit v1.2.3 From eeb963eeefb00ad37c4da79db7ab5f62777cf286 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 3 Jun 1999 03:40:27 +0000 Subject: 1999-06-03 Mark Kettenis * default_pager.c (new_partition): Declare `waste' as `int' instead of `unsigned int'. --- serverboot/default_pager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 09bff076..bfce88b1 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -228,7 +228,8 @@ new_partition (const char *name, struct file_direct *fdp, /* The partition's first page has a Linux swap signature. This means the beginning of the page contains a bitmap of good pages, and all others are bad. */ - unsigned int i, j, bad, waste, max; + unsigned int i, j, bad, max; + int waste; printf("(default pager): Found Linux 2.0 swap signature in %s\n", name); -- cgit v1.2.3 From d7dac2d744ba036ab8c102311b16520b72be2e60 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 3 Jun 1999 03:40:35 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 53d7dc08..7d14409f 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1999-06-03 Mark Kettenis + + * default_pager.c (new_partition): Declare `waste' as `int' + instead of `unsigned int'. + 1999-06-02 Roland McGrath * load.c (boot_script_exec_cmd): Copy environment from our `environ' -- cgit v1.2.3 From ca6b1e89cd646368a08734e55dfb5da7ac1e2465 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 29 Jun 1999 09:00:20 +0000 Subject: 1999-06-29 Thomas Bushnell, BSG * hyper.c (diskfs_readonly_changed): Adjust whether the store should permit writes too. --- ufs/ChangeLog | 5 +++++ ufs/hyper.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 16ae4238..7b0fee70 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +1999-06-29 Thomas Bushnell, BSG + + * hyper.c (diskfs_readonly_changed): Adjust whether the store + should permit writes too. + 1999-05-02 Roland McGrath * main.c (main): Remove bogus uninitialized variable ERR. diff --git a/ufs/hyper.c b/ufs/hyper.c index 2a43bfed..c5101141 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -1,5 +1,5 @@ /* Fetching and storing the hypermetadata (superblock and cg summary info). - Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 1999 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 @@ -396,6 +396,8 @@ copy_sblock () void diskfs_readonly_changed (int readonly) { + (*(readonly ? store_set_flags : store_clear_flags)) (store, STORE_READONLY); + vm_protect (mach_task_self (), (vm_address_t)disk_image, store->size, 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE)); -- cgit v1.2.3 From 022849d0b80dcb7b46f4f9dcb7c3af7bba95cf39 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Sat, 3 Jul 1999 23:55:45 +0000 Subject: 1999-07-03 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Use munmap instead of vm_deallocate. (diskfs_direnter_hard): Likewise. (diskfs_dirremove_hard): Likewise. (diskfs_dirrewrite_hard): Likewise. (diskfs_dirempty): Likewise. (diskfs_drop_dirstat): Likewise. (diskfs_get_directs): Likewise. * sizes.c (block_extended): Likewise. (poke_pages): Likewise. * hyper.c (get_hypermetadata): Likewise. (diskfs_set_hypermetadata): Likewise. --- ufs/ChangeLog | 15 +++++++++++++++ ufs/dir.c | 27 +++++++++++++-------------- ufs/hyper.c | 5 ++--- ufs/sizes.c | 6 +++--- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 7b0fee70..8791b327 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,18 @@ +1999-07-03 Thomas Bushnell, BSG + + * dir.c (diskfs_lookup_hard): Use munmap instead of + vm_deallocate. + (diskfs_direnter_hard): Likewise. + (diskfs_dirremove_hard): Likewise. + (diskfs_dirrewrite_hard): Likewise. + (diskfs_dirempty): Likewise. + (diskfs_drop_dirstat): Likewise. + (diskfs_get_directs): Likewise. + * sizes.c (block_extended): Likewise. + (poke_pages): Likewise. + * hyper.c (get_hypermetadata): Likewise. + (diskfs_set_hypermetadata): Likewise. + 1999-06-29 Thomas Bushnell, BSG * hyper.c (diskfs_readonly_changed): Adjust whether the store diff --git a/ufs/dir.c b/ufs/dir.c index 01432829..c17549c2 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 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 @@ -137,7 +137,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, } if (buf) { - vm_deallocate (mach_task_self (), buf, buflen); + munmap ((caddr_t) buf, buflen); buf = 0; } if (ds && (type == CREATE || type == RENAME)) @@ -181,7 +181,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, } if (err != ENOENT) { - vm_deallocate (mach_task_self (), buf, buflen); + munmap ((caddr_t) buf, buflen); return err; } @@ -295,7 +295,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, || !ds || ds->type == LOOKUP) { - vm_deallocate (mach_task_self (), buf, buflen); + vm_deallocate ((caddr_t) buf, buflen); if (ds) ds->type = LOOKUP; /* set to be ignored by drop_dirstat */ } @@ -586,7 +586,7 @@ diskfs_direnter_hard(struct node *dp, err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred); if (err) { - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + munmap ((caddr_t) ds->mapbuf, ds->mapextent); return err; } } @@ -610,7 +610,7 @@ diskfs_direnter_hard(struct node *dp, dp->dn_set_mtime = 1; - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + munmap ((caddr_t) ds->mapbuf, ds->mapextent); if (ds->stat != EXTEND) { @@ -678,7 +678,7 @@ diskfs_dirremove_hard(struct node *dp, dp->dn_set_mtime = 1; - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + munmap ((caddr_t) ds->mapbuf, ds->mapextent); /* If we are keeping count of this block, then keep the count up to date. */ @@ -711,7 +711,7 @@ diskfs_dirrewrite_hard(struct node *dp, ds->entry->d_type = IFTODT (np->dn_stat.st_mode); dp->dn_set_mtime = 1; - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + munmap ((caddr_t) ds->mapbuf, ds->mapextent); diskfs_file_update (dp, 1); @@ -758,7 +758,7 @@ diskfs_dirempty(struct node *dp, || (entry->d_name[1] != '.' && entry->d_name[1] != '\0'))) { - vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); + munmap ((caddr_t) buf, dp->dn_stat.st_size); if (!diskfs_check_readonly ()) dp->dn_set_atime = 1; if (diskfs_synchronous) @@ -770,7 +770,7 @@ diskfs_dirempty(struct node *dp, dp->dn_set_atime = 1; if (diskfs_synchronous) diskfs_node_update (dp, 1); - vm_deallocate (mach_task_self (), buf, dp->dn_stat.st_size); + munmap ((caddr_t) buf, dp->dn_stat.st_size); return 1; } @@ -781,7 +781,7 @@ diskfs_drop_dirstat (struct node *dp, struct dirstat *ds) if (ds->type != LOOKUP) { assert (ds->mapbuf); - vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent); + munmap ((caddr_t) ds->mapbuf, ds->mapextent); ds->type = LOOKUP; } return 0; @@ -968,9 +968,8 @@ diskfs_get_directs (struct node *dp, if (allocsize > *datacnt) { if (round_page (datap - *data) < allocsize) - vm_deallocate (mach_task_self (), - (vm_address_t) (*data + round_page (datap - *data)), - allocsize - round_page (datap - *data)); + munmap (*data + round_page (datap - *data), + allocsize - round_page (datap - *data)); } /* Set variables for return */ diff --git a/ufs/hyper.c b/ufs/hyper.c index c5101141..deb4a5df 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -138,8 +138,7 @@ get_hypermetadata (void) /* Free previous values. */ if (zeroblock) - vm_deallocate (mach_task_self(), - (vm_address_t)zeroblock, sblock->fs_bsize); + munmap ((caddr_t) zeroblock, sblock->fs_bsize); if (csum) free (csum); @@ -314,7 +313,7 @@ diskfs_set_hypermetadata (int wait, int clean) err = EIO; } - vm_deallocate (mach_task_self (), (vm_address_t)buf, read); + munmap (buf, read); if (err) { diff --git a/ufs/sizes.c b/ufs/sizes.c index 5c3d12f0..58cbfc98 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -1,5 +1,5 @@ /* File growth and truncation - Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999 Free Software Foundation This file is part of the GNU Hurd. @@ -439,7 +439,7 @@ block_extended (struct node *np, /* Undo mapping */ mach_port_deallocate (mach_task_self (), mapobj); - vm_deallocate (mach_task_self (), mapaddr, round_page (old_size)); + munmap ((caddr_t) mapaddr, round_page (old_size)); /* Now it's OK to free the old block */ ffs_blkfree (np, old_pbn, old_size); @@ -711,7 +711,7 @@ poke_pages (memory_object_t obj, { for (poke = addr; poke < addr + len; poke += vm_page_size) *(volatile int *)poke = *(volatile int *)poke; - vm_deallocate (mach_task_self (), addr, len); + munmap ((caddr_t) addr, len); } start += len; } -- cgit v1.2.3 From 490d27a97e87769f04becd62bdfe3a783ee66c97 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 6 Jul 1999 00:09:18 +0000 Subject: Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Repair typo. Reported by Yamashita TAKAO . --- ufs/ChangeLog | 5 +++++ ufs/dir.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 8791b327..4a983183 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG + + * dir.c (diskfs_lookup_hard): Repair typo. Reported by Yamashita + TAKAO . + 1999-07-03 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Use munmap instead of diff --git a/ufs/dir.c b/ufs/dir.c index c17549c2..c0352d03 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -295,7 +295,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, || !ds || ds->type == LOOKUP) { - vm_deallocate ((caddr_t) buf, buflen); + munmap ((caddr_t) buf, buflen); if (ds) ds->type = LOOKUP; /* set to be ignored by drop_dirstat */ } -- cgit v1.2.3 From be6fc7f77939fce114b98ea1f876a623c09b31b3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 11 Jul 1999 01:43:00 +0000 Subject: 1999-07-10 Roland McGrath * ufs.h: Add #include for munmap decl. --- ufs/ufs.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index 1c44e5f5..77fb50e0 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1999 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 @@ -17,11 +17,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include "fs.h" #include "dinode.h" @@ -81,7 +83,7 @@ struct user_pager_info } type; struct pager *p; vm_prot_t max_prot; - + vm_offset_t allow_unlocked_pagein; vm_size_t unlocked_pagein_length; }; @@ -223,7 +225,7 @@ swab_long_long (long long arg) abort (); \ ret; \ }) - + /* Execute A = B, but byteswap it along the way if necessary */ #define write_disk_entry(a,b) \ ({ \ -- cgit v1.2.3 From fbd6929a645721d3c1905900a9e1d9df1fed051e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 11 Jul 1999 01:52:42 +0000 Subject: . --- ufs/ChangeLog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 4a983183..209d39df 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +1999-07-10 Roland McGrath + + * ufs.h: Add #include for munmap decl. + Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Repair typo. Reported by Yamashita @@ -6,7 +10,7 @@ Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG 1999-07-03 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Use munmap instead of - vm_deallocate. + vm_deallocate. (diskfs_direnter_hard): Likewise. (diskfs_dirremove_hard): Likewise. (diskfs_dirrewrite_hard): Likewise. -- cgit v1.2.3 From e529ce98486b413cca7b16e7f7a51642b60f0a6f Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Sun, 11 Jul 1999 05:32:44 +0000 Subject: 1999-07-09 Thomas Bushnell, BSG * dir.c (diskfs_get_directs): Use mmap instead of vm_allocate. * hyper.c (get_hypermetadata): Likewise. * pager.c (pager_read_page): Likewise. --- ufs/ChangeLog | 11 +++++++++++ ufs/dir.c | 2 +- ufs/hyper.c | 7 ++----- ufs/pager.c | 5 +++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 209d39df..869840b8 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -2,6 +2,17 @@ * ufs.h: Add #include for munmap decl. +1999-07-09 Thomas Bushnell, BSG + + * dir.c (diskfs_get_directs): Use mmap instead of vm_allocate. + * hyper.c (get_hypermetadata): Likewise. + * pager.c (pager_read_page): Likewise. + +1999-07-06 Thomas Bushnell, BSG + + * hyper.c (diskfs_readonly_changed): Use mprotect instead of + vm_protect. + Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Repair typo. Reported by Yamashita diff --git a/ufs/dir.c b/ufs/dir.c index c0352d03..304c8a44 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -863,7 +863,7 @@ diskfs_get_directs (struct node *dp, allocsize = round_page (bufsiz); if (allocsize > *datacnt) - vm_allocate (mach_task_self (), (vm_address_t *) data, allocsize, 1); + *data = mmap (0, allocsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); /* Scan through the entries to find ENTRY. If we encounter a -1 in the process then stop to fill it. When we run diff --git a/ufs/hyper.c b/ufs/hyper.c index deb4a5df..c907d274 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -257,8 +257,7 @@ get_hypermetadata (void) exit (1); } - vm_allocate (mach_task_self (), - (vm_address_t *)&zeroblock, sblock->fs_bsize, 1); + zeroblock = mmap (0, sblock->fs_bsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); /* If the filesystem has new features in it, don't pay attention to the user's request not to use them. */ @@ -397,9 +396,7 @@ diskfs_readonly_changed (int readonly) { (*(readonly ? store_set_flags : store_clear_flags)) (store, STORE_READONLY); - vm_protect (mach_task_self (), - (vm_address_t)disk_image, store->size, - 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE)); + mprotect (disk_image, store->size, PROT_READ | (readonly ? 0 : PROT_WRITE)); if (readonly) { diff --git a/ufs/pager.c b/ufs/pager.c index 61695db6..e703bfd2 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -1,5 +1,5 @@ /* Pager for ufs - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1999 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 @@ -180,7 +180,8 @@ pager_read_page (struct user_pager_info *pager, printf ("Write-locked pagein Object %#x\tOffset %#x\n", pager, page); fflush (stdout); #endif - vm_allocate (mach_task_self (), buf, __vm_page_size, 1); + *buf = (vm_address_t) mmap (0, vm_page_size, PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); *writelock = 1; } -- cgit v1.2.3 From 50fde35cc07ce37cb8e7a68f8d919b631cc89b97 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Jul 1999 19:25:11 +0000 Subject: 1999-07-20 Roland McGrath * default_pager.c (new_partition): When reading Linux signature page, handle pager_read_file_direct returning sub-page blocks. --- serverboot/default_pager.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index bfce88b1..d2de5cdd 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -220,9 +220,25 @@ new_partition (const char *name, struct file_direct *fdp, if (rc) panic("(default pager): cannot read first page of %s! rc=%#x\n", name, rc); - if (rsize != LINUX_PAGE_SIZE) - panic("(default pager): bad read on first page of %s! size=%u\n", - name, rsize); + while (rsize < LINUX_PAGE_SIZE) + { + /* Filesystem block size is smaller than page size, + so we must do several reads to get the whole page. */ + vm_address_t baddr, bsize; + rc = page_read_file_direct(part->file, + rsize, LINUX_PAGE_SIZE-rsize, + &baddr, + &bsize); + if (rc) + panic("(default pager): " + "cannot read first page of %s! rc=%#x at %#x\n", + name, rc, rsize); + + memcpy ((char *) raddr + rsize, (void *) baddr, bsize); + rsize += bsize; + vm_deallocate (mach_task_self (), baddr, bsize); + } + if (!memcmp("SWAP-SPACE", (char *) raddr + LINUX_PAGE_SIZE-10, 10)) { /* The partition's first page has a Linux swap signature. -- cgit v1.2.3 From 5b8eb61d984dd0c22cf13617fb9109bbf70db403 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Jul 1999 19:25:19 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 7d14409f..df3e7d05 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1999-07-20 Roland McGrath + + * default_pager.c (new_partition): When reading Linux signature page, + handle pager_read_file_direct returning sub-page blocks. + 1999-06-03 Mark Kettenis * default_pager.c (new_partition): Declare `waste' as `int' -- cgit v1.2.3 From 5ca541889c0b390971091fc1a9cdae5d9a902e39 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Jul 1999 20:02:34 +0000 Subject: 1999-07-20 Roland McGrath * ext2_file_io.c, ffs_file_io.c, minix_file_io.c: Remove fs-specific routines *_page_{read,write}_file_direct. Moved to ... * file_io.c (page_read_file_direct, page_write_file_direct): Don't call fs-specific routine, these are not fs-specific. Instead, replaced with former fs-specific routines (which were all identical). Read and write more than a fs block when disk blocks are contiguous. --- serverboot/ext2_file_io.c | 116 -------------------------------- serverboot/ffs_file_io.c | 116 -------------------------------- serverboot/file_io.c | 164 +++++++++++++++++++++++++++++++++++---------- serverboot/minix_file_io.c | 115 ------------------------------- 4 files changed, 128 insertions(+), 383 deletions(-) diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c index 9d743368..d25fd9db 100644 --- a/serverboot/ext2_file_io.c +++ b/serverboot/ext2_file_io.c @@ -981,119 +981,3 @@ ext2_remove_file_direct(fdp) fdp->fd_blocks = 0; /* sanity */ /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */ } - -/* - * 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 -ext2_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) - size = 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 -ext2_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) - size = 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/ffs_file_io.c b/serverboot/ffs_file_io.c index 889ca4e5..ce67fdc8 100644 --- a/serverboot/ffs_file_io.c +++ b/serverboot/ffs_file_io.c @@ -967,119 +967,3 @@ ffs_remove_file_direct(fdp) fdp->fd_blocks = 0; /* sanity */ /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */ } - -/* - * 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 -ffs_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) - size = 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 -ffs_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) - size = 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.c b/serverboot/file_io.c index 141fdcfe..99966f95 100644 --- a/serverboot/file_io.c +++ b/serverboot/file_io.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 1994 The University of Utah and * the Computer Systems Laboratory at the University of Utah (CSL). * All rights reserved. @@ -156,41 +156,6 @@ add_file_direct(fdp, fp) } } -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 */ -{ - switch (fdp->f_fstype) { - case EXT2_FS: - return ext2_page_read_file_direct(fdp, offset, size, addr, size_read); - case MINIX_FS: - return minix_page_read_file_direct(fdp, offset, size, addr, size_read); - default: - return ffs_page_read_file_direct(fdp, offset, size, addr, size_read); - } -} - -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 */ -{ - switch (fdp->f_fstype) { - case EXT2_FS: - return ext2_page_write_file_direct(fdp, offset, addr, size, size_written); - case MINIX_FS: - return minix_page_write_file_direct(fdp, offset, addr, size, size_written); - default: - return ffs_page_write_file_direct(fdp, offset, addr, size, size_written); - } -} int remove_file_direct(fdp) @@ -223,3 +188,130 @@ file_is_structured(fp) 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/minix_file_io.c b/serverboot/minix_file_io.c index 0a18092b..17beb18c 100644 --- a/serverboot/minix_file_io.c +++ b/serverboot/minix_file_io.c @@ -849,118 +849,3 @@ minix_remove_file_direct(fdp) fdp->fd_blocks = 0; /* sanity */ /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */ } - -/* - * Special read and write routines for default pager. - * Assume that all offsets and sizes are multiples - * of DEV_BSIZE. - */ - -#define minix_fdir_blkoff(fdp, offset) /* offset % fd_bsize */ \ - ((offset) & ((fdp)->fd_bsize - 1)) -#define minix_fdir_lblkno(fdp, offset) /* offset / fd_bsize */ \ - ((offset) >> (fdp)->fd_bshift) - -#define minix_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 -minix_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 minix_daddr_t file_block; - minix_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 = minix_fdir_blkoff(fdp, offset); - file_block = minix_fdir_lblkno(fdp, offset); - - if (file_is_device(fdp)) { - disk_block = file_block; - } else { - disk_block = ((minix_daddr_t *)fdp->fd_blocks)[file_block]; - if (disk_block == 0) - return (FS_NOT_IN_FILE); - } - - if (size > fdp->fd_bsize) - size = fdp->fd_bsize; - - return (device_read(fdp->fd_dev, - 0, - (recnum_t) (minix_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 -minix_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 minix_daddr_t file_block; - minix_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 = minix_fdir_blkoff(fdp, offset); - file_block = minix_fdir_lblkno(fdp, offset); - - if (file_is_device(fdp)) { - disk_block = file_block; - } else { - disk_block = ((minix_daddr_t *)fdp->fd_blocks)[file_block]; - if (disk_block == 0) - return (FS_NOT_IN_FILE); - } - - if (size > fdp->fd_bsize) - size = 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) (minix_fdir_fsbtodb(fdp, disk_block) + btodb(off)), - (char *) addr, - size, - &num_written); - *size_written = num_written; - return rc; -} -- cgit v1.2.3 From 7a8b3db2b4fe449397a08d3887d47b950a428766 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 Jul 1999 20:04:51 +0000 Subject: . --- serverboot/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index df3e7d05..9609679f 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,12 @@ 1999-07-20 Roland McGrath + * ext2_file_io.c, ffs_file_io.c, minix_file_io.c: Remove fs-specific + routines *_page_{read,write}_file_direct. Moved to ... + * file_io.c (page_read_file_direct, page_write_file_direct): Don't + call fs-specific routine, these are not fs-specific. Instead, + replaced with former fs-specific routines (which were all identical). + Read and write more than a fs block when disk blocks are contiguous. + * default_pager.c (new_partition): When reading Linux signature page, handle pager_read_file_direct returning sub-page blocks. -- cgit v1.2.3 From 3ab9974fa2f0f3877b6af3e3563657d717aefd40 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 20 Aug 1999 05:33:12 +0000 Subject: 1999-08-20 Roland McGrath * bootstrap.c (parse_script): Add one to the buffer size so we can null-terminate after the end of the file. --- serverboot/bootstrap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 292bf81b..3057e0a7 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -437,7 +437,7 @@ parse_script (struct file *f) int amt, fd, err; int n = 0; - buf = malloc (f->f_size); + buf = malloc (f->f_size + 1); /* add one for null terminator we will write */ if (read_file (f, 0, buf, f->f_size, 0)) panic ("bootstrap: error reading boot script file"); @@ -445,7 +445,7 @@ parse_script (struct file *f) while (1) { while (p < buf + f->f_size && *p != '\n') - p++; + p++; *p = '\0'; err = boot_script_parse_line (line); if (err) @@ -453,7 +453,6 @@ parse_script (struct file *f) if (p == buf + f->f_size) break; line = ++p; - } free (buf); } -- cgit v1.2.3 From 149bd153be9b6f199f8d259e7d278462c099fd33 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 22 Aug 1999 23:58:16 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 9609679f..4ae27298 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1999-08-20 Roland McGrath + + * bootstrap.c (parse_script): Add one to the buffer size so we can + null-terminate after the end of the file. + 1999-07-20 Roland McGrath * ext2_file_io.c, ffs_file_io.c, minix_file_io.c: Remove fs-specific -- cgit v1.2.3 From 558d5489edced5c7a208f66eafb47fbcca201ac0 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Sat, 4 Sep 1999 13:00:39 +0000 Subject: 1999-09-04 Thomas Bushnell, BSG * pager.c (find_address): If !ISREAD, then don't return errors for access past NP->allocsize, and clear *ADDR and *DISKSIZE. These can happen through harmless races against truncate. (pager_write_page): Don't print annoying messages for writes to unallocated disk. These can happen through harmless races against truncate, and so we should not pester the console with them. --- ufs/ChangeLog | 9 +++++++++ ufs/pager.c | 17 +++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 869840b8..1375fede 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,12 @@ +1999-09-04 Thomas Bushnell, BSG + + * pager.c (find_address): If !ISREAD, then don't return errors for + access past NP->allocsize, and clear *ADDR and *DISKSIZE. These + can happen through harmless races against truncate. + (pager_write_page): Don't print annoying messages for writes to + unallocated disk. These can happen through harmless races against + truncate, and so we should not pester the console with them. + 1999-07-10 Roland McGrath * ufs.h: Add #include for munmap decl. diff --git a/ufs/pager.c b/ufs/pager.c index e703bfd2..3038932d 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -121,7 +121,14 @@ find_address (struct user_pager_info *upi, { if (*nplock) rwlock_reader_unlock (*nplock); - return EIO; + if (isread) + return EIO; + else + { + *addr = 0; + *disksize = 0; + return 0; + } } if (offset + __vm_page_size > np->allocsize) @@ -216,13 +223,7 @@ pager_write_page (struct user_pager_info *pager, err = EIO; } else - { - printf ("Attempt to write unallocated disk\n."); - printf ("Object %p\tOffset %#x\n", pager, page); - fflush (stdout); - err = 0; /* unallocated disk; - error would be pointless */ - } + err = 0; if (nplock) rwlock_reader_unlock (nplock); -- cgit v1.2.3 From 637f6a0aa9cec92581381a8a19a66d2f9b66216b Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 8 Sep 1999 08:41:59 +0000 Subject: 1999-09-08 Thomas Bushnell, BSG * dir.c (diskfs_get_directs): Initialize `err' to shut gcc up. 1999-09-07 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Pass additional parameter to diskfs_get_filemap. (diskfs_dirempty): Likewise. * sizes.c (diskfs_truncate): Likewise. (block_extended): Likewise. (diskfs_grow): Likewise. * pager.c (diskfs_get_filemap): Accept additional parameter. --- ufs/ChangeLog | 14 ++++++++++++++ ufs/dir.c | 6 +++--- ufs/pager.c | 4 +++- ufs/sizes.c | 6 +++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 1375fede..4bebe284 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,17 @@ +1999-09-08 Thomas Bushnell, BSG + + * dir.c (diskfs_get_directs): Initialize `err' to shut gcc up. + +1999-09-07 Thomas Bushnell, BSG + + * dir.c (diskfs_lookup_hard): Pass additional parameter to + diskfs_get_filemap. + (diskfs_dirempty): Likewise. + * sizes.c (diskfs_truncate): Likewise. + (block_extended): Likewise. + (diskfs_grow): Likewise. + * pager.c (diskfs_get_filemap): Accept additional parameter. + 1999-09-04 Thomas Bushnell, BSG * pager.c (find_address): If !ISREAD, then don't return errors for diff --git a/ufs/dir.c b/ufs/dir.c index 304c8a44..aee08bb0 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -144,7 +144,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, ds->stat = LOOKING; /* Map in the directory contents. */ - memobj = diskfs_get_filemap (dp, prot); + memobj = diskfs_get_filemap (dp, 0, prot); if (memobj == MACH_PORT_NULL) return errno; @@ -730,7 +730,7 @@ diskfs_dirempty(struct node *dp, memory_object_t memobj; error_t err; - memobj = diskfs_get_filemap (dp, VM_PROT_READ); + memobj = diskfs_get_filemap (dp, 0, VM_PROT_READ); if (memobj == MACH_PORT_NULL) /* XXX should reflect error properly */ @@ -839,7 +839,7 @@ diskfs_get_directs (struct node *dp, char buf[DIRBLKSIZ]; char *bufp; int bufvalid; - error_t err; + error_t err = 0; int i; char *datap; struct directory_entry *entryp; diff --git a/ufs/pager.c b/ufs/pager.c index 3038932d..3cba748e 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -547,11 +547,13 @@ flush_node_pager (struct node *node) /* Call this to create a FILE_DATA pager and return a send right. NP must be locked. PROT is the max protection desired. */ mach_port_t -diskfs_get_filemap (struct node *np, vm_prot_t prot) +diskfs_get_filemap (struct node *np, int index, vm_prot_t prot) { struct user_pager_info *upi; mach_port_t right; + assert (index == 0); /* XXX */ + assert (S_ISDIR (np->dn_stat.st_mode) || S_ISREG (np->dn_stat.st_mode) || (S_ISLNK (np->dn_stat.st_mode) diff --git a/ufs/sizes.c b/ufs/sizes.c index 58cbfc98..cffce158 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -103,7 +103,7 @@ diskfs_truncate (struct node *np, pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); - obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); + obj = diskfs_get_filemap (np, 0, VM_PROT_READ | VM_PROT_WRITE); if (obj != MACH_PORT_NULL) { /* XXX should cope with errors from diskfs_get_filemap */ @@ -403,7 +403,7 @@ block_extended (struct node *np, volatile int *pokeaddr; /* Map in this part of the file */ - mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ); + mapobj = diskfs_get_filemap (np, 0, VM_PROT_WRITE | VM_PROT_READ); /* XXX Should cope with errors from diskfs_get_filemap and back out the operation here. */ @@ -484,7 +484,7 @@ diskfs_grow (struct node *np, assert (!diskfs_readonly); /* This reference will ensure that NP->dn->fileinfo stays allocated. */ - pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ); + pagerpt = diskfs_get_filemap (np, 0, VM_PROT_WRITE|VM_PROT_READ); if (pagerpt == MACH_PORT_NULL) return errno; -- cgit v1.2.3 From f9881efde06c7a8329557ce26fa5adfc84362391 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Sun, 12 Sep 1999 08:22:16 +0000 Subject: Directory removed; never used and now causing some confusion, and since implementation plans have changed, it's not useful to distributed anymore. --- libmom/ChangeLog | 31 --------- libmom/Makefile | 41 ------------ libmom/allocate-address.c | 50 --------------- libmom/allocate-memory.c | 51 --------------- libmom/copy-ref.c | 34 ---------- libmom/deallocate-memory.c | 35 ----------- libmom/error-trans.c | 40 ------------ libmom/fetch-mach-port.c | 27 -------- libmom/hash-ref.c | 28 --------- libmom/mach-port-set.c | 30 --------- libmom/make-memory-readonly.c | 36 ----------- libmom/make-memory-readwrite.c | 36 ----------- libmom/memory-init.c | 32 ---------- libmom/mom-errors.h | 47 -------------- libmom/mom-kerndep.h | 41 ------------ libmom/mom.h | 132 --------------------------------------- libmom/priv.h | 27 -------- libmom/ref-destroy.c | 29 --------- libmom/refs-identical.c | 28 --------- libmom/reserve-memory-anywhere.c | 40 ------------ libmom/reserve-memory.c | 42 ------------- libmom/unreserve-memory.c | 27 -------- libmom/unuse-memory.c | 43 ------------- libmom/wire-memory.c | 28 --------- 24 files changed, 955 deletions(-) delete mode 100644 libmom/ChangeLog delete mode 100644 libmom/Makefile delete mode 100644 libmom/allocate-address.c delete mode 100644 libmom/allocate-memory.c delete mode 100644 libmom/copy-ref.c delete mode 100644 libmom/deallocate-memory.c delete mode 100644 libmom/error-trans.c delete mode 100644 libmom/fetch-mach-port.c delete mode 100644 libmom/hash-ref.c delete mode 100644 libmom/mach-port-set.c delete mode 100644 libmom/make-memory-readonly.c delete mode 100644 libmom/make-memory-readwrite.c delete mode 100644 libmom/memory-init.c delete mode 100644 libmom/mom-errors.h delete mode 100644 libmom/mom-kerndep.h delete mode 100644 libmom/mom.h delete mode 100644 libmom/priv.h delete mode 100644 libmom/ref-destroy.c delete mode 100644 libmom/refs-identical.c delete mode 100644 libmom/reserve-memory-anywhere.c delete mode 100644 libmom/reserve-memory.c delete mode 100644 libmom/unreserve-memory.c delete mode 100644 libmom/unuse-memory.c delete mode 100644 libmom/wire-memory.c diff --git a/libmom/ChangeLog b/libmom/ChangeLog deleted file mode 100644 index f04006c5..00000000 --- a/libmom/ChangeLog +++ /dev/null @@ -1,31 +0,0 @@ -Sat May 25 17:25:09 1996 Michael I. Bushnell, p/BSG - - * refs-identical.c (mom_ports_identical): Omit uses of deleted - members of struct mom_port_ref.c. - - * ref-destroy.c (mom_ref_destroy): Omit uses of deleted members of - struct mom_port_ref.c. - - * mach-port-set.c (mom_mach_port_set): Omit uses of deleted - members of struct mom_port_ref.c. - - * fetch-mach-port.c (mom_fetch_mach_port): Omit uses of deleted - members of struct mom_port_ref.c. - - * copy-ref.c (mom_copy_ref): Likewise. - - * mom-kerndep.h (struct mom_port_ref): Delete members `lock' and - `refcnt'. - * Makefile (SRCS): Delete add-ref.c and drop-ref.c. - * mom.h (mom_add_ref, mom_drop_ref): Delete functions. - * add-ref.c, drop-ref.c: Delete files. - -Fri May 24 16:14:54 1996 Michael I. Bushnell, p/BSG - - * mom.h: Include . - * error-trans.c: New file. - * mom-kerndep.h (mom_error_translate_mach): New function. - * Makefile (LCLHDRS, installhdrs): Add mom-errors.h. - (SRCS): Add error-trans.c. - * mom-errors.h: New file. - diff --git a/libmom/Makefile b/libmom/Makefile deleted file mode 100644 index 04df2c9c..00000000 --- a/libmom/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (C) 1996 Free Software Foundation, Inc. -# Written by Michael I. Bushnell, p/BSG. -# -# 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. - -dir := libmom -makemode := library - -libname = libmom - -SRCS = allocate-address.c allocate-memory.c copy-ref.c \ - deallocate-memory.c fetch-mach-port.c hash-ref.c \ - mach-port-set.c make-memory-readonly.c make-memory-readwrite.c \ - memory-init.c ref-destroy.c refs-identical.c reserve-memory.c \ - reserve-memory-anywhere.c unreserve-memory.c unuse-memory.c \ - wire-memory.c error-trans.c - -LCLHDRS = mom.h mom-kerndep.h priv.h mom-errors.h -installhdrs = mom.h mom-kerndep.h mom-errors.h -installhdrsubdir = . - -OBJS = $(SRCS:.c=.o) - -include ../Makeconf - - diff --git a/libmom/allocate-address.c b/libmom/allocate-address.c deleted file mode 100644 index fa017bac..00000000 --- a/libmom/allocate-address.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_allocate_address (void *start, size_t len, int readonly, - struct mom_port_ref *obj, size_t offset, - int copy) -{ - error_t err; - mach_port_t port; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - if (obj) - { - port = mom_fetch_mach_port (obj); - assert (offset % vm_page_size == 0); - } - else - port = MACH_PORT_NULL; - - mutex_lock (&_mom_memory_lock); - err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, - port, (obj ? offset : 0), (obj ? copy : 0), - (VM_PROT_READ | VM_PROT_EXECUTE - | (!readonly ? VM_PROT_WRITE : 0)), - VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE, - VM_INHERIT_COPY); - mutex_unlock (&_mom_memory_lock); - return err; -} diff --git a/libmom/allocate-memory.c b/libmom/allocate-memory.c deleted file mode 100644 index d98632bc..00000000 --- a/libmom/allocate-memory.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_allocate_memory (void **start, size_t len, int readonly, - struct mom_port_ref *obj, size_t offset, - int copy) -{ - error_t err; - mach_port_t port; - - assert (len % vm_page_size == 0); - if (obj) - { - port = mom_fetch_mach_port (obj); - assert (offset % vm_page_size == 0); - } - else - port = MACH_PORT_NULL; - - *start = 0; - - mutex_lock (&_mom_memory_lock); - err = vm_map (mach_task_self (), (vm_address_t *)start, len, 0, 0, - port, (obj ? offset : 0), (obj ? copy : 0), - (VM_PROT_READ | VM_PROT_EXECUTE - | (!readonly ? VM_PROT_WRITE : 0)), - VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE, - VM_INHERIT_COPY); - mutex_unlock (&_mom_memory_lock); - return err; -} diff --git a/libmom/copy-ref.c b/libmom/copy-ref.c deleted file mode 100644 index 03d4ab45..00000000 --- a/libmom/copy-ref.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copy a mom port reference - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_copy_ref (struct mom_port_ref *new, - struct mom_port_ref *obj) -{ - error_t err; - - err = mach_port_mod_refs (mach_task_self (), - obj->port, MACH_PORT_RIGHT_SEND, 1); - if (!err) - new->port = obj->port; - return err; -} diff --git a/libmom/deallocate-memory.c b/libmom/deallocate-memory.c deleted file mode 100644 index bf7acfdb..00000000 --- a/libmom/deallocate-memory.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_deallocate_memory (void *start, size_t len) -{ - error_t err; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - - mutex_lock (&_mom_memory_lock); - err = vm_deallocate (mach_task_self (), (vm_address_t) start, len); - mutex_unlock (&_mom_memory_lock); - return err; -} diff --git a/libmom/error-trans.c b/libmom/error-trans.c deleted file mode 100644 index 57ef7e31..00000000 --- a/libmom/error-trans.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -mom_error_t -mom_error_translate_mach (error_t macherr) -{ - switch (macherr) - { - case EMACH_SEND_INVALID_DEST: - return EMOM_INVALID_DEST; - - case EMACH_SEND_INVALID_RIGHT: - return EMOM_INVALID_REF; - - case EMIG_SERVER_DIED: - return EMOM_SERVER_DIED; - - default: - return macherr; - } -} diff --git a/libmom/fetch-mach-port.c b/libmom/fetch-mach-port.c deleted file mode 100644 index 85262600..00000000 --- a/libmom/fetch-mach-port.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Return the Mach port corresponding to a mom port reference - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -mach_port_t -mom_fetch_mach_port (struct mom_port_ref *obj) -{ - return obj->port; -} diff --git a/libmom/hash-ref.c b/libmom/hash-ref.c deleted file mode 100644 index 6c160b1b..00000000 --- a/libmom/hash-ref.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Return a hash key for a mom port - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -int -mom_hash_port (struct mom_port_ref *obj) -{ - return mom_fetch_mach_port (obj); -} - diff --git a/libmom/mach-port-set.c b/libmom/mach-port-set.c deleted file mode 100644 index ed6842fd..00000000 --- a/libmom/mach-port-set.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Initialize a mom port reference from a Mach port - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_mach_port_set (struct mom_port_ref *obj, - mach_port_t port) -{ - obj->port = port; - return 0; -} - diff --git a/libmom/make-memory-readonly.c b/libmom/make-memory-readonly.c deleted file mode 100644 index e7ca4c87..00000000 --- a/libmom/make-memory-readonly.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_make_memory_readonly (void *start, size_t len) -{ - error_t err; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - - mutex_lock (&_mom_memory_lock); - err = vm_protect (mach_task_self (), (vm_address_t) start, len, 0, - VM_PROT_READ | VM_PROT_EXECUTE); - mutex_unlock (&_mom_memory_lock); - return err; -} diff --git a/libmom/make-memory-readwrite.c b/libmom/make-memory-readwrite.c deleted file mode 100644 index f35e6bfd..00000000 --- a/libmom/make-memory-readwrite.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_make_memory_readwrite (void *start, size_t len) -{ - error_t err; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - - mutex_lock (&_mom_memory_lock); - err = vm_protect (mach_task_self (), (vm_address_t) start, len, 0, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - mutex_unlock (&_mom_memory_lock); - return err; -} diff --git a/libmom/memory-init.c b/libmom/memory-init.c deleted file mode 100644 index 38972018..00000000 --- a/libmom/memory-init.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Initialization and static data for mom memory management. - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -struct mutex _mom_memory_lock = MUTEX_INITIALIZER; -size_t mom_page_size; - -static void init_memory (void) __attribute__ ((constructor)); - -static void -init_memory (void) -{ - mom_page_size = vm_page_size; -} diff --git a/libmom/mom-errors.h b/libmom/mom-errors.h deleted file mode 100644 index 85a35d5e..00000000 --- a/libmom/mom-errors.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Error codes for MOM library - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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. */ - - -/* MOM uses Mach error system 0x11 and subsystem 0. */ -#define _MOM_ERRNO(n) ((0x11 << 26 | ((n) & 0x3fff))) - -enum __momerrors_error_codes -{ - /* These are standard errors to be returned by RPC user stubs - in Mom systems. */ - - /* All Mom systems must detect and return these errors */ - - /* The RPC attempted to send to an invalid mom_port_ref. This can - happen because, for example, the server it spoke to has died. */ - EMOM_INVALID_DEST = _MOM_ERRNO (1), - - /* The RPC attempted to send an invalid mom_port_ref in its content. - This shall not happen if the server the reference is to has - merely died. */ - EMOM_INVALID_REF = _MOM_ERRNO (2), - - /* The server began processing the RPC, but at some point it died. */ - EMOM_SERVER_DIED = _MOM_ERRNO (3) -}; - -typedef enum __momerrors_error_codes mom_error_t; - - diff --git a/libmom/mom-kerndep.h b/libmom/mom-kerndep.h deleted file mode 100644 index cc61db05..00000000 --- a/libmom/mom-kerndep.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Mach-specific type definitions for MOM - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 -#include - -struct mom_port_ref -{ - mach_port_t port; -}; - -/* Mach-specific functions */ - -/* Initialize OBJ with a reference to Mach port PORT. One Mach user - reference is consumed. */ -error_t mom_mach_port_set (struct mom_port_ref *obj, mach_port_t port); - -/* Return the Mach port corresponding to OBJ. No new Mach user - references are created, so this Mach port should not be used - after OBJ has been destroyed. */ -mach_port_t mom_fetch_mach_port (struct mom_port_ref *obj); - -/* Turn a Mach error number into a Mom error number. */ -mom_error_t mom_error_translate_mach (error_t macherr); diff --git a/libmom/mom.h b/libmom/mom.h deleted file mode 100644 index 6d04f1d5..00000000 --- a/libmom/mom.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Microkernel object module - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 -#include - -#include - -/* This header file defines structure layouts for the use of functions - below; it is specific to the particular microkernel in use. */ -#include - - - - - -/* User RPC endpoints */ - -/* A communications end-point suitable for sending RPC's to servers. */ -struct mom_port_ref; /* layout defined in mom-kerndep.h */ - -/* Create a new port reference that refers to the same underlying channel - as OBJ. Fill *NEW with the new reference. NEW should be otherwise - unused memory. */ -error_t mom_copy_ref (struct mom_port_ref *new, struct mom_port_ref *obj); - -/* Tell if two mom ports refer to the same underlying server RPC channel */ -int mom_refs_identical (struct mom_port_ref *obj1, struct mom_port_ref *obj2); - -/* Return a hash key for a port. Different ports may have the same - hash key, but no port's hash key will ever change as long as that - port is known to this task. Two identical ports (as by - mom_ports_identical) will always have the same hash key. */ -int mom_hash_ref (struct mom_port_ref *obj); - -/* Destroy mom port reference OBJ and deallocate the underlying kernel - object. After this call, the memory in *OBJ may be used by the - user for any purpose. It is an error to call this routine if any - other thread might be calling any other mom port reference function - on OBJ concurrently. */ -void mom_ref_destroy (struct mom_port_ref *obj); - - - -/* Memory management */ - -/* Size of a "physical" page; mom memory management calls must be in - aligned multiples of this value. */ -extern size_t mom_page_size; - -/* Reserve a region of memory from START and continuing for LEN bytes - so that it won't be used by anyone, but don't make it directly - usable. */ -error_t mom_reserve_memory (void *start, size_t len); - -/* Reserve a region of memory anywhere of size LEN bytes and return - its address in ADDR. */ -error_t mom_reserve_memory_anywhere (void **addr, size_t len); - -/* Make a reserved region of memory usable, as specified by START and - LEN. If READONLY is set then only make it available for read - access; otherwise permit both read and write. If OBJ is null, then - use zero-filled anonymous storage. If OBJ is non-null, then it - specifies a mom port reference referring to a memory server, and - OFFSET is the offset within that server. If COPY is set, then the - data is copied from the memory object, otherwise it shares with - other users of the same object. */ -error_t mom_use_memory (void *start, size_t len, int readonly, - struct mom_port_ref *obj, size_t offset, - int copy); - -/* Ask the kernel to wire the region of memory specified to physical - memory. The exact semantics of this are kernel dependent; it is - also usually privileged in some fashion and will fail for - non-privileged users. */ -error_t mom_wire_memory (void *start, size_t len); - -/* Convert a region of usable memory to read-only */ -error_t mom_make_memory_readonly (void *start, size_t len); - -/* Convert a region of usable memory to read/write */ -error_t mom_make_memory_readwrite (void *start, size_t len); - -/* Convert a region of usable memory to reserved but unusable status. */ -error_t mom_unuse_memory (void *start, size_t len); - -/* Convert a region of reserved unusable memory to unreserved status. */ -error_t mom_unreserve_memory (void *start, size_t len); - - - -/* Optimized combination versions of memory functions; these are very - likely to be faster than using the two call sequences they are - equivalent to. */ - -/* Combined version of mom_unuse_memory followed by mom_unreserve_memory. */ -error_t mom_deallocate_memory (void *start, size_t len); - -/* Combined version of mom_reserve_memory and mom_use_memory. */ -error_t mom_allocate_address (void *start, size_t len, int readonly, - struct mom_port_ref *obj, size_t offset, - int copy); - -/* Combined version of mom_reserve_memory_anywhere and mom_use_memory. */ -error_t mom_allocate_memory (void **start, size_t len, int readonly, - struct mom_port_ref *obj, size_t offset, - int copy); - -/* Shorthand for the most common sort of allocation--like mom_allocate_memory, - but READONLY, and OBJ are both null. */ -#define mom_allocate(start,len) \ - (mom_allocate_memory ((start), (len), 0, 0, 0, 0)) - diff --git a/libmom/priv.h b/libmom/priv.h deleted file mode 100644 index 88d2d9ed..00000000 --- a/libmom/priv.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "mom.h" -#include -#include - -extern struct mutex _mom_memory_lock; - - diff --git a/libmom/ref-destroy.c b/libmom/ref-destroy.c deleted file mode 100644 index 6966bcdc..00000000 --- a/libmom/ref-destroy.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Completely destroy a MOM port - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -void -mom_ref_destroy (struct mom_port_ref *obj) -{ - mach_port_deallocate (mach_task_self (), obj->port); -} - - diff --git a/libmom/refs-identical.c b/libmom/refs-identical.c deleted file mode 100644 index 0c4ee885..00000000 --- a/libmom/refs-identical.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Tell if two mom port references refer to the same channel - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -int -mom_ports_identical (struct mom_port_ref *obj1, - struct mom_port_ref *obj2) -{ - return obj1->port == obj2->port; -} diff --git a/libmom/reserve-memory-anywhere.c b/libmom/reserve-memory-anywhere.c deleted file mode 100644 index 40f9ec00..00000000 --- a/libmom/reserve-memory-anywhere.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_reserve_memory_anywhere (void **start, size_t len) -{ - error_t err; - - assert (len % vm_page_size == 0); - - *start = 0; - - mutex_lock (&_mom_memory_lock); - err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 1, - MACH_PORT_NULL, 0, 0, 0, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, - VM_INHERIT_COPY); - mutex_unlock (&_mom_memory_lock); - - return err; -} diff --git a/libmom/reserve-memory.c b/libmom/reserve-memory.c deleted file mode 100644 index ada9ef02..00000000 --- a/libmom/reserve-memory.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Reserve memory - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_reserve_memory (void *start, size_t len) -{ - error_t err; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - - mutex_lock (&_mom_memory_lock); - err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, - MACH_PORT_NULL, 0, 0, 0, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, - VM_INHERIT_COPY); - mutex_unlock (&_mom_memory_lock); - - return err; -} - - diff --git a/libmom/unreserve-memory.c b/libmom/unreserve-memory.c deleted file mode 100644 index 88e8eb94..00000000 --- a/libmom/unreserve-memory.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_unreserve_memory (void *start, size_t len) -{ - return mom_deallocate_memory (start, len); -} diff --git a/libmom/unuse-memory.c b/libmom/unuse-memory.c deleted file mode 100644 index 363f2a45..00000000 --- a/libmom/unuse-memory.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - -error_t -mom_unuse_memory (void *start, size_t len) -{ - error_t err; - - assert ((vm_address_t) start % vm_page_size == 0); - assert (len % vm_page_size == 0); - - mutex_lock (&_mom_memory_lock); - /* Deallocate and reallocate so that we drop any mapping around. */ - err = vm_deallocate (mach_task_self (), (vm_address_t) start, len); - if (!err) - err = vm_map (mach_task_self (), (vm_address_t *)&start, len, 0, 0, - MACH_PORT_NULL, 0, 0, 0, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, - VM_INHERIT_COPY); - mutex_unlock (&_mom_memory_lock); - return err; -} - - diff --git a/libmom/wire-memory.c b/libmom/wire-memory.c deleted file mode 100644 index b3832154..00000000 --- a/libmom/wire-memory.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 1996 Free Software Foundation, Inc. - Written by Michael I. Bushnell, p/BSG. - - 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 "priv.h" - - -error_t -mom_wire_memory (void *start, size_t len) -{ - return EOPNOTSUPP; -} -- cgit v1.2.3 From af939c11b41fb1b53a232815224f64f0f1a410cc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Sep 1999 04:34:38 +0000 Subject: 1999-09-09 Roland McGrath * Makeconf (link-executable): New variable, partial linking commands for executables. ($(target)): Use it. Move .o's before -Wl,-(, just cause. ($(addsuffix .static,$(target))): New static pattern rule, use `$(link-executable) -static' and static hurd libs. [$(doinst) = one]: Give deps to $(target).static too. {"Decode makemode" page}: Set linktarg instead of cleantarg for each makemode that sets only one. [$(makemode) != library]: Append $(linktarg:=.static) to linktarg. [$(cleantarg) empty]: Set cleantarg to $(linktarg). [Installation section] (targets): Set to $(target) if empty. (installable): New variable, union of $(linktarg) and $(targets). Remove conditionals on $(doinst), leaving only multi-target version. Use $(installable) rather than $(targets) to compute list of targets for static pattern rule that does the install. (install-targets): New variable, $(targets) plus subset of $(linktarg) matching $(build-static:=.static). (all): Depend on $(install-targets) rather than $(targets). (install): Likewise for computed list of targets in $(installationdir). * config.make.in (build-static): New variable. * configure.in: Support --enable-static-progs=LIST. --- configure.in | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index f291b665..91420edc 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.15 1999/01/27 20:48:21 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.16 1999/09/13 04:34:38 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -26,10 +26,23 @@ esac AC_SUBST(asm_syntax) AC_ARG_ENABLE(profile, -[ --disable-profile do not build profiled libraries and programs],, - enable_profile=yes) +[ --disable-profile do not build profiled libraries and programs]) AC_SUBST(enable_profile) +define([default_static],['ext2fs,ufs'])dnl +AC_ARG_ENABLE(static-progs, +[ --enable-static-progs=PROGRAMS... + build statically-linked PROGRAM.static versions + of (only) the listed programs ]dnl +changequote(',')[default_static]changequote([,])) +case "$enable_static_progs" in +'no') enable_static_progs= ;; # we got --disable-static +'') enable_static_progs=default_static ;; +*) enable_static_progs=`echo "$enable_static_progs" | + sed 's/[[, ]][[, ]]*/ /g'` ;; +esac +AC_SUBST(enable_static_progs) + AC_PROG_INSTALL AC_PROG_AWK -- cgit v1.2.3 From f043e443830bf3f6aa6c29b1a3c8ed954bff4af6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Sep 1999 04:34:49 +0000 Subject: 1999-09-09 Roland McGrath * Makefile (makemode): servers -> server. (targets): Replaced with target; remove ufs.static. (ufs.static-LDFLAGS): Variable removed. (ufs.static, ufs): Remove deps. --- ufs/Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ufs/Makefile b/ufs/Makefile index 202316f8..c3bdc997 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,5 +1,5 @@ -# Copyright (C) 1994, 1995, 1996 Free Software Foundation +# Copyright (C) 1994,95,96,99 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 @@ -16,9 +16,9 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dir := ufs -makemode := servers +makemode := server -targets = ufs ufs.static +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 LCLHDRS = ufs.h fs.h dinode.h dir.h @@ -26,8 +26,4 @@ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) HURDLIBS = diskfs iohelp fshelp store pager ports threads ihash shouldbeinlibc -ufs.static-LDFLAGS += -static - include ../Makeconf - -ufs.static ufs: $(OBJS) $(library_deps) -- cgit v1.2.3 From 298788e891e149c18599d9b4e8cac308c1d1457c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Sep 1999 04:35:54 +0000 Subject: ChangeLog --- ufs/ChangeLog | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 4bebe284..0ab45a3d 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +1999-09-09 Roland McGrath + + * Makefile (makemode): servers -> server. + (targets): Replaced with target; remove ufs.static. + (ufs.static-LDFLAGS): Variable removed. + (ufs.static, ufs): Remove deps. + 1999-09-08 Thomas Bushnell, BSG * dir.c (diskfs_get_directs): Initialize `err' to shut gcc up. @@ -5,7 +12,7 @@ 1999-09-07 Thomas Bushnell, BSG * dir.c (diskfs_lookup_hard): Pass additional parameter to - diskfs_get_filemap. + diskfs_get_filemap. (diskfs_dirempty): Likewise. * sizes.c (diskfs_truncate): Likewise. (block_extended): Likewise. @@ -34,7 +41,7 @@ 1999-07-06 Thomas Bushnell, BSG * hyper.c (diskfs_readonly_changed): Use mprotect instead of - vm_protect. + vm_protect. Mon Jul 5 20:04:58 1999 Thomas Bushnell, BSG -- cgit v1.2.3 From ddbe575459786c3530c2d092b4193b6d41f1e80a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Sep 1999 06:35:11 +0000 Subject: Reverted changes related to io_map_segment. --- ufs/ChangeLog | 4 ++++ ufs/dir.c | 6 +++--- ufs/pager.c | 4 +--- ufs/sizes.c | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 0ab45a3d..09d4b17a 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +1999-09-13 Roland McGrath + + * dir.c, sizes.c, pager.c: Reverted changes related to io_map_segment. + 1999-09-09 Roland McGrath * Makefile (makemode): servers -> server. diff --git a/ufs/dir.c b/ufs/dir.c index aee08bb0..304c8a44 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -144,7 +144,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, ds->stat = LOOKING; /* Map in the directory contents. */ - memobj = diskfs_get_filemap (dp, 0, prot); + memobj = diskfs_get_filemap (dp, prot); if (memobj == MACH_PORT_NULL) return errno; @@ -730,7 +730,7 @@ diskfs_dirempty(struct node *dp, memory_object_t memobj; error_t err; - memobj = diskfs_get_filemap (dp, 0, VM_PROT_READ); + memobj = diskfs_get_filemap (dp, VM_PROT_READ); if (memobj == MACH_PORT_NULL) /* XXX should reflect error properly */ @@ -839,7 +839,7 @@ diskfs_get_directs (struct node *dp, char buf[DIRBLKSIZ]; char *bufp; int bufvalid; - error_t err = 0; + error_t err; int i; char *datap; struct directory_entry *entryp; diff --git a/ufs/pager.c b/ufs/pager.c index 3cba748e..3038932d 100644 --- a/ufs/pager.c +++ b/ufs/pager.c @@ -547,13 +547,11 @@ flush_node_pager (struct node *node) /* Call this to create a FILE_DATA pager and return a send right. NP must be locked. PROT is the max protection desired. */ mach_port_t -diskfs_get_filemap (struct node *np, int index, vm_prot_t prot) +diskfs_get_filemap (struct node *np, vm_prot_t prot) { struct user_pager_info *upi; mach_port_t right; - assert (index == 0); /* XXX */ - assert (S_ISDIR (np->dn_stat.st_mode) || S_ISREG (np->dn_stat.st_mode) || (S_ISLNK (np->dn_stat.st_mode) diff --git a/ufs/sizes.c b/ufs/sizes.c index cffce158..58cbfc98 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -103,7 +103,7 @@ diskfs_truncate (struct node *np, pager_change_attributes (upi->p, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1); - obj = diskfs_get_filemap (np, 0, VM_PROT_READ | VM_PROT_WRITE); + obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE); if (obj != MACH_PORT_NULL) { /* XXX should cope with errors from diskfs_get_filemap */ @@ -403,7 +403,7 @@ block_extended (struct node *np, volatile int *pokeaddr; /* Map in this part of the file */ - mapobj = diskfs_get_filemap (np, 0, VM_PROT_WRITE | VM_PROT_READ); + mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ); /* XXX Should cope with errors from diskfs_get_filemap and back out the operation here. */ @@ -484,7 +484,7 @@ diskfs_grow (struct node *np, assert (!diskfs_readonly); /* This reference will ensure that NP->dn->fileinfo stays allocated. */ - pagerpt = diskfs_get_filemap (np, 0, VM_PROT_WRITE|VM_PROT_READ); + pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ); if (pagerpt == MACH_PORT_NULL) return errno; -- cgit v1.2.3 From 7df981fd135d841dd0af0638bc16332a73a0ed70 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 19 Sep 1999 18:53:26 +0000 Subject: 1999-09-19 Roland McGrath * configure.in (enable_static_progs): Move sed translation of commas to spaces out of case stmt, so it applies to default too. --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 91420edc..9d65bb88 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.16 1999/09/13 04:34:38 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.17 1999/09/19 18:53:26 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -38,9 +38,9 @@ changequote(',')[default_static]changequote([,])) case "$enable_static_progs" in 'no') enable_static_progs= ;; # we got --disable-static '') enable_static_progs=default_static ;; -*) enable_static_progs=`echo "$enable_static_progs" | - sed 's/[[, ]][[, ]]*/ /g'` ;; esac +# Convert comma/space-separated list into space-separated list. +enable_static_progs=`echo "$enable_static_progs" | sed 's/[[, ]][[, ]]*/ /g'` AC_SUBST(enable_static_progs) AC_PROG_INSTALL -- cgit v1.2.3 From 7bb1561b0c4ea284293b46ad05308ae24c2d8324 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 6 Oct 1999 17:39:36 +0000 Subject: 1999-10-06 Roland McGrath * bootstrap.c (DEFAULT_ROOT): Change to "hd0s1". --- serverboot/bootstrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 3057e0a7..ce9e2e10 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -38,7 +38,7 @@ #include "../boot/boot_script.h" /* Use this device if no root specified. */ -#define DEFAULT_ROOT "hd0a" +#define DEFAULT_ROOT "hd0s1" #if 0 -- cgit v1.2.3 From 924b7a7ced241d8b3ebecc038bb9b2d6df3fb735 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 6 Oct 1999 17:39:51 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 4ae27298..10832cb7 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +1999-10-06 Roland McGrath + + * bootstrap.c (DEFAULT_ROOT): Change to "hd0s1". + 1999-08-20 Roland McGrath * bootstrap.c (parse_script): Add one to the buffer size so we can -- cgit v1.2.3 From c32ebe9139fdfd56904e8743c3aea55ed267b159 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 8 Oct 1999 13:32:41 +0000 Subject: 1999-10-08 Thomas Bushnell, BSG * bootstrap.c: (DEFAULT_ROOT): Remove macro. (main): If no root device was specified, then prompt as if the user had specified -a. --- serverboot/ChangeLog | 6 ++++++ serverboot/bootstrap.c | 13 +++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 10832cb7..3b25fce8 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,9 @@ +1999-10-08 Thomas Bushnell, BSG + + * bootstrap.c: (DEFAULT_ROOT): Remove macro. + (main): If no root device was specified, then prompt as if the + user had specified -a. + 1999-10-06 Roland McGrath * bootstrap.c (DEFAULT_ROOT): Change to "hd0s1". diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index ce9e2e10..69e4f892 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -37,10 +37,6 @@ #include "../boot/boot_script.h" -/* Use this device if no root specified. */ -#define DEFAULT_ROOT "hd0s1" - - #if 0 /* * Use 8 Kbyte stacks instead of the default 64K. @@ -236,15 +232,12 @@ main(argc, argv) panic_init(bootstrap_master_host_port); #endif - if (root_name[0] == '\0') - root_name = DEFAULT_ROOT; - /* - * If the '-a' (ask) switch was specified, ask for - * the root device. + * If the '-a' (ask) switch was specified, or if no + * root device was specificed, ask for the root device. */ - if (index(flag_string, 'a')) { + if (root_name [0] == '\0' || index(flag_string, 'a')) { static char new_root[16]; printf("root device? [%s] ", root_name); -- cgit v1.2.3 From 373a931f456740d06753b8a302d20b6ce80d8f28 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 8 Oct 1999 13:40:13 +0000 Subject: 1999-10-08 Thomas Bushnell, BSG * bootstrap.c: (DEFAULT_ROOT): Remove macro. (main): If no root device was specified, then prompt as if the user had specified -a. Don't use strcpy to move NEW_ROOT into ROOT_NAME; that's unsafe. --- serverboot/ChangeLog | 3 ++- serverboot/bootstrap.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 3b25fce8..3b878676 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -2,7 +2,8 @@ * bootstrap.c: (DEFAULT_ROOT): Remove macro. (main): If no root device was specified, then prompt as if the - user had specified -a. + user had specified -a. Don't use strcpy to move NEW_ROOT into + ROOT_NAME; that's unsafe. 1999-10-06 Roland McGrath diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 69e4f892..f6d6050a 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -237,14 +237,14 @@ main(argc, argv) * root device was specificed, ask for the root device. */ - if (root_name [0] == '\0' || index(flag_string, 'a')) { + if (!root_name || root_name [0] == '\0' || index(flag_string, 'a')) { static char new_root[16]; - + printf("root device? [%s] ", root_name); safe_gets(new_root, sizeof(new_root)); if (new_root[0] != '\0') - strcpy (root_name, new_root); + root_name = new_root; } (void) strbuild(boot_script_name, -- cgit v1.2.3 From f3fe7656d00377188237ec2a9b144408bb790384 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 8 Oct 1999 22:56:34 +0000 Subject: 1999-10-09 Marcus Brinkmann * rules (BUILDARCH): Renamed to DEB_BUILD_GNU_TYPE. (HOSTARCH): Renamed to DEB_HOST_GNU_TYPE. (INFODIR): New variable. (STAMPS_TO_CLEAN): Add stamp-config. (configure): Depend on configure.in. (config, stamp-config): New targets. (stamp-build): Build info documentation. (clean): Do not clean up build directory, it will be removed. Clean documentation directory. (binary-arch): Remove etc/motd. Expand bash {,} syntax. Gzip serverboot. Install additional documentation formats. Rename libexec/runsystem to libexec/runsystem.gnu. Install postinst, prerm (.PHONY): Add config. --- debian/rules | 68 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/debian/rules b/debian/rules index 4e5ce53c..521e0b1d 100755 --- a/debian/rules +++ b/debian/rules @@ -5,9 +5,9 @@ ## Created On : Sat, 1 Aug 1998 21:33:31 +0200 ## Created On Node : localhost ## Last Modified By : Marcus Brinkmann -## Last Modified On : Mon, 4 Jan 1999 03:37:08 +0100 +## Last Modified On : Thu, 23 Sep 1999 01:41:38 +0200 ## Last Machine Used: localhost -## Update Count : 1 +## Update Count : 2 ## Status : Unknown, Use with caution! ## HISTORY : ## Description : @@ -16,8 +16,9 @@ # The name of the package (for example, `emacs'). package := hurd -BUILDARCH := $(DEB_BUILD_GNU_TYPE) -HOSTARCH := $(DEB_HOST_GNU_TYPE) + +DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) # Configuration variables (these should be pretty generic) CC = cc @@ -26,6 +27,7 @@ LDFLAGS = -s PREFIX = /usr BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man +INFODIR = $(PREFIX)/info DOCDIR = $(PREFIX)/doc/$(package) # Package specific stuff. The idea is to try to make the rules @@ -33,7 +35,7 @@ DOCDIR = $(PREFIX)/doc/$(package) FILES_TO_CLEAN = debian/files include/*.h DIRS_TO_CLEAN = debian/tmp debian/$(package)-dev build -STAMPS_TO_CLEAN = stamp-build +STAMPS_TO_CLEAN = stamp-build stamp-config install_file = install -o root -g root -m 644 install_program = install -s -o root -g root -m 755 @@ -47,25 +49,38 @@ define checkroot @test 0 = "`id -u`" || (echo need root priviledges; exit 1) endef -all build: stamp-build +# Next is NOT a phony target. -configure: +configure: configure.in aclocal autoconf -stamp-build: configure +# The next IS a phony target. + +config: stamp-config +stamp-config: configure + $(checkdir) + -mkdir build + cd build && ../configure --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_HOST_GNU_TYPE) --prefix= + touch stamp-config + +all build: config stamp-build +stamp-build: $(checkdir) - mkdir build - cd build && ../configure --build=$(BUILDARCH) --host=$(HOSTARCH) --prefix= -# go and fetch a few beers now... cd build && $(MAKE) no_prof=t +# XXX-doc + cd build && $(MAKE) -C doc hurd.info + cd build && $(MAKE) -C doc hurd.ps touch stamp-build clean: $(checkdir) - -cd build && make clean no_deps=t +# -cd build && make clean no_deps=t -rm -f $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN) -rm -rf $(DIRS_TO_CLEAN) +# XXX-doc + -rm -f doc/hurd.d doc/hurd.info* version.texi for NAME in hurd/*.h; do \ if [ -L $$NAME ] ; then \ rm -f $$NAME ; \ @@ -77,7 +92,9 @@ clean: binary: binary-indep binary-arch -# Build architecture-independent files here. +binary-indep: +# We have nothing to do here. + binary-arch: build $(checkdir) $(checkroot) @@ -88,6 +105,8 @@ binary-arch: build cd build && $(MAKE) install prefix=`pwd`/../debian/tmp no_prof=t # kill the profiling libs -rm -f debian/tmp/lib/*_p.a +# /etc/motd is in base-files! + -rm -f debian/tmp/etc/motd # probably we'll make debug packages later, for now, strip'em -strip --strip-unneeded debian/tmp/lib/lib*.so -strip --strip-debug debian/tmp/lib/lib*.a @@ -120,7 +139,12 @@ binary-arch: build dpkg --build debian/$(package)-dev .. # now the shared libs and other stuff - $(make_directory) debian/tmp/{DEBIAN,usr/doc/$(package)} + $(make_directory) debian/tmp/DEBIAN + $(make_directory) debian/tmp$(DOCDIR) + $(make_directory) debian/tmp$(INFODIR) + + gzip -9fq debian/tmp/boot/serverboot + # Only found in CVS, not the distribution. # $(install_file) BUGS debian/tmp$(DOCDIR) # $(install_file) TODO debian/tmp$(DOCDIR) @@ -131,21 +155,29 @@ binary-arch: build $(install_file) ChangeLog debian/tmp$(DOCDIR)/changelog $(install_file) debian/README.Debian debian/tmp$(DOCDIR) $(install_file) debian/changelog debian/tmp$(DOCDIR)/changelog.Debian +# XXX-doc + $(install_file) build/doc/hurd.ps debian/tmp$(DOCDIR) gzip -9frq debian/tmp$(DOCDIR)/. $(install_file) debian/copyright debian/tmp$(DOCDIR) +# XXX-doc + $(install_file) build/doc/hurd.info* debian/tmp$(INFODIR) + -gzip -9frq debian/tmp$(INFODIR) + $(install_file) debian/servers.boot debian/tmp/boot/servers.boot $(make_directory) debian/tmp/servers +# libexec/runsystem is managed by update-alternatives + mv debian/tmp/libexec/runsystem debian/tmp/libexec/runsystem.gnu + $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs + $(install_program) debian/postinst debian/tmp/DEBIAN/postinst + $(install_program) debian/prerm debian/tmp/DEBIAN/prerm dpkg-shlibdeps -p$(package) debian/tmp/bin/* debian/tmp/libexec/* debian/tmp/hurd/* debian/tmp/sbin/* dpkg-gencontrol -p$(package) -Pdebian/tmp chown -R root.root debian/tmp dpkg --build debian/tmp .. -binary-indep: build -# We have nothing to do here. - -.PHONY: build clean binary-indep binary-arch binary +.PHONY: build config clean binary-indep binary-arch binary -- cgit v1.2.3 From 41efadd2b9330400deda2c417743e07ce3d414aa Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 8 Oct 1999 22:56:43 +0000 Subject: 1999-10-09 Marcus Brinkmann * postinst, prerm: New Files. * shlibs,shlibs.local: Remove libmom. * changelog: Update to reflect Debian uploads. --- debian/changelog | 44 ++++++++++++++++++++++++++++++++++++++++++-- debian/shlibs | 1 - debian/shlibs.local | 1 - 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 638509c7..5585f88e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,48 @@ -hurd (19990601) unstable; urgency=low +hurd (19991004) unstable; urgency=high * New snapshot from CVS. + term: Realize bogus devices. + ext2fs: Important bug fixes! - -- Marcus Brinkmann Tue, 1 Jun 1999 19:25:37 +0200 + -- Marcus Brinkmann Sun, 3 Oct 1999 18:01:17 +0200 + +hurd (19990923) unstable; urgency=low + + * New snapshot from CVS. + MAKEDEV: pty created with mode 0666. + Implements pathconf for libdiskfs and libnetfs. + Various bug fixes. + * Development package now includes pic libraries. + + -- Marcus Brinkmann Sun, 19 Sep 1999 19:29:00 +0200 + +hurd (19990907) unstable; urgency=low + + * New snapshot from CVS. + * gzip /boot/serverboot to /boot/serverboot.gz + + -- Marcus Brinkmann Mon, 23 Aug 1999 15:12:10 +0200 + +hurd (19990725) unstable; urgency=low + + * New snapshot from CVS. + + -- Marcus Brinkmann Thu, 25 Jul 1999 16:16:03 +0200 + +hurd (19990714) unstable; urgency=low + + * New snapshot from CVS. + * debian/rules: etc/motd is in base-files, do not include it. + * Activate split-init. + + -- Marcus Brinkmann Wed, 14 Jul 1999 16:38:00 +0200 + +hurd (19990616) unstable; urgency=low + + * New snapshot from CVS. + * Now contains info and ps documentation. + + -- Marcus Brinkmann Thu, 17 Jun 1999 17:35:54 +0200 hurd (19990524) unstable; urgency=low diff --git a/debian/shlibs b/debian/shlibs index cfa417e5..267f4976 100644 --- a/debian/shlibs +++ b/debian/shlibs @@ -1,7 +1,6 @@ libshouldbeinlibc 0.2 hurd libftpconn 0.2 hurd libports 0.2 hurd -libmom 0.2 hurd libthreads 0.2 hurd libhurdbugaddr 0.2 hurd libstore 0.2 hurd diff --git a/debian/shlibs.local b/debian/shlibs.local index b4fbdcc5..910a73c7 100644 --- a/debian/shlibs.local +++ b/debian/shlibs.local @@ -1,7 +1,6 @@ libshouldbeinlibc 0.2 libftpconn 0.2 libports 0.2 -libmom 0.2 libthreads 0.2 libhurdbugaddr 0.2 libstore 0.2 -- cgit v1.2.3 From 0b4574e02fa6dcf7ace55e63a2a2c94d2b775134 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 8 Oct 1999 22:57:32 +0000 Subject: 1999-10-09 Marcus Brinkmann * rules (BUILDARCH): Renamed to DEB_BUILD_GNU_TYPE. (HOSTARCH): Renamed to DEB_HOST_GNU_TYPE. (INFODIR): New variable. (STAMPS_TO_CLEAN): Add stamp-config. (configure): Depend on configure.in. (config, stamp-config): New targets. (stamp-build): Build info documentation. (clean): Do not clean up build directory, it will be removed. Clean documentation directory. (binary-arch): Remove etc/motd. Expand bash {,} syntax. Gzip serverboot. Install additional documentation formats. Rename libexec/runsystem to libexec/runsystem.gnu. Install postinst, prerm (.PHONY): Add config. * postinst, prerm: New Files. * shlibs,shlibs.local: Remove libmom. * changelog: Update to reflect Debian uploads. --- debian/postinst | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/prerm | 71 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 debian/postinst create mode 100644 debian/prerm diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..89c26bec --- /dev/null +++ b/debian/postinst @@ -0,0 +1,89 @@ +#! /bin/sh +# postinst.skeleton +# Skeleton maintainer script showing all the possible cases. +# Written by Charles Briscoe-Smith, March-June 1998. Public Domain. + +# Abort if any command returns an error value +set -e + +# This script is called as the last step of the installation of the +# package. All the package's files are in place, dpkg has already done +# its automatic conffile handling, and all the packages we depend of +# are already fully installed and configured. + +# The following idempotent stuff doesn't generally need protecting +# against being run in the abort-* cases. + +# Install info files into the dir file. + +install-info --quiet --section "Hurd" "The Hurd" /usr/info/hurd.info.gz + +# Manage alternatives. + +update-alternatives --quiet \ + --install /libexec/runsystem runsystem /libexec/runsystem.gnu 20 + +# Take care that a "login" user exists. Useful for our login shell. + +if ! grep --quiet '^login:' /etc/passwd ; then + adduser --quiet --system --home /etc/login --gecos "Not logged in" --no-create-home login + chsh -s /bin/bash login +fi + +case "$1" in + configure) + # Configure this package. If the package must prompt the user for + # information, do it here. + + # There are three sub-cases: + if test "${2+set}" != set; then + # We're being installed by an ancient dpkg which doesn't remember + # which version was most recently configured, or even whether + # there is a most recently configured version. + : + + elif test -z "$2" -o "$2" = ""; then + # The package has not ever been configured on this system, or was + # purged since it was last configured. + : + + else + # Version $2 is the most recently configured version of this + # package. + : + + fi ;; + abort-upgrade) + # Back out of an attempt to upgrade this package FROM THIS VERSION + # to version $2. Undo the effects of "prerm upgrade $2". + : + + ;; + abort-remove) + if test "$2" != in-favour; then + echo "$0: undocumented call to \`postinst $*'" 1>&2 + exit 0 + fi + # Back out of an attempt to remove this package, which was due to + # a conflict with package $3 (version $4). Undo the effects of + # "prerm remove in-favour $3 $4". + : + + ;; + abort-deconfigure) + if test "$2" != in-favour -o "$5" != removing; then + echo "$0: undocumented call to \`postinst $*'" 1>&2 + exit 0 + fi + # Back out of an attempt to deconfigure this package, which was + # due to package $6 (version $7) which we depend on being removed + # to make way for package $3 (version $4). Undo the effects of + # "prerm deconfigure in-favour $3 $4 removing $6 $7". + : + + ;; + *) echo "$0: didn't understand being called with \`$1'" 1>&2 + exit 0;; +esac + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 00000000..e6adae87 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,71 @@ +#!/bin/sh + +# Abort if any command returns an error value +set -e + +# This script is called as the first step in removing the package from +# the system. This includes cases where the user explicitly asked for +# the package to be removed, upgrade, automatic removal due to conflicts, +# and deconfiguration due to temporary removal of a depended-on package. + +# Info files should be uninstalled from the dir file in any case. +install-info --quiet --remove hurd + +# Because we run this in almost all cases, we do it here instead below. + +if [ "$1" != "upgrade" ]; then + update-alternatives --remove runsystem /libexec/runsystem.gnu +fi + +case "$1" in + remove) + # This package about to be removed. + : + + # There are two sub-cases: + if test "${2+set}" = set; then + if test "$2" != in-favour; then + echo "$0: undocumented call to \`prerm $*'" 1>&2 + exit 0 + fi + # We are being removed because of a conflict with package $3 + # (version $4), which is now being installed. + : + + else + # The package is being removed in its own right. + : + + fi + + + ;; + + deconfigure) + if test "$2" != in-favour -o "$5" != removing; then + echo "$0: undocumented call to \`prerm $*'" 1>&2 + exit 0 + fi + # Package $6 (version $7) which we depend on is being removed due + # to a conflict with package $3 (version $4), and this package is + # being deconfigured until $6 can be reinstalled. + : + + ;; + upgrade) + # Prepare to upgrade FROM THIS VERSION of this package to version $2. + : + + ;; + failed-upgrade) + # Prepare to upgrade from version $2 of this package TO THIS VERSION. + # This is only used if the old version's prerm couldn't handle it, + # and returned non-zero. (Fix old prerm bugs here.) + : + + ;; + *) echo "$0: didn't understand being called with \`$1'" 1>&2 + exit 0;; +esac + +exit 0 -- cgit v1.2.3 From 694a16a9db2eb446c00c1ebeb5c5cbe831f8e4ab Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 8 Oct 1999 22:57:42 +0000 Subject: updates from marcus --- debian/ChangeLog | 23 +++++++++++++++++++++++ debian/TODO | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index c5084a4d..45cacc3a 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,26 @@ +1999-10-09 Marcus Brinkmann + + * rules (BUILDARCH): Renamed to DEB_BUILD_GNU_TYPE. + (HOSTARCH): Renamed to DEB_HOST_GNU_TYPE. + (INFODIR): New variable. + (STAMPS_TO_CLEAN): Add stamp-config. + (configure): Depend on configure.in. + (config, stamp-config): New targets. + (stamp-build): Build info documentation. + (clean): Do not clean up build directory, it will be removed. + Clean documentation directory. + (binary-arch): Remove etc/motd. + Expand bash {,} syntax. + Gzip serverboot. + Install additional documentation formats. + Rename libexec/runsystem to libexec/runsystem.gnu. + Install postinst, prerm + (.PHONY): Add config. + + * postinst, prerm: New Files. + * shlibs,shlibs.local: Remove libmom. + * changelog: Update to reflect Debian uploads. + 1999-06-01 Marcus Brinkmann * TODO: Remove entry about shared library dependencies (see below). diff --git a/debian/TODO b/debian/TODO index bc703349..ba3dc95e 100644 --- a/debian/TODO +++ b/debian/TODO @@ -2,8 +2,10 @@ * Split into multiple packages, so that we can provide virtual packages that correspond closer to the existing Debian GNU/Linux - ones. + ones. But be careful that you don't use existing packagenames, or + bug reports will not be assigned correctly. * A postinstallation script which sets up translators correctly. + Better a script that manages translators, so changes by users are honored. -* Do something with the Texinfo documentation. +* Split out pic libraries, build profiling libs (when they work). -- cgit v1.2.3 From 822faaf3dcbee03f1aae496e6240769e5b6c0d27 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 13 Oct 1999 19:37:29 +0000 Subject: 1999-10-13 Roland McGrath * consts.c (diskfs_name_max): New variable. --- ufs/consts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/consts.c b/ufs/consts.c index 8806049e..69221233 100644 --- a/ufs/consts.c +++ b/ufs/consts.c @@ -1,5 +1,5 @@ /* Various constants wanted by the diskfs library - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1999 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 @@ -16,9 +16,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ufs.h" +#include "dir.h" #include int diskfs_link_max = LINK_MAX; +int diskfs_name_max = MAXNAMLEN; int diskfs_maxsymlinks = 8; int diskfs_shortcut_symlink = 1; int diskfs_shortcut_chrdev = 1; -- cgit v1.2.3 From 1a4ef01d300a7ad85cd44f2cba7528fb2e00ebfb Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 13 Oct 1999 19:42:28 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 09d4b17a..02120e59 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +1999-10-13 Roland McGrath + + * consts.c (diskfs_name_max): New variable. + 1999-09-13 Roland McGrath * dir.c, sizes.c, pager.c: Reverted changes related to io_map_segment. -- cgit v1.2.3 From febab894f78d6cf509544872e075c3204d35b9d6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 28 Oct 1999 20:51:36 +0000 Subject: 1999-10-28 Roland McGrath * file_io.h: Include . (FS_* macros): Define these to equivalent errno codes. * def_pager_setup.c (add_paging_file): Put strerror of result code in error messages. * bootstrap.c (parse_script): Likewise. * load.c (boot_script_exec_cmd): Include NAMEBUF in error messages, and use strerror to format result code. * panic.c (panic): Use program_invocation_name in message. --- serverboot/bootstrap.c | 35 ++++++++++++++++++++++++----------- serverboot/def_pager_setup.c | 5 +++-- serverboot/file_io.h | 21 +++++++++++++++++++-- serverboot/load.c | 18 +++++++++++++----- serverboot/panic.c | 15 ++++++++------- 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index f6d6050a..41fe7591 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -29,6 +29,7 @@ #include #include +#include #include @@ -112,8 +113,12 @@ boot_panic (kern_return_t err) void safe_gets (char *str, int maxlen) { - char *c; - c = strchr (fgets (str, maxlen, stdin), '\n'); + 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"); @@ -122,7 +127,14 @@ safe_gets (char *str, int maxlen) printf_init (device_t master) { mach_port_t cons; - device_open (master, D_READ|D_WRITE, "console", &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); @@ -224,22 +236,22 @@ main(argc, argv) &bootstrap_master_device_port); } - - - printf_init(bootstrap_master_device_port); #ifdef pleasenoXXX panic_init(bootstrap_master_host_port); #endif + printf ("serverboot flags %s root=%s\n", flag_string, root_name); + + /* - * If the '-a' (ask) switch was specified, or if no + * 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')) { - static char new_root[16]; - + static char new_root[MAXPATHLEN/2]; + printf("root device? [%s] ", root_name); safe_gets(new_root, sizeof(new_root)); @@ -431,8 +443,9 @@ parse_script (struct file *f) int n = 0; buf = malloc (f->f_size + 1); /* add one for null terminator we will write */ - if (read_file (f, 0, buf, f->f_size, 0)) - panic ("bootstrap: error reading boot script file"); + 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) diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c index 194f0355..8834a379 100644 --- a/serverboot/def_pager_setup.c +++ b/serverboot/def_pager_setup.c @@ -58,11 +58,12 @@ add_paging_file(master_device_port, file_name, linux_signature) result = open_file_direct(pfile.f_dev, fdp, isa_file); if (result) - panic("Can't open paging file %s\n", file_name); + 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: %d\n", result); + panic("Can't read disk addresses: %s\n", strerror (result)); close_file(&pfile); diff --git a/serverboot/file_io.h b/serverboot/file_io.h index 5706ce5b..8a1a6e34 100644 --- a/serverboot/file_io.h +++ b/serverboot/file_io.h @@ -162,13 +162,30 @@ extern int page_write_file_direct(); * Error codes for file system errors. */ +#include + +/* 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 - a routine */ +#define FS_INVALID_PARAMETER 5006 /* bad parameter to routine */ +#endif + #endif /* _FILE_IO_H_ */ diff --git a/serverboot/load.c b/serverboot/load.c index 3898eac6..a4f48ba3 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -273,7 +273,7 @@ boot_script_exec_cmd (task_t user_task, result = open_file(bootstrap_master_device_port, namebuf, &file); if (result != 0) { - panic("openi %d", result); + panic ("%s: %s", namebuf, strerror (result)); } env_len = 0; @@ -308,6 +308,7 @@ boot_script_exec_cmd (task_t user_task, st.user_task = user_task; st.aout_symtab_size = 0; st.aout_strtab_size = 0; +printf("serverboot loading %s\n", file_name); result = exec_load(prog_read, prog_read_exec, &st, &info); #ifdef GZIP if (result) @@ -360,7 +361,7 @@ boot_script_exec_cmd (task_t user_task, } #endif BZIP2 if (result) - panic("(serverboot) exec_load %s: error %d", namebuf, result); + panic ("cannot load %s: %s", namebuf, strerror (result)); #if 0 printf("(serverboot): loaded %s; entrypoint %08x\n", namebuf, info.entry); #endif @@ -370,9 +371,11 @@ boot_script_exec_cmd (task_t user_task, */ result = thread_create (user_task, &user_thread); if (result) - panic ("can't create user thread for %s: %x", namebuf, result); + panic ("can't create user thread for %s: %s", namebuf, + strerror (result)); arg_pos = set_regs(user_task, user_thread, &info, arg_len); +printf("set up user thread\n"); /* * Read symbols from the executable file. */ @@ -451,15 +454,19 @@ boot_script_exec_cmd (task_t user_task, /* * Then the strings and string pointers for each argument */ - for (i = 0; i < arg_count; i++) + for (i = 0; i < arg_count; i++) { + printf("\targv[%d] = %s\n", i, argv[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++) + for (i = 0; i < envc; i++) { + printf("\tenviron[%d] = %s\n", i, environ[i]); *k_ap++ = environ[i] - environ[0] + u_cp; + } *k_ap = (char *)0; bcopy (environ[0], k_cp, env_len); @@ -481,6 +488,7 @@ boot_script_exec_cmd (task_t user_task, */ close_file(&file); +printf ("resume user thread...\n"); /* Resume the thread. */ thread_resume (user_thread); mach_port_deallocate (mach_task_self (), user_thread); diff --git a/serverboot/panic.c b/serverboot/panic.c index 80197500..87428429 100644 --- a/serverboot/panic.c +++ b/serverboot/panic.c @@ -1,25 +1,25 @@ -/* +/* * 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. */ @@ -27,6 +27,7 @@ #include #include #include +#include static mach_port_t master_host_port; @@ -44,7 +45,7 @@ panic(s, va_alist) va_list listp; clearerr (stdout); - printf("bootstrap/default-pager panic: "); + printf("%s: panic: ", program_invocation_name); va_start(listp); vprintf(s, listp); va_end(listp); -- cgit v1.2.3 From 52ea1586e07a7aa05f15713bc1edb743e160396f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 28 Oct 1999 20:51:43 +0000 Subject: . --- serverboot/ChangeLog | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 3b878676..ad2b20d0 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,9 +1,20 @@ +1999-10-28 Roland McGrath + + * file_io.h: Include . + (FS_* macros): Define these to equivalent errno codes. + * def_pager_setup.c (add_paging_file): Put strerror of result code in + error messages. + * bootstrap.c (parse_script): Likewise. + * load.c (boot_script_exec_cmd): Include NAMEBUF in error messages, + and use strerror to format result code. + * panic.c (panic): Use program_invocation_name in message. + 1999-10-08 Thomas Bushnell, BSG * bootstrap.c: (DEFAULT_ROOT): Remove macro. (main): If no root device was specified, then prompt as if the user had specified -a. Don't use strcpy to move NEW_ROOT into - ROOT_NAME; that's unsafe. + ROOT_NAME; that's unsafe. 1999-10-06 Roland McGrath -- cgit v1.2.3 From 36cc6f5c3c22d63b427ead67d8ed3449f8ac6835 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 28 Oct 1999 21:16:57 +0000 Subject: 1999-10-28 Roland McGrath * load.c, bootstrap.c: Back out some debugging printfs accidentally included in the last commit. * bootstrap.c (main): Increase size of NEW_ROOT buffer. This change was included in the last commit, but not logged then. --- serverboot/bootstrap.c | 2 -- serverboot/load.c | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 41fe7591..7ac38a2c 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -241,8 +241,6 @@ main(argc, argv) panic_init(bootstrap_master_host_port); #endif - printf ("serverboot flags %s root=%s\n", flag_string, root_name); - /* * If the '-a' (ask) switch was specified, or if no diff --git a/serverboot/load.c b/serverboot/load.c index a4f48ba3..fc16baf1 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -308,7 +308,6 @@ boot_script_exec_cmd (task_t user_task, st.user_task = user_task; st.aout_symtab_size = 0; st.aout_strtab_size = 0; -printf("serverboot loading %s\n", file_name); result = exec_load(prog_read, prog_read_exec, &st, &info); #ifdef GZIP if (result) @@ -375,7 +374,6 @@ printf("serverboot loading %s\n", file_name); strerror (result)); arg_pos = set_regs(user_task, user_thread, &info, arg_len); -printf("set up user thread\n"); /* * Read symbols from the executable file. */ @@ -454,19 +452,15 @@ printf("set up user thread\n"); /* * Then the strings and string pointers for each argument */ - for (i = 0; i < arg_count; i++) { - printf("\targv[%d] = %s\n", i, argv[i]); + 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++) { - printf("\tenviron[%d] = %s\n", i, environ[i]); + 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); @@ -488,7 +482,6 @@ printf("set up user thread\n"); */ close_file(&file); -printf ("resume user thread...\n"); /* Resume the thread. */ thread_resume (user_thread); mach_port_deallocate (mach_task_self (), user_thread); -- cgit v1.2.3 From 2df37f50a446d4888e4765ba241778c81ae523f2 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 28 Oct 1999 21:17:15 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index ad2b20d0..cc010072 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,10 @@ 1999-10-28 Roland McGrath + * load.c, bootstrap.c: Back out some debugging printfs accidentally + included in the last commit. + * bootstrap.c (main): Increase size of NEW_ROOT buffer. + This change was included in the last commit, but not logged then. + * file_io.h: Include . (FS_* macros): Define these to equivalent errno codes. * def_pager_setup.c (add_paging_file): Put strerror of result code in -- cgit v1.2.3 From 9c8f90e4d205c36e04638f0f4b97be5fec2f1fff Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 8 Nov 1999 21:58:34 +0000 Subject: 1999-11-08 Roland McGrath * bootstrap.c (main): Further spruce up prompting and error reporting for root device and boot script. --- serverboot/bootstrap.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 7ac38a2c..46935a26 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -182,6 +182,25 @@ main(argc, argv) 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; @@ -190,6 +209,7 @@ main(argc, argv) char *flag_string; boolean_t ask_boot_script = 0; + boolean_t ask_root_name = 0; /* * Use 4Kbyte cthread wait stacks. @@ -247,22 +267,14 @@ main(argc, argv) * root device was specificed, ask for the root device. */ - if (!root_name || root_name [0] == '\0' || index(flag_string, 'a')) { - static char new_root[MAXPATHLEN/2]; - - printf("root device? [%s] ", root_name); - safe_gets(new_root, sizeof(new_root)); - - if (new_root[0] != '\0') - root_name = new_root; - } + 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. @@ -272,6 +284,9 @@ main(argc, argv) ask_boot_script = TRUE; while (TRUE) { + if (ask_root_name) + prompt_for_root (); + if (ask_boot_script) { char new_boot_script[MAXPATHLEN]; @@ -284,10 +299,18 @@ main(argc, argv) 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: %d\n", + printf("Can't open server boot script %s: %s\n", boot_script_name, - result); + strerror (result)); ask_boot_script = TRUE; continue; } -- cgit v1.2.3 From 7f9db970d5071e747d6ca2972a2de76239181a73 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 8 Nov 1999 22:00:07 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index cc010072..f1a1b7a3 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +1999-11-08 Roland McGrath + + * bootstrap.c (main): Further spruce up prompting and error reporting + for root device and boot script. + 1999-10-28 Roland McGrath * load.c, bootstrap.c: Back out some debugging printfs accidentally -- cgit v1.2.3 From 684b3d69287635f6bdd794cd7f49c6e9a6dfc1cf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:57:32 +0000 Subject: 1999-11-16 Roland McGrath * ffs_file_io.c (ffs_open_file): Use memmove instead of ovbcopy. * ext2_file_io.c (ext2_open_file): Likewise. * strfcns.c (ovbcopy): Function removed. --- serverboot/ext2_file_io.c | 2 +- serverboot/ffs_file_io.c | 2 +- serverboot/strfcns.c | 37 +++++++------------------------------ 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c index d25fd9db..d96ad576 100644 --- a/serverboot/ext2_file_io.c +++ b/serverboot/ext2_file_io.c @@ -651,7 +651,7 @@ ext2_open_file(master_device_port, path, fp) if (++nlinks > MAXSYMLINKS) RETURN (FS_SYMLINK_LOOP); - ovbcopy(cp, &namebuf[link_len], len); + memmove(&namebuf[link_len], cp, len); #ifdef IC_FASTLINK if (fp->i_ic.i_blocks == 0) { diff --git a/serverboot/ffs_file_io.c b/serverboot/ffs_file_io.c index ce67fdc8..0055c302 100644 --- a/serverboot/ffs_file_io.c +++ b/serverboot/ffs_file_io.c @@ -625,7 +625,7 @@ ffs_open_file(master_device_port, path, fp) if (++nlinks > MAXSYMLINKS) RETURN (FS_SYMLINK_LOOP); - ovbcopy(cp, &namebuf[link_len], len); + memmove (&namebuf[link_len], cp, len); #ifdef IC_FASTLINK if ((fp->i_flags & IC_FASTLINK) != 0) { diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 53c097ba..85e5eb83 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -1,26 +1,26 @@ -/* +/* * 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 + * + * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* @@ -74,28 +74,6 @@ strprefix(s1, s2) return (TRUE); } -/* - * ovbcopy - like bcopy, but recognizes overlapping ranges and handles - * them correctly. - */ -ovbcopy(from, to, bytes) - char *from, *to; - int bytes; /* num bytes to copy */ -{ - /* Assume that bcopy copies left-to-right (low addr first). */ - if (from + bytes <= to || to + bytes <= from || to == from) - bcopy(from, to, bytes); /* non-overlapping or no-op*/ - else if (from > to) - bcopy(from, to, bytes); /* overlapping but OK */ - else { - /* to > from: overlapping, and must copy right-to-left. */ - from += bytes - 1; - to += bytes - 1; - while (bytes-- > 0) - *to-- = *from--; - } -} - /* * Return a pointer to the first occurence of 'c' in * string s, or 0 if none. @@ -114,4 +92,3 @@ index(s, c) } return s; } - -- cgit v1.2.3 From 743b8a0429a4801b696c4b10cb262e638b94002c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:57:50 +0000 Subject: . --- serverboot/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index f1a1b7a3..9c83ebe1 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,9 @@ +1999-11-16 Roland McGrath + + * ffs_file_io.c (ffs_open_file): Use memmove instead of ovbcopy. + * ext2_file_io.c (ext2_open_file): Likewise. + * strfcns.c (ovbcopy): Function removed. + 1999-11-08 Roland McGrath * bootstrap.c (main): Further spruce up prompting and error reporting -- cgit v1.2.3 From f7796d16d3e37778bf200237228c68763c9a33d5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:59:12 +0000 Subject: 1999-11-16 Roland McGrath * strfcns.c (index): Function removed. --- serverboot/strfcns.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 85e5eb83..82a76728 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -73,22 +73,3 @@ strprefix(s1, s2) } return (TRUE); } - -/* - * Return a pointer to the first occurence of 'c' in - * string s, or 0 if none. - */ -char * -index(s, c) - char *s; - char c; -{ - char cc; - - while ((cc = *s) != c) { - if (cc == 0) - return 0; - s++; - } - return s; -} -- cgit v1.2.3 From 7c1b1940c5d50e0f011bd998ad6433238a7b243b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:59:26 +0000 Subject: . --- serverboot/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 9c83ebe1..9ec80617 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,7 @@ 1999-11-16 Roland McGrath + * strfcns.c (index): Function removed. + * ffs_file_io.c (ffs_open_file): Use memmove instead of ovbcopy. * ext2_file_io.c (ext2_open_file): Likewise. * strfcns.c (ovbcopy): Function removed. -- cgit v1.2.3 From 2a3a644af059fd988d9b7e24e9dd31942fcce70c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:22:34 +0000 Subject: 1999-11-16 Roland McGrath * default_pager.c (default_pager_initialize): Use MACH_PORT_VALID to check old DMM port, rather than just checking for MACH_PORT_NULL. --- serverboot/default_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index d2de5cdd..783e311e 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -3074,7 +3074,7 @@ default_pager_initialize(host_port) DMM = default_pager_default_port; kr = vm_set_default_memory_manager(host_port, &DMM); - if ((kr != KERN_SUCCESS) || (DMM != MACH_PORT_NULL)) + if ((kr != KERN_SUCCESS) || MACH_PORT_VALID(DMM)) panic(my_name); /* -- cgit v1.2.3 From 1b817868af61984cf975472233ebed76a922b02a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:22:40 +0000 Subject: 1999-11-18 Roland McGrath * wiring.c (wire_all_memory): Touch pages before wiring. --- serverboot/wiring.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/serverboot/wiring.c b/serverboot/wiring.c index ddcbd373..585a3075 100644 --- a/serverboot/wiring.c +++ b/serverboot/wiring.c @@ -1,25 +1,25 @@ -/* +/* * 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. */ @@ -107,7 +107,31 @@ wire_all_memory() if (MACH_PORT_VALID(object)) (void) mach_port_deallocate(this_task, object); if (protection != VM_PROT_NONE) - wire_memory(address, size, protection); + { + /* The VM system cannot cope with a COW fault on another + unrelated virtual copy happening later when we have + wired down the original page. So we must touch all our + pages before wiring to make sure that only we will ever + use them. */ + void *page; + if (!(protection & VM_PROT_WRITE)) + { + kr = vm_protect(this_task, address, size, + 0, max_protection); + } + for (page = (void *) address; + page < (void *) (address + size); + page += vm_page_size) + *(volatile int *) page = *(int *) page; + + wire_memory(address, size, protection); + + if (!(protection & VM_PROT_WRITE)) + { + kr = vm_protect(this_task, address, size, + 0, protection); + } + } address += size; } } @@ -149,4 +173,3 @@ __vm_allocate (task, address, size, anywhere) { return vm_allocate (task, address, size, anywhere); } - -- cgit v1.2.3 From d9afcd47d152bbec1b0ca28b4bb0c893173a8c96 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:23:45 +0000 Subject: . --- serverboot/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 9ec80617..f0aa97f5 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,12 @@ +1999-11-18 Roland McGrath + + * wiring.c (wire_all_memory): Touch pages before wiring. + 1999-11-16 Roland McGrath + * default_pager.c (default_pager_initialize): Use MACH_PORT_VALID to + check old DMM port, rather than just checking for MACH_PORT_NULL. + * strfcns.c (index): Function removed. * ffs_file_io.c (ffs_open_file): Use memmove instead of ovbcopy. -- cgit v1.2.3 From 486c73aad8070a70a38aaba47eff125cf1ee669b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:38:50 +0000 Subject: 1999-11-18 Roland McGrath * default_pager.c (default_pager): Instead of suspending this thread, just become the default_pager_default_thread thread ourselves. --- serverboot/default_pager.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 783e311e..198bb224 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -3185,9 +3185,12 @@ default_pager() for (i = 0; i < default_pager_external_count; i++) start_default_pager_thread(FALSE); + default_pager_default_thread(0); /* Become the default_pager server */ +#if 0 cthread_fork (default_pager_default_thread, 0); /* cthread_exit (cthread_self ()); */ thread_suspend (mach_thread_self ()); +#endif } /* -- cgit v1.2.3 From 7714e0e88003b7a4560fc673a469329ca4186338 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:38:59 +0000 Subject: . --- serverboot/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index f0aa97f5..a200a14e 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,8 @@ 1999-11-18 Roland McGrath + * default_pager.c (default_pager): Instead of suspending this thread, + just become the default_pager_default_thread thread ourselves. + * wiring.c (wire_all_memory): Touch pages before wiring. 1999-11-16 Roland McGrath -- cgit v1.2.3 From 87e719c0caf53ef83dc0a9ba22ac52378efddf52 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 21 Nov 1999 04:23:17 +0000 Subject: 1999-11-20 Roland McGrath * dlabel.c (fd_get_device): Check STORE->class->id, not STORE->class. --- ufs-utils/dlabel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c index a51fc8ec..1bb30bbc 100644 --- a/ufs-utils/dlabel.c +++ b/ufs-utils/dlabel.c @@ -1,8 +1,8 @@ /* Get the disklabel from a device node - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1999 Free Software Foundation, Inc. - Written by Miles Bader + Written by Miles Bader This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -46,7 +46,7 @@ fd_get_device (int fd, device_t *device) err = store_create (node, 0, 0, &store); if (! err) { - if (store->class != STORAGE_DEVICE + if (store->class->id != STORAGE_DEVICE /* In addition to requiring a device, we also want the *whole* device -- one contiguous run starting at 0. */ || store->num_runs != 1 -- cgit v1.2.3 From 2c8cd1f299e619fdf19ce5886644f3e80bdd27d5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 21 Nov 1999 04:23:31 +0000 Subject: . --- ufs-utils/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 9e402e66..2463384a 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,7 @@ +1999-11-20 Roland McGrath + + * dlabel.c (fd_get_device): Check STORE->class->id, not STORE->class. + 1998-09-04 Roland McGrath * mkfs.c (main): Fix return type to int, use return. -- cgit v1.2.3 From 063e8f381ef476dd21c70a1308781d895783691d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 14 Dec 1999 18:52:13 +0000 Subject: mkbootfs: Removed directory and all files. They have long been obsolete. --- mkbootfs/ChangeLog | 22 ------- mkbootfs/Makefile | 32 --------- mkbootfs/mkbootfs.c | 184 ---------------------------------------------------- 3 files changed, 238 deletions(-) delete mode 100644 mkbootfs/ChangeLog delete mode 100644 mkbootfs/Makefile delete mode 100644 mkbootfs/mkbootfs.c diff --git a/mkbootfs/ChangeLog b/mkbootfs/ChangeLog deleted file mode 100644 index 787943a2..00000000 --- a/mkbootfs/ChangeLog +++ /dev/null @@ -1,22 +0,0 @@ -Fri Jul 22 10:38:17 1994 Michael I Bushnell - - * Makefile: Rewritten in accord with new scheme. - -Wed Jul 20 16:24:08 1994 Michael I Bushnell - - * Makefile (mkbootfs): Put -n after hostname for compat with - old broken rsh. - Use gcc literally instead of MIGHOSTCC. - -Tue Jul 5 14:22:00 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) - - * Makefile (SRCS): New variable. - -Fri May 6 13:25:47 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) - - * Makefile (mkbootfs): Use MIGHOSTCC instead of CC. - -Thu May 5 19:06:21 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) - - * Makefile (mkbootfs): Call rsh with -n flag. - diff --git a/mkbootfs/Makefile b/mkbootfs/Makefile deleted file mode 100644 index df5af560..00000000 --- a/mkbootfs/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 1993, 1994 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 -# published by the Free Software Foundation; either version 2, 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. - -dir := mkbootfs -makemode := misc - -SRCS = mkbootfs.c - -include ../Makeconf - -all: mkbootfs - -mkbootfs: mkbootfs.c - rsh $(mighost) -n cd `pwd` \; gcc mkbootfs.c -o mkbootfs - -clean: - rm -f mkbootfs *.o - diff --git a/mkbootfs/mkbootfs.c b/mkbootfs/mkbootfs.c deleted file mode 100644 index e3ad7137..00000000 --- a/mkbootfs/mkbootfs.c +++ /dev/null @@ -1,184 +0,0 @@ -/* Make a bootstrap filesystem from a filesystem and an exec server - Copyright (C) 1993, 1994 Free Software Foundation - -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. */ - -/* Written by Michael I. Bushnell. */ - -/* The job is to write a .o corresponding to the exec server. This - .o contains the following symbols: - - _execserver_text_size - _execserver_data_size - _execserver_bss_size - _execserver_text - _execserver_data - _execserver_start - - The .o will then be linked along with the rest of the filesystem, which - will spawn an execserver with the right bits when it starts. - - The text should be loaded at 0x10000 and the data at - 0x10000 + _execserver_text_size and the bss cleared at - 0x10000 + _execserver_text_size + _execserver_data_size. - */ - -/* This is non-general, and only intended for the i386 Mach 3.0 with - its own weird format. It expects the header files to be from such a - Mach system as CMU sets them up. */ - -#include -#include -#include - -/* Usage: mkbootfs execserver newdoto */ - -main (int argc, char **argv) -{ - int execserver, newdoto; - struct exec a, newa; - unsigned long foo; - void *buf; - struct nlist n; - - signal (0, 0); - - if (argc != 3) - { - fprintf (stderr, "Usage: %s execserver newdoto\n", argv[0]); - exit (1); - } - - execserver = open (argv[1], O_RDONLY); - if (execserver == -1) - { - perror (argv[1]); - exit (1); - } - - newdoto = open (argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (newdoto == -1) - { - perror (argv[2]); - exit (1); - } - - read (execserver, &a, sizeof (struct exec)); - - /* Write the new data segment to the new file. */ - lseek (newdoto, sizeof (struct exec), L_SET); - - /* First, _execserver_text_size */ - foo = a.a_text + sizeof (struct exec); - write (newdoto, &foo, sizeof foo); - - /* Next, _execserver_data_size */ - write (newdoto, &a.a_data, sizeof a.a_data); - - /* Next, _execserver_bss_size */ - write (newdoto, &a.a_bss, sizeof a.a_bss); - - /* Next, _execserver_text */ - buf = malloc (a.a_text + sizeof (struct exec)); - lseek (execserver, 0, L_SET); - read (execserver, buf, a.a_text + sizeof (struct exec)); - write (newdoto, buf, a.a_text + sizeof (struct exec)); - free (buf); - - /* Next, _execserver_data */ - buf = malloc (a.a_data); - read (execserver, buf, a.a_data); - write (newdoto, buf, a.a_data); - free (buf); - - /* Finally, _execserver_start */ - write (newdoto, &a.a_entry, sizeof a.a_entry); - - /* We have no relocation information */ - - /* Now, write the symbol table */ - n.n_un.n_strx = 50; - n.n_type = N_DATA | N_EXT; - n.n_value = 0; - - /* First, _execserver_text_size */ - write (newdoto, &n, sizeof (n)); - n.n_value += sizeof (foo); - - /* Now, _execserver_data_size */ - n.n_un.n_strx += 50; - write (newdoto, &n, sizeof (n)); - n.n_value += sizeof (foo); - - /* Now, _execserver_bss_size */ - n.n_un.n_strx += 50; - write (newdoto, &n, sizeof (n)); - n.n_value += sizeof (foo); - - /* Now, _execserver_text */ - n.n_un.n_strx += 50; - write (newdoto, &n, sizeof (n)); - n.n_value += a.a_text + sizeof (struct exec); - - /* Now, _execserver_data */ - n.n_un.n_strx += 50; - write (newdoto, &n, sizeof (n)); - n.n_value += a.a_data; - - /* Now, _execserver_start */ - n.n_un.n_strx += 50; - write (newdoto, &n, sizeof (n)); - n.n_value += sizeof (foo); - - /* Now, we have to write out the string table */ -#define DOSTRING(x) \ - write (newdoto, x, strlen (x) + 1); \ - lseek (newdoto, 50 - strlen (x) - 1, L_INCR); - - foo = 350; /* six strings and the beginning */ - write (newdoto, &foo, sizeof foo); - lseek (newdoto, 50 - sizeof foo, L_INCR); - - DOSTRING ("_execserver_text_size"); - DOSTRING ("_execserver_data_size"); - DOSTRING ("_execserver_bss_size"); - DOSTRING ("_execserver_text"); - DOSTRING ("_execserver_data"); - DOSTRING ("_execserver_start"); - - lseek (newdoto, -1, L_INCR); - foo = 0; - write (newdoto, &foo, 1); - - /* Now write out the header */ - a.a_magic = OMAGIC; - a.a_data = - (4 * sizeof (int) + a.a_text + a.a_data + sizeof (struct exec)); - a.a_text = 0; - a.a_bss = 0; - a.a_syms = 6 * sizeof n; - a.a_entry = 0; - a.a_trsize = 0; - a.a_drsize = 0; - lseek (newdoto, 0, L_SET); - write (newdoto, &a, sizeof a); - - exit (0); -} - - - -- cgit v1.2.3 From 93a3b81b195bbc7c7af09c6ad6d4fc98a3c75f30 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 3 Jan 2000 20:27:13 +0000 Subject: 2000-01-03 Roland McGrath * file_io.h: Include "../ext2fs/ext2_fs.h" instead of "ext2_fs.h". * ext2_file_io.c (search_directory): Use `struct ext2_dir_entry_2' in place of `struct ext2_dir_entry', so as to grok newer dir formats. * ext2_fs.h: File removed. * Makefile (LCLHDRS): Remove it from the list. * ffs_compat.c (EXT2_INODES_PER_BLOCK): New macro, no longer in ext2_fs.h. --- serverboot/ChangeLog | 10 + serverboot/Makefile | 6 +- serverboot/ext2_file_io.c | 4 +- serverboot/ext2_fs.h | 451 ---------------------------------------------- serverboot/ffs_compat.c | 2 + serverboot/file_io.h | 11 +- 6 files changed, 27 insertions(+), 457 deletions(-) delete mode 100644 serverboot/ext2_fs.h diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index a200a14e..b9ef7604 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,13 @@ +2000-01-03 Roland McGrath + + * file_io.h: Include "../ext2fs/ext2_fs.h" instead of "ext2_fs.h". + * ext2_file_io.c (search_directory): Use `struct ext2_dir_entry_2' in + place of `struct ext2_dir_entry', so as to grok newer dir formats. + * ext2_fs.h: File removed. + * Makefile (LCLHDRS): Remove it from the list. + * ffs_compat.c (EXT2_INODES_PER_BLOCK): New macro, no longer in + ext2_fs.h. + 1999-11-18 Roland McGrath * default_pager.c (default_pager): Instead of suspending this thread, diff --git a/serverboot/Makefile b/serverboot/Makefile index d2ab975d..b274717e 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1997 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999 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 @@ -22,7 +22,7 @@ SRCS = bootstrap.c ffs_compat.c load.c wiring.c def_pager_setup.c \ ffs_file_io.c minix_ffs_compat.c default_pager.c file_io.c\ minix_file_io.c ext2_file_io.c kalloc.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 ext2_fs.h \ +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 target = serverboot @@ -49,4 +49,4 @@ LDFLAGS += -static include ../Makeconf # Don't even bother. -CFLAGS := $(filter-out -Wall,$(CFLAGS)) \ No newline at end of file +CFLAGS := $(filter-out -Wall,$(CFLAGS)) diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c index d96ad576..28ee2cb3 100644 --- a/serverboot/ext2_file_io.c +++ b/serverboot/ext2_file_io.c @@ -374,7 +374,7 @@ search_directory(name, fp, inumber_p) vm_offset_t buf; vm_size_t buf_size; vm_offset_t offset; - register struct ext2_dir_entry *dp; + struct ext2_dir_entry_2 *dp; int length; kern_return_t rc; char tmp_name[256]; @@ -387,7 +387,7 @@ search_directory(name, fp, inumber_p) if (rc != KERN_SUCCESS) return (rc); - dp = (struct ext2_dir_entry *)buf; + 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'; diff --git a/serverboot/ext2_fs.h b/serverboot/ext2_fs.h deleted file mode 100644 index 4068c002..00000000 --- a/serverboot/ext2_fs.h +++ /dev/null @@ -1,451 +0,0 @@ -/* - * linux/include/linux/ext2_fs.h - * - * Copyright (C) 1992, 1993, 1994 Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/include/linux/minix_fs.h - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -#ifndef _LINUX_EXT2_FS_H -#define _LINUX_EXT2_FS_H - -/* - * The second extended filesystem constants/structures - */ - -/* - * Define EXT2FS_DEBUG to produce debug messages - */ -#undef EXT2FS_DEBUG - -/* - * Define EXT2FS_DEBUG_CACHE to produce cache debug messages - */ -#undef EXT2FS_DEBUG_CACHE - -/* - * Define EXT2FS_CHECK_CACHE to add some checks to the name cache code - */ -#undef EXT2FS_CHECK_CACHE - -/* - * Define EXT2FS_PRE_02B_COMPAT to convert ext 2 fs prior to 0.2b - */ -#undef EXT2FS_PRE_02B_COMPAT - -/* - * Define DONT_USE_DCACHE to inhibit the directory cache - */ -#define DONT_USE_DCACHE - -/* - * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files - */ -#define EXT2_PREALLOCATE - -/* - * The second extended file system version - */ -#define EXT2FS_DATE "94/03/10" -#define EXT2FS_VERSION "0.5" - -/* - * Debug code - */ -#ifdef EXT2FS_DEBUG -# define ext2_debug(f, a...) { \ - printk ("EXT2-fs DEBUG (%s, %d): %s:", \ - __FILE__, __LINE__, __FUNCTION__); \ - printk (f, ## a); \ - } -#else -# define ext2_debug(f, a...) /**/ -#endif - -/* - * Special inodes numbers - */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_ACL_IDX_INO 3 /* ACL inode */ -#define EXT2_ACL_DATA_INO 4 /* ACL inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ -#define EXT2_FIRST_INO 11 /* First non reserved inode */ - -/* - * The second extended file system magic number - */ -#define EXT2_PRE_02B_MAGIC 0xEF51 -#define EXT2_SUPER_MAGIC 0xEF53 - -/* - * Maximal count of links to a file - */ -#define EXT2_LINK_MAX 32000 - -/* - * Macro-instructions used to manage several block sizes - */ -#define EXT2_MIN_BLOCK_SIZE 1024 -#define EXT2_MAX_BLOCK_SIZE 4096 -#define EXT2_MIN_BLOCK_LOG_SIZE 10 -#ifdef __KERNEL__ -# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) -#else -# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#endif -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long)) -#ifdef __KERNEL__ -# define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10) -#else -# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#endif -#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode)) - -/* - * Macro-instructions used to manage fragments - */ -#define EXT2_MIN_FRAG_SIZE 1024 -#define EXT2_MAX_FRAG_SIZE 4096 -#define EXT2_MIN_FRAG_LOG_SIZE 10 -#ifdef __KERNEL__ -# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) -#else -# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) -#endif - -/* - * ACL structures - */ -struct ext2_acl_header /* Header of Access Control Lists */ -{ - unsigned long aclh_size; - unsigned long aclh_file_count; - unsigned long aclh_acle_count; - unsigned long aclh_first_acle; -}; - -struct ext2_acl_entry /* Access Control List Entry */ -{ - unsigned long acle_size; - unsigned short acle_perms; /* Access permissions */ - unsigned short acle_type; /* Type of entry */ - unsigned short acle_tag; /* User or group identity */ - unsigned short acle_pad1; - unsigned long acle_next; /* Pointer on next entry for the */ - /* same inode or on next free entry */ -}; - -/* - * Structure of a blocks group descriptor - */ -struct ext2_old_group_desc -{ - unsigned long bg_block_bitmap; /* Blocks bitmap block */ - unsigned long bg_inode_bitmap; /* Inodes bitmap block */ - unsigned long bg_inode_table; /* Inodes table block */ - unsigned short bg_free_blocks_count; /* Free blocks count */ - unsigned short bg_free_inodes_count; /* Free inodes count */ -}; - -struct ext2_group_desc -{ - unsigned long bg_block_bitmap; /* Blocks bitmap block */ - unsigned long bg_inode_bitmap; /* Inodes bitmap block */ - unsigned long bg_inode_table; /* Inodes table block */ - unsigned short bg_free_blocks_count; /* Free blocks count */ - unsigned short bg_free_inodes_count; /* Free inodes count */ - unsigned short bg_used_dirs_count; /* Directories count */ - unsigned short bg_pad; - unsigned long bg_reserved[3]; -}; - -/* - * Macro-instructions used to manage group descriptors - */ -#ifdef __KERNEL__ -# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) -# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) -# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) -#else -# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) -# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) -# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) -#endif - -/* - * Constants relative to the data blocks - */ -#define EXT2_NDIR_BLOCKS 12 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) - -/* - * Inode flags - */ -#define EXT2_SECRM_FL 0x0001 /* Secure deletion */ -#define EXT2_UNRM_FL 0x0002 /* Undelete */ -#define EXT2_COMPR_FL 0x0004 /* Compress file */ -#define EXT2_SYNC_FL 0x0008 /* Synchronous updates */ - -/* - * ioctl commands - */ -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) -#define EXT2_IOC_GETVERSION _IOR('v', 1, long) -#define EXT2_IOC_SETVERSION _IOW('v', 2, long) - -/* - * Structure of an inode on the disk - */ -struct ext2_inode { - unsigned short i_mode; /* File mode */ - unsigned short i_uid; /* Owner Uid */ - unsigned long i_size; /* Size in bytes */ - unsigned long i_atime; /* Access time */ - unsigned long i_ctime; /* Creation time */ - unsigned long i_mtime; /* Modification time */ - unsigned long i_dtime; /* Deletion Time */ - unsigned short i_gid; /* Group Id */ - unsigned short i_links_count; /* Links count */ - unsigned long i_blocks; /* Blocks count */ - unsigned long i_flags; /* File flags */ - unsigned long i_reserved1; - unsigned long i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - unsigned long i_version; /* File version (for NFS) */ - unsigned long i_file_acl; /* File ACL */ - unsigned long i_dir_acl; /* Directory ACL */ - unsigned long i_faddr; /* Fragment address */ - unsigned char i_frag; /* Fragment number */ - unsigned char i_fsize; /* Fragment size */ - unsigned short i_pad1; - unsigned long i_reserved2[2]; -}; - -/* - * File system states - */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleany */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ - -/* - * Mount flags - */ -#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */ -#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */ -#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \ - EXT2_MOUNT_CHECK_STRICT) -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ - -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ - EXT2_MOUNT_##opt) -/* - * Maximal mount counts between two filesystem checks - */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ - -/* - * Behaviour when detecting errors - */ -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ -#define EXT2_ERRORS_PANIC 3 /* Panic */ -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE - -/* - * Structure of the super block - */ -struct ext2_super_block { - unsigned long s_inodes_count; /* Inodes count */ - unsigned long s_blocks_count; /* Blocks count */ - unsigned long s_r_blocks_count;/* Reserved blocks count */ - unsigned long s_free_blocks_count;/* Free blocks count */ - unsigned long s_free_inodes_count;/* Free inodes count */ - unsigned long s_first_data_block;/* First Data Block */ - unsigned long s_log_block_size;/* Block size */ - long s_log_frag_size; /* Fragment size */ - unsigned long s_blocks_per_group;/* # Blocks per group */ - unsigned long s_frags_per_group;/* # Fragments per group */ - unsigned long s_inodes_per_group;/* # Inodes per group */ - unsigned long s_mtime; /* Mount time */ - unsigned long s_wtime; /* Write time */ - unsigned short s_mnt_count; /* Mount count */ - short s_max_mnt_count; /* Maximal mount count */ - unsigned short s_magic; /* Magic signature */ - unsigned short s_state; /* File system state */ - unsigned short s_errors; /* Behaviour when detecting errors */ - unsigned short s_pad; - unsigned long s_lastcheck; /* time of last check */ - unsigned long s_checkinterval; /* max. time between checks */ - unsigned long s_reserved[238]; /* Padding to the end of the block */ -}; - -/* - * Structure of a directory entry - */ -#define EXT2_NAME_LEN 255 - -struct ext2_dir_entry { - unsigned long inode; /* Inode number */ - unsigned short rec_len; /* Directory entry length */ - unsigned short name_len; /* Name length */ - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * EXT2_DIR_PAD defines the directory entries boundaries - * - * NOTE: It must be a multiple of 4 - */ -#define EXT2_DIR_PAD 4 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ - ~EXT2_DIR_ROUND) - -#ifdef __KERNEL__ -/* - * Function prototypes - */ - -/* - * Ok, these declarations are also in but none of the - * ext2 source programs needs to include it so they are duplicated here. - */ -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define NORET_TYPE __volatile__ -# define ATTRIB_NORET /**/ -# define NORET_AND /**/ -#else -# define NORET_TYPE /**/ -# define ATTRIB_NORET __attribute__((noreturn)) -# define NORET_AND noreturn, -#endif - -/* acl.c */ -extern int ext2_permission (struct inode *, int); - -/* balloc.c */ -extern int ext2_new_block (struct super_block *, unsigned long, - unsigned long *, unsigned long *); -extern void ext2_free_blocks (struct super_block *, unsigned long, - unsigned long); -extern unsigned long ext2_count_free_blocks (struct super_block *); -extern void ext2_check_blocks_bitmap (struct super_block *); - -/* bitmap.c */ -extern unsigned long ext2_count_free (struct buffer_head *, unsigned); - -#ifndef DONT_USE_DCACHE -/* dcache.c */ -extern void ext2_dcache_invalidate (unsigned short); -extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long, - const char *, int); -extern void ext2_dcache_add (unsigned short, unsigned long, const char *, - int, unsigned long); -extern void ext2_dcache_remove (unsigned short, unsigned long, const char *, - int); -#endif - -/* dir.c */ -extern int ext2_check_dir_entry (char *, struct inode *, - struct ext2_dir_entry *, struct buffer_head *, - unsigned long); - -/* file.c */ -extern int ext2_read (struct inode *, struct file *, char *, int); -extern int ext2_write (struct inode *, struct file *, char *, int); - -/* fsync.c */ -extern int ext2_sync_file (struct inode *, struct file *); - -/* ialloc.c */ -extern struct inode * ext2_new_inode (const struct inode *, int); -extern void ext2_free_inode (struct inode *); -extern unsigned long ext2_count_free_inodes (struct super_block *); -extern void ext2_check_inodes_bitmap (struct super_block *); - -/* inode.c */ -extern int ext2_bmap (struct inode *, int); - -extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *); -extern struct buffer_head * ext2_bread (struct inode *, int, int, int *); - -extern int ext2_getcluster (struct inode * inode, long block); -extern void ext2_read_inode (struct inode *); -extern void ext2_write_inode (struct inode *); -extern void ext2_put_inode (struct inode *); -extern int ext2_sync_inode (struct inode *); -extern void ext2_discard_prealloc (struct inode *); - -/* ioctl.c */ -extern int ext2_ioctl (struct inode *, struct file *, unsigned int, - unsigned long); - -/* namei.c */ -extern int ext2_open (struct inode *, struct file *); -extern void ext2_release (struct inode *, struct file *); -extern int ext2_lookup (struct inode *,const char *, int, struct inode **); -extern int ext2_create (struct inode *,const char *, int, int, - struct inode **); -extern int ext2_mkdir (struct inode *, const char *, int, int); -extern int ext2_rmdir (struct inode *, const char *, int); -extern int ext2_unlink (struct inode *, const char *, int); -extern int ext2_symlink (struct inode *, const char *, int, const char *); -extern int ext2_link (struct inode *, struct inode *, const char *, int); -extern int ext2_mknod (struct inode *, const char *, int, int, int); -extern int ext2_rename (struct inode *, const char *, int, - struct inode *, const char *, int); - -/* super.c */ -extern void ext2_error (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern NORET_TYPE void ext2_panic (struct super_block *, const char *, - const char *, ...) - __attribute__ ((NORET_AND format (printf, 3, 4))); -extern void ext2_warning (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern void ext2_put_super (struct super_block *); -extern void ext2_write_super (struct super_block *); -extern int ext2_remount (struct super_block *, int *, char *); -extern struct super_block * ext2_read_super (struct super_block *,void *,int); -extern void ext2_statfs (struct super_block *, struct statfs *); - -/* truncate.c */ -extern void ext2_truncate (struct inode *); - -/* - * Inodes and files operations - */ - -/* dir.c */ -extern struct inode_operations ext2_dir_inode_operations; - -/* file.c */ -extern struct inode_operations ext2_file_inode_operations; - -/* symlink.c */ -extern struct inode_operations ext2_symlink_inode_operations; - -#endif /* __KERNEL__ */ - -#endif /* _LINUX_EXT2_FS_H */ diff --git a/serverboot/ffs_compat.c b/serverboot/ffs_compat.c index 46644a9b..6e322b63 100644 --- a/serverboot/ffs_compat.c +++ b/serverboot/ffs_compat.c @@ -25,6 +25,8 @@ #include +#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; diff --git a/serverboot/file_io.h b/serverboot/file_io.h index 8a1a6e34..323e4e9a 100644 --- a/serverboot/file_io.h +++ b/serverboot/file_io.h @@ -34,11 +34,20 @@ #include #include +#include #include +/* 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 #include "minix_fs.h" -#include "ext2_fs.h" +#include "../ext2fs/ext2_fs.h" /* snarf stolen linux header from ext2fs */ #include "disk_inode.h" #define BSD_FFS 0 -- cgit v1.2.3 From 81c66c37efd2b6fff37110a20e7b773527c14fe6 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 30 Jan 2000 13:07:27 +0000 Subject: Debian changelogs for 19991209 and 19991022. --- debian/changelog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5585f88e..0bd9e4bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +hurd (19991209) unstable; urgency=low + + * New snapshot from CVS. + + -- Marcus Brinkmann Thu, 9 Dec 1999 23:43:23 +0100 + +hurd (19991022) unstable; urgency=low + + * New snapshot from CVS. + * libdiskfs/init-startup.c: Disable periodic syncing before shutting down. + This fixes the fs-unclean-on-reboot bug! + + -- Marcus Brinkmann Fri, 22 Oct 1999 21:32:02 +0200 + hurd (19991004) unstable; urgency=high * New snapshot from CVS. -- cgit v1.2.3 From 55970a17523862529e5490551b01cd24bd8399ab Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 30 Jan 2000 13:09:28 +0000 Subject: 2000-01-30 Marcus Brinkmann * changelog: Update to reflect Debian uploads. --- debian/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 45cacc3a..05e175d9 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2000-01-30 Marcus Brinkmann + + * changelog: Update to reflect Debian uploads. + 1999-10-09 Marcus Brinkmann * rules (BUILDARCH): Renamed to DEB_BUILD_GNU_TYPE. -- cgit v1.2.3 -- cgit v1.2.3 From 4ab9fb88b5ba408e9282a345ddbbdba80a1c47fd Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 3 Mar 2000 21:48:33 +0000 Subject: 2000-03-03 Roland McGrath * dir.c (diskfs_get_directs): Don't allocate buffer for *DATA until after scanning for ENTRY and possibly returning EOF. --- ufs/dir.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 304c8a44..8077234c 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation + Copyright (C) 1994,95,96,97,98,99,2000 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 @@ -856,15 +856,6 @@ diskfs_get_directs (struct node *dp, dp->dn->dirents[i] = -1; } - /* Allocate enough space to hold the maximum we might return */ - if (!bufsiz || bufsiz > dp->dn_stat.st_size) - allocsize = round_page (dp->dn_stat.st_size); - else - allocsize = round_page (bufsiz); - - if (allocsize > *datacnt) - *data = mmap (0, allocsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); - /* Scan through the entries to find ENTRY. If we encounter a -1 in the process then stop to fill it. When we run off the end, ENTRY is too big. */ @@ -891,11 +882,23 @@ diskfs_get_directs (struct node *dp, if (blkno == nblks) { + /* We reached the end of the directory without seeing ENTRY. + This is treated as an EOF condition, meaning we return + success with empty results. */ *datacnt = 0; *amt = 0; return 0; } + /* Allocate enough space to hold the maximum we might return */ + if (!bufsiz || bufsiz > dp->dn_stat.st_size) + allocsize = round_page (dp->dn_stat.st_size); + else + allocsize = round_page (bufsiz); + + if (allocsize > *datacnt) + *data = mmap (0, allocsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + /* Set bufp appropriately */ bufp = buf; if (curentry != entry) -- cgit v1.2.3 From 5101d9d4d17c8be708d1934b78436f742d4f678f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 3 Mar 2000 21:48:41 +0000 Subject: . --- ufs/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 02120e59..34f98d28 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +2000-03-03 Roland McGrath + + * dir.c (diskfs_get_directs): Don't allocate buffer for *DATA until + after scanning for ENTRY and possibly returning EOF. + 1999-10-13 Roland McGrath * consts.c (diskfs_name_max): New variable. -- cgit v1.2.3 From 1c5ac2829d68a029ca9b52d63922e51bd3d3db7f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 27 Mar 2000 18:20:47 +0000 Subject: 2000-03-27 Roland McGrath * configure.in (VERSIONING): New check for ld --version-script. * config.make.in (VERSIONING): New variable, set by configure. --- configure.in | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 9d65bb88..ed80813a 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.17 1999/09/19 18:53:26 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.18 2000/03/27 18:20:47 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -68,6 +68,35 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) AC_SUBST(LIBCRYPT) +# See if --version-script is available. +AC_CACHE_CHECK(for ld --version-script, hurd_cv_ld_version_script_option, [dnl +cat > conftest.c <<\EOF +void foobar() {} +EOF +cat > conftest.map <<\EOF +VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +EOF + +if AC_TRY_COMMAND([eval $ac_compile 1>&AC_FD_CC]) && + AC_TRY_COMMAND([${CC-cc} $CFLAGS -shared -o conftest.so conftest.o + -nostartfiles -nostdlib + -Wl,--version-script,conftest.map + 1>&AC_FD_CC]); then + hurd_cv_ld_version_script_option=yes +else + hurd_cv_ld_version_script_option=no +fi +rm -f conftest*]) +VERSIONING=$hurd_cv_ld_version_script_option +AC_SUBST(VERSIONING) + + if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. makefiles= -- cgit v1.2.3 From 72f6177ab99f72566b7583f55bad24def9047c86 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 3 Apr 2000 18:44:48 +0000 Subject: 2000-04-03 Roland McGrath * panic.c: Include instead of . (panic): Use stdarg style. --- serverboot/panic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/serverboot/panic.c b/serverboot/panic.c index 87428429..4cc657f4 100644 --- a/serverboot/panic.c +++ b/serverboot/panic.c @@ -25,7 +25,7 @@ */ #include -#include +#include #include #include @@ -38,15 +38,13 @@ panic_init(port) } /*VARARGS1*/ -panic(s, va_alist) - char *s; - va_dcl +panic (const char *s, ...) { va_list listp; clearerr (stdout); printf("%s: panic: ", program_invocation_name); - va_start(listp); + va_start(listp, s); vprintf(s, listp); va_end(listp); printf("\n"); -- cgit v1.2.3 From 1dd1025c58e0efc004805739bed79e32f4de2970 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 3 Apr 2000 18:44:54 +0000 Subject: . --- serverboot/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index b9ef7604..d95bc2a5 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +2000-04-03 Roland McGrath + + * panic.c: Include instead of . + (panic): Use stdarg style. + 2000-01-03 Roland McGrath * file_io.h: Include "../ext2fs/ext2_fs.h" instead of "ext2_fs.h". -- cgit v1.2.3 From 8fe6686e892bf89f8b8177b30eaad08affa03bca Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Thu, 25 May 2000 20:23:28 +0000 Subject: * configure.in: Add check for libio. Only enable versioning if we found libio. --- configure.in | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index ed80813a..c0c8de61 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.18 2000/03/27 18:20:47 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.19 2000/05/25 20:23:28 kettenis Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -93,7 +93,27 @@ else hurd_cv_ld_version_script_option=no fi rm -f conftest*]) -VERSIONING=$hurd_cv_ld_version_script_option + +# See if libc was built with --enable-libio. +AC_CACHE_CHECK([for libio], + hurd_cv_libio, + AC_TRY_COMPILE([#include +#ifndef _STDIO_USES_IOSTREAM +# error No libio found. +#endif],, + hurd_cv_libio=yes, + hurd_cv_libio=no)) + +# The versions of the symbols in libthreads have to match those in +# libc.so. Since the symbols in a libc that includes libio will be +# versioned differently from the ones in a libc that uses stdio, this +# isn't easy to accomplish. Instead we leave things unversioned if +# libio isn't found. +if test $hurd_cv_libio = yes; then + VERSIONING=$hurd_cv_ld_version_script_option +else + VERSIONING=no +fi AC_SUBST(VERSIONING) -- cgit v1.2.3 From 348b465f1f6aafbc02b9e8a3850ce119676110b2 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 4 Jul 2000 19:53:13 +0000 Subject: 2000-07-04 Marcus Brinkmann * changelog: Update to reflect Debian uploads. * rules: Use install_script to install scripts. Don't check for shared libraries in scripts. 2000-01-30 Marcus Brinkmann * changelog: Update to reflect Debian uploads. --- debian/ChangeLog | 6 ++++++ debian/changelog | 14 ++++++++++++++ debian/rules | 13 +++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 05e175d9..b534e7f5 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,9 @@ +2000-07-04 Marcus Brinkmann + + * changelog: Update to reflect Debian uploads. + * rules: Use install_script to install scripts. + Don't check for shared libraries in scripts. + 2000-01-30 Marcus Brinkmann * changelog: Update to reflect Debian uploads. diff --git a/debian/changelog b/debian/changelog index 0bd9e4bc..df52e2fc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +hurd (20000703) unstable; urgency=low + + * New snapshot from CVS. + * exec/hashexec.c (check_hashbang: Fix off by one error in line 178. + Patch by Kalle Olavi Niemital. + + -- Marcus Brinkmann Mon, 3 Jul 2000 00:44:47 +0200 + +hurd (20000130) unstable; urgency=low + + * New snapshot from CVS. Closes: Bug#54282, Bug#40302, Bug#56076. + + -- Marcus Brinkmann Sun, 30 Jan 2000 14:55:39 +0100 + hurd (19991209) unstable; urgency=low * New snapshot from CVS. diff --git a/debian/rules b/debian/rules index 521e0b1d..7bb66fee 100755 --- a/debian/rules +++ b/debian/rules @@ -39,6 +39,7 @@ STAMPS_TO_CLEAN = stamp-build stamp-config install_file = install -o root -g root -m 644 install_program = install -s -o root -g root -m 755 +install_script = install -o root -g root -m 755 make_directory = install -d -o root -g root -m 755 define checkdir @@ -172,10 +173,14 @@ binary-arch: build $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs - $(install_program) debian/postinst debian/tmp/DEBIAN/postinst - $(install_program) debian/prerm debian/tmp/DEBIAN/prerm - - dpkg-shlibdeps -p$(package) debian/tmp/bin/* debian/tmp/libexec/* debian/tmp/hurd/* debian/tmp/sbin/* + $(install_script) debian/postinst debian/tmp/DEBIAN/postinst + $(install_script) debian/prerm debian/tmp/DEBIAN/prerm + + # Filter out scripts. + dpkg-shlibdeps -p$(package) `for f in debian/tmp/bin/* \ + debian/tmp/libexec/* debian/tmp/hurd/* \ + debian/tmp/sbin/* ; do head -n1 $$f \ + | sed -n -e '/^#!/!a\'$$'\n'$$f ; done` dpkg-gencontrol -p$(package) -Pdebian/tmp chown -R root.root debian/tmp dpkg --build debian/tmp .. -- cgit v1.2.3 From 4153466ba0bb10fa250af108399d5f4367acad3e Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 26 Jul 2000 12:33:12 +0000 Subject: * Makefile (HURDLIBS): Reorder libs such that the threads lib comes before the ports lib. This makes sure the functions in libthreads properly override the stubs in libports with the new dynamic linker semantics in glibc 2.2. --- ufs/ChangeLog | 7 +++++++ ufs/Makefile | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 34f98d28..a83d02b8 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +2000-07-26 Mark Kettenis + + * Makefile (HURDLIBS): Reorder libs such that the threads lib + comes before the ports lib. This makes sure the functions in + libthreads properly override the stubs in libports with the new + dynamic linker semantics in glibc 2.2. + 2000-03-03 Roland McGrath * dir.c (diskfs_get_directs): Don't allocate buffer for *DATA until diff --git a/ufs/Makefile b/ufs/Makefile index c3bdc997..183caa86 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,5 +1,6 @@ - -# Copyright (C) 1994,95,96,99 Free Software Foundation, Inc. +# Makefile for ufs +# +# Copyright (C) 1994,95,96,99,2000 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 @@ -24,6 +25,6 @@ SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \ LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) -HURDLIBS = diskfs iohelp fshelp store pager ports threads ihash shouldbeinlibc +HURDLIBS = diskfs iohelp fshelp store pager threads ports ihash shouldbeinlibc include ../Makeconf -- cgit v1.2.3 From 95efc29646074436a694541e4de678a645af14c5 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 27 Nov 2000 21:46:04 +0000 Subject: 2000-11-27 Marcus Brinkmann * changelog: Update to reflect Debian upgrade. * rc: New file. * rules: Install rc. * control: Add Build-Depends. --- debian/ChangeLog | 7 ++++ debian/changelog | 49 ++++++++++++++++++++++ debian/control | 1 + debian/rc | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/rules | 3 ++ 5 files changed, 182 insertions(+) create mode 100755 debian/rc diff --git a/debian/ChangeLog b/debian/ChangeLog index b534e7f5..a4436579 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,10 @@ +2000-11-27 Marcus Brinkmann + + * changelog: Update to reflect Debian upgrade. + * rc: New file. + * rules: Install rc. + * control: Add Build-Depends. + 2000-07-04 Marcus Brinkmann * changelog: Update to reflect Debian uploads. diff --git a/debian/changelog b/debian/changelog index df52e2fc..06235e20 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,52 @@ +hurd (20001127) unstable; urgency=low + + * New snapshot from CVS, really fixes isofs now. + + -- Marcus Brinkmann Mon, 27 Nov 2000 21:07:03 +0100 + +hurd (20001126) unstable; urgency=low + + * New snapshot from CVS, closes: #68417, #69281, #68626 + * Fix in 20001030 closes: #72319 + * debian/control: Add build dependencies, closes: #75734 + + -- Marcus Brinkmann Sun, 26 Nov 2000 05:53:19 +0100 + +hurd (20001030) unstable; urgency=low + + * New snapshot from CVS. + * Still contains all the goodies, streadev, kbd, mouse. Now opening + kbd, mouse more than once doesn't crash them (thanks Erik Verbruggen + ) + * sutils/MAKEDEV.sh: kmsg is really klog. + + -- Marcus Brinkmann Tue, 30 Oct 2000 18:02:29 +0200 + +hurd (20000921) unstable; urgency=low + + * New snapshot from CVS + * Add streamdev by OKUJI Yoshinori + (source: ftp://alpha.gnu.org/contrib/okuji/hurd/streamdev-19990920.tar.gz) + * Add kbd and mouse by UCHIYAMA Yasushi . + * sutils/MAKEDEV.sh: Add kbd and kmsg. No sense to add mouse, as you need + to configure it (see /hurd/mouse --help). + + -- Marcus Brinkmann Sat, 23 Sep 2000 04:27:58 +0200 + +hurd (20000803) unstable; urgency=low + + * New snapshot from CVS. + * isofs: Patch to fix symlink handling. + + -- Marcus Brinkmann Thu, 3 Aug 2000 21:09:44 +0200 + +hurd (20000726) unstable; urgency=low + + * New snapshot from CVS. + * Fixes the infamous zero hole bug (actually both of them). + + -- Marcus Brinkmann Wed, 26 Jul 2000 02:24:06 +0200 + hurd (20000703) unstable; urgency=low * New snapshot from CVS. diff --git a/debian/control b/debian/control index 9bdfb88e..2f1bff32 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 2.5.0.0 +Build-Depends: mig, texinfo, tetex-bin Package: hurd Priority: required diff --git a/debian/rc b/debian/rc new file mode 100755 index 00000000..416f6d01 --- /dev/null +++ b/debian/rc @@ -0,0 +1,122 @@ +#!/bin/bash +PATH=/bin:/sbin + +swapon -a + +if [ -r /fastboot ] +then + rm -f /fastboot + echo Fast boot ... skipping disk checks +elif [ $1x = autobootx ] +then + echo Automatic boot in progress... + date + + /sbin/fsck --preen --writable + + case $? in + # Successful completion + 0) + ;; + # Filesystem modified (but ok now) + 1 | 2) + ;; + # Fsck couldn't fix it. + 4 | 8) + echo "Automatic boot failed... help!" + exit 1 + ;; + # Signal that really interrupted something + 20 | 130 | 131) + echo "Boot interrupted" + exit 1 + ;; + # Special `let fsck finish' interruption (SIGQUIT) + 12) + echo "Boot interrupted (filesystem checks complete)" + exit 1 + ;; + # Oh dear. + *) + echo "Unknown error during fsck" + exit 1 + ;; + esac +fi + +echo -n cleaning up left over files... +rm -f /etc/nologin +rm -f /var/lock/LCK.* +if test -d /tmp; then + + # Forcibly remove all translators in the directory. + # It is then safe to attempt to remove files and descend directories. + # All parameters must begin with "./". + function remove_translators() { + local f + for f; do + settrans -pagfS "$f" + if [ -L "$f" ] || [ ! -d "$f" ]; then + rm "$f" + else + remove_translators "$f"/* "$f"/.[!.] "$f"/.??* + rmdir "$f" + fi + done + } + + (cd /tmp + shopt -s nullglob + for f in * .[!.] .??*; do + case "$f" in + 'lost+found'|'quotas') ;; + *) remove_translators "./$f" + esac + done) + + unset -f remove_translators # because it relies on nullglob + +fi +if test -d /var/run; then + (cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) +fi +echo done + +# This file must exist for e2fsck to work. XXX +touch /var/run/mtab + +#echo -n restoring pty permissions... +#chmod 666 /dev/tty[pqrs]* +#echo done + +#echo -n updating /etc/motd... +#echo GNU\'s Not Unix Version `uname --release` > /tmp/newmotd +#egrep -v 'GNU|Version' /etc/motd >> /tmp/newmotd +#mv /tmp/newmotd /etc/motd +#echo done + +chmod 664 /etc/motd + +( + trap ":" INT QUIT TSTP + + if [ -d /etc/rc.boot ] + then + for i in /etc/rc.boot/S* + do + [ ! -f $i ] && continue + $i start + done + fi + if [ -d /etc/rc2.d ] + then + for i in /etc/rc2.d/S* + do + [ ! -f $i ] && continue + $i start + done + fi +) + +date + diff --git a/debian/rules b/debian/rules index 7bb66fee..53af91a9 100755 --- a/debian/rules +++ b/debian/rules @@ -171,6 +171,9 @@ binary-arch: build # libexec/runsystem is managed by update-alternatives mv debian/tmp/libexec/runsystem debian/tmp/libexec/runsystem.gnu +# We have our own rc, slightly modified. + cp debian/rc debian/tmp/libexec/rc + $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs $(install_script) debian/postinst debian/tmp/DEBIAN/postinst -- cgit v1.2.3 From 6541698d7d102f16295bb8240d02dd112197b163 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 30 Nov 2000 19:10:04 +0000 Subject: ext2fs, ufs: 2000-11-30 Marcus Brinkmann * dir.c (diskfs_lookup_hard): If name is too long, clear DS before returning ENAMETOOLONG. pfinet: 2000-11-02 Marcus Brinkmann * tunnel.c (trivfs_S_io_get_owner): Add return type to silence compiler warning. --- ufs/ChangeLog | 5 +++++ ufs/dir.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index a83d02b8..82ada32f 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +2000-11-30 Marcus Brinkmann + + * dir.c (diskfs_lookup_hard): If name is too long, clear + DS before returning ENAMETOOLONG. + 2000-07-26 Mark Kettenis * Makefile (HURDLIBS): Reorder libs such that the threads lib diff --git a/ufs/dir.c b/ufs/dir.c index 8077234c..2cc77398 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -126,7 +126,11 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, namelen = strlen (name); if (namelen > MAXNAMLEN) - return ENAMETOOLONG; + { + if (ds) + diskfs_null_dirstat (ds); + return ENAMETOOLONG; + } try_again: if (ds) -- cgit v1.2.3 From 2ce430f6071e45e899ad86891eecc26be805a445 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 3 Dec 2000 06:29:21 +0000 Subject: 2000-12-02 Roland McGrath * inode.c (write_node): Remove assert that dn_set_mtime et al are clear. It is ok if they are set in parallel, because the latter setting will be carried out eventually. --- ufs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 1901788e..099609ab 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation + Copyright (C) 1994,95,96,97,98,2000 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 @@ -320,7 +320,6 @@ write_node (struct node *np) struct dinode *di = dino (np->dn->number); error_t err; - assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime); if (np->dn_stat_dirty) { assert (!diskfs_readonly); -- cgit v1.2.3 From ea5f2a1a2552f01facb832f3324b4f0d32353e9b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 3 Dec 2000 06:30:18 +0000 Subject: . --- ufs/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 82ada32f..6927195b 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +2000-12-02 Roland McGrath + + * inode.c (write_node): Remove assert that dn_set_mtime et al are + clear. It is ok if they are set in parallel, because the latter + setting will be carried out eventually. + 2000-11-30 Marcus Brinkmann * dir.c (diskfs_lookup_hard): If name is too long, clear -- cgit v1.2.3 From 3bc8c9e3eed213b6326c607bfb368f695a4752e7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 7 Jan 2001 19:31:50 +0000 Subject: doc/ 2001-01-07 Marcus Brinkmann * hurd.texi (Diskfs Callbacks): Make diskfs_dirstat_size const. ext2fs/ 2001-01-07 Marcus Brinkmann * dir.c: Make diskfs_dirstat_size const. isofs/ 2001-01-07 Marcus Brinkmann * lookup.c: Make diskfs_dirstat_size const. ufs/ 2001-01-07 Marcus Brinkmann * dir.c: Make diskfs_dirstat_size const. libdiskfs/ 2001-01-07 Marcus Brinkmann * diskfs.h: Make diskfs_dirstat_size const. libdiskfs/ 2001-01-07 Marcus Brinkmann * file-statfs.c: Include . ftpfs/ 2001-01-07 Marcus Brinkmann * dir.c (ftpfs_dir_create): Fix last change (calloc invocation). 2001-01-07 Marcus Brinkmann * copy.c: Include . New macro page_aligned. (copy_write): Cast buf to vm_address_t in call to vm_write. Dereference amount for memcpy. (copy_read): Add len parameter to vm_read, remove redundant following len assignment. --- ufs/ChangeLog | 4 ++++ ufs/dir.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 6927195b..14aed9dd 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +2001-01-07 Marcus Brinkmann + + * dir.c: Make diskfs_dirstat_size const. + 2000-12-02 Roland McGrath * inode.c (write_node): Remove assert that dn_set_mtime et al are diff --git a/ufs/dir.c b/ufs/dir.c index 2cc77398..7880ca21 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -79,7 +79,7 @@ struct dirstat size_t nbytes; }; -size_t diskfs_dirstat_size = sizeof (struct dirstat); +const size_t diskfs_dirstat_size = sizeof (struct dirstat); /* Initialize DS such that diskfs_drop_dirstat will ignore it. */ void -- cgit v1.2.3 From 1c9f0a5afa9c6eb6af95106c382d441eadaa0949 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 8 Jan 2001 22:33:11 +0000 Subject: doc/ 2001-01-08 Marcus Brinkmann * hurd.texi (Store Management): Replace off_t with store_offset_t. (Store I/O): Likewise. (Store Classes): Likewise. ext2fs/ 2001-01-08 Marcus Brinkmann * ext2fs.c (main): Use %Ld instead %ld to print store->size. * hyper.c (get_hypermetadata): Likewise. libstore/ 2001-01-08 Marcus Brinkmann * zero.c (zero_remap): Change type of variables length, old_length to store_offset_t. (zero_decode): Change type of variable size to store_offset_t. (zero_open): Likewise. Use strtoull instead strtoul to parse size argument from name. Use store_offset_t for max_offs and its calculation. (store_zero_create): Use store_offset_t type for size argument. * derive.c (_store_derive): Use store_offset_t as type for variable last_part_base. * stripe.c (addr_adj): Change types of addr argument and return value to store_offset_t. (store_ileave_create): Change type of interleave argument and variables min_end and end to store_offset_t, but type of variable block_size to size_t. (store_concat_create): Change type of variable block_size to size_t. * make.c (_store_create): Change end argument type to store_offset_t. * store.h: New type store_offset_t, define to off64_t. (struct store_run): Change type of start and length to store_offset_t. (struct store): Change type of end, wrap_src, wrap_dst, blocks, size to store_offset_t. Change type of addr arg in store_read_meth_t and store_write_meth_t to store_offset_t, as well as in declarations for store_read and store_write. Change type of argument end in _store_create declaration to store_offset_t. Change type of argument size in store_zero_create to store_offset_t. Change type of argument interleace in store_ileace_create to store_offset_t. * rdwr.c (store_find_first_run): Change type of return value, addr and *base arguments, and variables wrap_src and run_blocks to store_offset_t. (store_next_run): Change type of *base argument to store_offset_t. (store_write): Change type of addr argument and variable base to store_offset_t. (store_read): Likewise, also for addr argument of local function seg_read. Change type of len argument to size_t. * copy.c (copy_read): Change type of addr argument to store_offset_t. (copy_write): Likewise. * device.c (dev_read): Likewise. (dev_write): Likewise. * file.c (file_read): Likewise. (file_write): Likewise. (file_byte_read): Likewise. (file_byte_write): Likewise. * mvol.c (mvol_read): Likewise. (mvol_write): Likewise. * remap.c (remap_read): Likewise. (remap_write): Likewise. * stripe.c (stripe_read): Likewise. (stripe_write): Likewise. * task.c (task_read): Likewise. (task_write): Likewise. * zero.c (zero_read): Likewise. (zero_write): Likewise. * remap.c (store_remap_runs): Change type of addr and len arguments of local function add_run and of local variables addr, length, baddr, blen and len to store_offset_t. (remap_open): Cast -1 to store_offset_t, not off_t. * argp.c (struct store_parsed): Change type of interleave from off_t to store_offset_t. (store_parsed_append_args): Use %Ld instead %ld to print interleave value. (store_parsed_name): Likewise. ufs/ 2001-01-08 Marcus Brinkmann * main.c (main): Use %Ld instead %ld to print store->size. * hyper.c (get_hypermetadata): Likewise. * inode.c (diskfs_S_file_get_storage_info): Change type of variables start and length from off_t to store_offset_t. utils/ 2001-01-08 Marcus Brinkmann * storeread.c (main): Change type of addr to store_offset_t, also for first argument of local function dump. Add comment about store->size as len parameter for store_read. Use atoll instead atoi for addr argument. * storeinfo.c (print_store): Remove local function pint, add two similar functions psiz and poff, accepting and printing a size_t or store_offset_t respectively. Use psiz to print block_size, poff to print blocks and size of store. Use %Ld instead %ld to print runs. * storecat.c (main): Change type of addr and left to store_offset_t. --- ufs/ChangeLog | 7 +++++++ ufs/hyper.c | 2 +- ufs/inode.c | 4 ++-- ufs/main.c | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 14aed9dd..d8e04a0e 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +2001-01-08 Marcus Brinkmann + + * main.c (main): Use %Ld instead %ld to print store->size. + * hyper.c (get_hypermetadata): Likewise. + * inode.c (diskfs_S_file_get_storage_info): Change type of variables + start and length from off_t to store_offset_t. + 2001-01-07 Marcus Brinkmann * dir.c: Make diskfs_dirstat_size const. diff --git a/ufs/hyper.c b/ufs/hyper.c index c907d274..ece327a2 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -251,7 +251,7 @@ get_hypermetadata (void) if (store->size < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size (%ld) less than necessary " + "Disk size (%Ld) less than necessary " "(superblock says we need %ld)\n", store->size, sblock->fs_size * sblock->fs_fsize); exit (1); diff --git a/ufs/inode.c b/ufs/inode.c index 099609ab..72467e1a 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -679,8 +679,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, for (i = 0; i < NDADDR; i++) { - off_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); - off_t length = + store_offset_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); + store_offset_t length = (((i + 1) * sblock->fs_bsize > np->allocsize) ? np->allocsize - i * sblock->fs_bsize : sblock->fs_bsize); diff --git a/ufs/main.c b/ufs/main.c index cc39019d..8c79d707 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -169,7 +169,7 @@ main (int argc, char **argv) error (4, 0, "%s: Bad device block size %d (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); if (store->size < SBSIZE + SBOFF) - error (5, 0, "%s: Disk too small (%ld bytes)", diskfs_disk_name, + error (5, 0, "%s: Disk too small (%Ld bytes)", diskfs_disk_name, store->size); log2_dev_blocks_per_dev_bsize = 0; -- cgit v1.2.3 From 88487d6b67d4714d4bc63ca59a5ec7449b0bc219 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 11 Jan 2001 22:25:19 +0000 Subject: 2001-01-09 Marcus Brinkmann * changelog: Update to reflect Debian upgrade. * rules: Use --disable-profile wih configure instead no_prof=t with make. --- debian/ChangeLog | 7 +++++++ debian/changelog | 14 ++++++++++++++ debian/rules | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index a4436579..8ea6c1e1 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,10 @@ +2001-01-09 Marcus Brinkmann + + * changelog: Update to reflect Debian upgrade. + + * rules: Use --disable-profile wih configure instead no_prof=t + with make. + 2000-11-27 Marcus Brinkmann * changelog: Update to reflect Debian upgrade. diff --git a/debian/changelog b/debian/changelog index 06235e20..e92d5794 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +hurd (20001204) unstable; urgency=low + + * New snapshot from CVS, with a couple of bug fixes: + pfinet: Don't leak references. + ext2fs, ufs: Avoid a dn_set_?time vs sync thread race. + Corretly deny too long filenames. + nfsd: Fix a couple of memory leaks. + + * Additional patchs: + libdiskfs: Don't crash when symlink target is the empty string. + streamdev, kbd, mouse: New translators for X and klog device. + + -- Marcus Brinkmann Mon, 4 Dec 2000 15:18:39 +0100 + hurd (20001127) unstable; urgency=low * New snapshot from CVS, really fixes isofs now. diff --git a/debian/rules b/debian/rules index 53af91a9..a1efd14e 100755 --- a/debian/rules +++ b/debian/rules @@ -62,14 +62,15 @@ config: stamp-config stamp-config: configure $(checkdir) -mkdir build - cd build && ../configure --build=$(DEB_BUILD_GNU_TYPE) \ + cd build && ../configure --disable-profile \ + --build=$(DEB_BUILD_GNU_TYPE) \ --host=$(DEB_HOST_GNU_TYPE) --prefix= touch stamp-config all build: config stamp-build stamp-build: $(checkdir) - cd build && $(MAKE) no_prof=t + cd build && $(MAKE) # XXX-doc cd build && $(MAKE) -C doc hurd.info cd build && $(MAKE) -C doc hurd.ps -- cgit v1.2.3 From d8de5d79215dc437d3159f812d3e93a92c01063b Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 11 Jan 2001 22:32:35 +0000 Subject: The below change is preperation for a new mach-defpager interface by Roland. 2001-01-11 Marcus Brinkmann * def_pager_setup.c: Include and . (default_pager_paging_storage): New stub. --- serverboot/ChangeLog | 6 ++++++ serverboot/def_pager_setup.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index d95bc2a5..eace83e6 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,9 @@ +2001-01-11 Marcus Brinkmann + + * def_pager_setup.c: Include and + . + (default_pager_paging_storage): New stub. + 2000-04-03 Roland McGrath * panic.c: Include instead of . diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c index 8834a379..5e2073ec 100644 --- a/serverboot/def_pager_setup.c +++ b/serverboot/def_pager_setup.c @@ -24,6 +24,8 @@ * the rights to redistribute these changes. */ #include +#include +#include #include @@ -93,6 +95,16 @@ remove_paging_file(file_name) 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 -- cgit v1.2.3 From e15080b2f764ea71562c4e01999e1fb69790bbf4 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 26 Feb 2001 04:16:10 +0000 Subject: 2001-02-25 Roland McGrath * utilities.c: Include for decl. --- ufs-fsck/utilities.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index 2ccade06..f3a2b670 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -1,5 +1,5 @@ /* Miscellaneous functions for fsck - Copyright (C) 1994, 1995, 1996, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1999, 2001 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -25,6 +25,7 @@ #include #include #include +#include static void retch (char *reason); @@ -61,12 +62,12 @@ getinode (ino_t ino, struct dinode *di) if (!lastifrag) lastifrag = malloc (sblock->fs_bsize); - + iblk = ino_to_fsba (sblock, ino); if (iblk != lastifragaddr) readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize); lastifragaddr = iblk; - bcopy (lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode), + bcopy (lastifrag + ino_to_fsbo (sblock, ino) * sizeof (struct dinode), di, sizeof (struct dinode)); } @@ -75,7 +76,7 @@ void write_inode (ino_t ino, struct dinode *di) { daddr_t iblk; - + iblk = ino_to_fsba (sblock, ino); if (iblk != lastifragaddr) readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_bsize); @@ -101,10 +102,10 @@ allocblk (int nfrags) { daddr_t i; int j, k; - + if (nfrags <= 0 || nfrags > sblock->fs_frag) return 0; - + /* Examine each block of the filesystem. */ for (i = 0; i < maxfsblock - sblock->fs_frag; i += sblock->fs_frag) { @@ -115,7 +116,7 @@ allocblk (int nfrags) for (k = 0; k < nfrags; k++) if (testbmap (i + j + k)) break; - + /* If one of the frags was allocated... */ if (k < nfrags) { @@ -123,7 +124,7 @@ allocblk (int nfrags) j += k; continue; } - + /* It's free (at address i + j) */ /* Mark the frags allocated in our map */ @@ -136,16 +137,16 @@ allocblk (int nfrags) return 0; } -/* Check if a block starting at BLK and extending for CNT +/* Check if a block starting at BLK and extending for CNT fragments is out of range; if it is, then return 1; otherwise return 0. */ int check_range (daddr_t blk, int cnt) { int c; - + if ((unsigned)(blk + cnt) > maxfsblock) return 1; - + c = dtog (sblock, blk); if (blk < cgdmin (sblock, c)) { @@ -157,9 +158,9 @@ check_range (daddr_t blk, int cnt) if (blk + cnt > cgbase (sblock, c + 1)) return 1; } - + return 0; -} +} struct problem { char *desc; @@ -236,7 +237,7 @@ flush_problems () { fail (problems)->prev = free_problems; free_problems = problems; - } + } } /* Like printf, but exit after printing. */ @@ -276,7 +277,7 @@ punt (char *msg) /* If SEVERE is true, and we're in preen mode, then things are too hair to fix automatically, so tell the user to do it himself and punt. */ -static void +static void no_preen (int severe) { if (severe && preen) @@ -295,7 +296,7 @@ problem (int severe, char *fmt, ...) va_start (args, fmt); push_problem (fmt, args); va_end (args); - + no_preen (severe); } @@ -371,7 +372,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) pextend (" O=%s", pw->pw_name); else pextend (" O=%lu", dino.di_uid); - + pextend (" M=0%o", DI_MODE (&dino)); pextend (" SZ=%llu", dino.di_size); p = ctime (&dino.di_mtime.tv_sec); @@ -407,7 +408,7 @@ reply (char *question) { int persevere; char c; - + if (preen) retch ("Got to reply() in preen mode"); @@ -449,6 +450,6 @@ reply (char *question) { fix_denied = 1; return 0; - } + } } } -- cgit v1.2.3 From c390c9609331cbb84aa1a677b8c7ee30f0c6d718 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 26 Feb 2001 04:16:18 +0000 Subject: 2001-02-25 Roland McGrath * mkfs.c [!STANDALONE]: Include for decl. * stati.c: Likewise. --- ufs-utils/mkfs.c | 3 ++- ufs-utils/stati.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index e8513b70..1bfce2eb 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.18 1998/10/20 09:46:39 roland Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.19 2001/02/26 04:16:18 roland Exp $"; #endif /* not lint */ #include @@ -90,6 +90,7 @@ static char *rcsid = "$Id: mkfs.c,v 1.18 1998/10/20 09:46:39 roland Exp $"; #ifndef STANDALONE #include #include +#include #endif /* diff --git a/ufs-utils/stati.c b/ufs-utils/stati.c index 2c0147d0..ba545bf2 100644 --- a/ufs-utils/stati.c +++ b/ufs-utils/stati.c @@ -61,6 +61,7 @@ static char sccsid[] __attribute__ ((unused)); #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ mode_rep (unsigned short mode) case S_IFIFO: *p++ = 'f'; break; default: *p++ = '?'; } - + add_perms (0, S_ISUID); add_perms (3, S_ISGID); add_perms (6, 0); -- cgit v1.2.3 From 60423ee8b51b67287e14a0c68c85ed34991d8f72 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 26 Feb 2001 04:18:20 +0000 Subject: . --- ufs-fsck/ChangeLog | 6 +++++- ufs-utils/ChangeLog | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 0fede606..277fd9a7 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,10 +1,14 @@ +2001-02-25 Roland McGrath + + * utilities.c: Include for decl. + Thu May 6 10:25:27 1999 Thomas Bushnell, BSG * utilities.c (pextend): Free MORE before returning. * dir.c (linkup): Don't free tempname until after we're done using it in the call to warning. Reported by Katsuya Tanaka (tanaka@boarderz.com). - + 1999-03-25 Roland McGrath * setup.c (setup): Don't complain if the device is a block device. diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 2463384a..a445b3a6 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +2001-02-25 Roland McGrath + + * mkfs.c [!STANDALONE]: Include for decl. + * stati.c: Likewise. + 1999-11-20 Roland McGrath * dlabel.c (fd_get_device): Check STORE->class->id, not STORE->class. -- cgit v1.2.3 From c4a53b359c763a34b61e6803295cc0ea45ea25c5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 28 Feb 2001 08:32:56 +0000 Subject: 2001-02-28 Roland McGrath * default_pager.c: Use instead of "file_io.h", so mach-defpager gets its own version when it uses this source file. (new_partition): If CHECK_LINUX_SIGNATURE arg is -3, don't print out. --- serverboot/default_pager.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index 198bb224..d5dbcf9b 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -48,7 +48,7 @@ #include #include -#include "file_io.h" +#include #define debug 0 @@ -206,9 +206,10 @@ new_partition (const char *name, struct file_direct *fdp, if (check_linux_signature < 0) { - printf("(default pager): " - "Paging to raw partition %s (%uk paging space)\n", - name, part->total_size * (vm_page_size / 1024)); + if (check_linux_signature != -3) + printf("(default pager): " + "Paging to raw partition %s (%uk paging space)\n", + name, part->total_size * (vm_page_size / 1024)); return part; } -- cgit v1.2.3 From cc887ffd80f9101c2b5c14d10ba84796279b3950 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 28 Feb 2001 08:34:07 +0000 Subject: . --- serverboot/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index eace83e6..539ed6ec 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,9 @@ +2001-02-28 Roland McGrath + + * default_pager.c: Use instead of "file_io.h", + so mach-defpager gets its own version when it uses this source file. + (new_partition): If CHECK_LINUX_SIGNATURE arg is -3, don't print out. + 2001-01-11 Marcus Brinkmann * def_pager_setup.c: Include and -- cgit v1.2.3 From e09a35d0336517a074db32d91b4d2b4188269e0a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 1 Apr 2001 01:41:05 +0000 Subject: 2001-03-31 Roland McGrath * assert.h: Fix obsolescent #endif syntax. * default_pager.c: Likewise. * queue.h: Likewise. * load.c: Likewise. --- serverboot/assert.h | 16 ++++++++-------- serverboot/default_pager.c | 30 +++++++++++++++--------------- serverboot/load.c | 4 ++-- serverboot/queue.h | 10 +++++----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/serverboot/assert.h b/serverboot/assert.h index 9bcab69e..9f70aec3 100644 --- a/serverboot/assert.h +++ b/serverboot/assert.h @@ -1,25 +1,25 @@ -/* +/* * 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. */ @@ -38,9 +38,9 @@ extern void Assert(); #ifdef lint #define assert_static(x) -#else lint +#else /* lint */ #define assert_static(x) assert(x) -#endif lint +#endif /* lint */ #else /* ASSERTIONS */ #define assert(ex) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index d5dbcf9b..a7625447 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -655,7 +655,7 @@ struct dpager { #ifdef CHECKSUM vm_offset_t *checksum; /* checksum - parallel to block map */ #define NO_CHECKSUM ((vm_offset_t)-1) -#endif CHECKSUM +#endif /* CHECKSUM */ }; typedef struct dpager *dpager_t; @@ -752,7 +752,7 @@ pager_alloc(pager, part, size) mapptr[i] = NO_CHECKSUM; } pager->checksum = mapptr; -#endif CHECKSUM +#endif /* CHECKSUM */ } /* @@ -908,7 +908,7 @@ pager_extend(pager, new_size) new_mapptr[i] = 0; kfree((char *)old_mapptr, INDIRECT_PAGEMAP_SIZE(old_size)); pager->checksum = new_mapptr; -#endif CHECKSUM +#endif /* CHECKSUM */ #if DEBUG_READER_CONFLICTS pager->writer = FALSE; #endif @@ -979,7 +979,7 @@ pager_extend(pager, new_size) for (i = 1; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++) new_mapptr[i] = 0; pager->checksum = new_mapptr; -#endif CHECKSUM +#endif /* CHECKSUM */ #if DEBUG_READER_CONFLICTS pager->writer = FALSE; #endif @@ -1008,7 +1008,7 @@ pager_extend(pager, new_size) new_mapptr[i] = NO_CHECKSUM; kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); pager->checksum = new_mapptr; -#endif CHECKSUM +#endif /* CHECKSUM */ #if DEBUG_READER_CONFLICTS pager->writer = FALSE; #endif @@ -1254,7 +1254,7 @@ compute_checksum(addr, size) return (checksum); } -#endif CHECKSUM +#endif /* CHECKSUM */ /* * Given an offset within a paging object, find the @@ -1364,7 +1364,7 @@ pager_write_offset(pager, offset) for (j = 0; j < PAGEMAP_ENTRIES; j++) cksumptr[j] = NO_CHECKSUM; } -#endif CHECKSUM +#endif /* CHECKSUM */ } f_page %= PAGEMAP_ENTRIES; } @@ -1465,7 +1465,7 @@ pager_dealloc(pager) } kfree((char *)pager->checksum, INDIRECT_PAGEMAP_SIZE(pager->size)); -#endif CHECKSUM +#endif /* CHECKSUM */ } else { mapptr = pager->map; @@ -1478,7 +1478,7 @@ pager_dealloc(pager) kfree((char *)pager->map, PAGEMAP_SIZE(pager->size)); #ifdef CHECKSUM kfree((char *)pager->checksum, PAGEMAP_SIZE(pager->size)); -#endif CHECKSUM +#endif /* CHECKSUM */ } } @@ -1573,7 +1573,7 @@ default_read(ds, addr, size, offset, out_addr, deallocate) register partition_t part; #ifdef CHECKSUM vm_size_t original_size = size; -#endif CHECKSUM +#endif /* CHECKSUM */ vm_offset_t original_offset = offset; /* @@ -1638,7 +1638,7 @@ ddprintf ("default_read(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); original_offset, write_checksum, read_checksum); } } -#endif CHECKSUM +#endif /* CHECKSUM */ return (PAGER_SUCCESS); } @@ -1673,7 +1673,7 @@ default_write(ds, addr, size, offset) checksum = compute_checksum(addr, size); pager_put_checksum(ds, offset, checksum); } -#endif CHECKSUM +#endif /* CHECKSUM */ offset = ptoa(block.block.p_offset); ddprintf ("default_write(%x,%x,%x,%d)\n",addr,size,offset,block.block.p_index); part = partition_of(block.block.p_index); @@ -2606,7 +2606,7 @@ seqnos_memory_object_data_initialize(pager, seqno, pager_request, #ifdef lint pager_request++; -#endif lint +#endif /* lint */ ds = pager_port_lookup(pager); if (ds == DEFAULT_PAGER_NULL) @@ -2670,7 +2670,7 @@ seqnos_memory_object_data_write(pager, seqno, pager_request, #ifdef lint pager_request++; -#endif lint +#endif /* lint */ ddprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err); if ((data_cnt % vm_page_size) != 0) @@ -2773,7 +2773,7 @@ seqnos_memory_object_lock_completed(pager, seqno, pager_request, { #ifdef lint pager++; seqno++; pager_request++; offset++; length++; -#endif lint +#endif /* lint */ panic("%slock_completed",my_name); return(KERN_FAILURE); diff --git a/serverboot/load.c b/serverboot/load.c index fc16baf1..1665868b 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -333,7 +333,7 @@ boot_script_exec_cmd (task_t user_task, st.image_size); } } -#endif GZIP +#endif /* GZIP */ #ifdef BZIP2 if (result) { @@ -358,7 +358,7 @@ boot_script_exec_cmd (task_t user_task, st.image_size); } } -#endif BZIP2 +#endif /* BZIP2 */ if (result) panic ("cannot load %s: %s", namebuf, strerror (result)); #if 0 diff --git a/serverboot/queue.h b/serverboot/queue.h index 3e93476f..00619174 100644 --- a/serverboot/queue.h +++ b/serverboot/queue.h @@ -1,18 +1,18 @@ -/* +/* * 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 @@ -313,4 +313,4 @@ typedef struct queue_entry *queue_entry_t; -#endif _QUEUE_H_ +#endif /* _QUEUE_H_ */ -- cgit v1.2.3 From f084b53d1af89134c6873621a24924718e56272e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 1 Apr 2001 01:41:29 +0000 Subject: . --- serverboot/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 539ed6ec..ce756ce0 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +2001-03-31 Roland McGrath + + * assert.h: Fix obsolescent #endif syntax. + * default_pager.c: Likewise. + * queue.h: Likewise. + * load.c: Likewise. + 2001-02-28 Roland McGrath * default_pager.c: Use instead of "file_io.h", -- cgit v1.2.3 From 905a6f66bbdf18d967ab7e6b1de49763791ff87c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 29 Apr 2001 20:37:46 +0000 Subject: 2001-04-29 Marcus Brinkmann * changelog: Update to reflect Debian upgrades. --- debian/ChangeLog | 4 ++++ debian/changelog | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 8ea6c1e1..da6dbe37 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-04-29 Marcus Brinkmann + + * changelog: Update to reflect Debian upgrades. + 2001-01-09 Marcus Brinkmann * changelog: Update to reflect Debian upgrade. diff --git a/debian/changelog b/debian/changelog index e92d5794..b2b56b9b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,34 @@ +hurd (20010426) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + storeio hack to prevent double activation. + + -- Marcus Brinkmann Fri, 27 Apr 2001 00:09:56 +0200 + +hurd (20010311) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Sun, 11 Mar 2001 22:45:21 +0100 + +hurd (20010111) unstable; urgency=low + + * New snapshot from CVS, containing lots of small bug fixes, and: + + Together with gnumach 1.2-9, you can access large stores with + storeinfo, storeread (because libstore uses the new interface in + gnumach, and off64_t internally). + + pfinet contains support for network ioctls. The corresponding + changes in the glibc library are not available in Debian yet, though. + * streamdev is renamed to streamio. + + -- Marcus Brinkmann Fri, 12 Jan 2001 00:06:41 +0100 + hurd (20001204) unstable; urgency=low * New snapshot from CVS, with a couple of bug fixes: -- cgit v1.2.3 From 7c80866b417ce602f6d1c188d18c28e8cf7e3a14 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 9 Jun 2001 20:30:34 +0000 Subject: * inode.c (diskfs_set_statfs): If number of free blocks is less than the number of reserved blocks, set the number of available blocks to 0. --- ufs/ChangeLog | 6 ++++++ ufs/inode.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index d8e04a0e..8f651624 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +2001-06-09 Mark Kettenis + + * inode.c (diskfs_set_statfs): If number of free blocks is less + than the number of reserved blocks, set the number of available + blocks to 0. + 2001-01-08 Marcus Brinkmann * main.c (main): Use %Ld instead %ld to print store->size. diff --git a/ufs/inode.c b/ufs/inode.c index 72467e1a..2647754c 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994,95,96,97,98,2000 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,98,2000,01 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 @@ -519,6 +519,8 @@ diskfs_set_statfs (struct statfs *st) + sblock->fs_cstotal.cs_nffree); st->f_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100) - (sblock->fs_dsize - st->f_bfree)); + if (st->f_bfree < ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100))) + st->f_bavail = 0; st->f_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */ st->f_ffree = sblock->fs_cstotal.cs_nifree; st->f_fsid = getpid (); -- cgit v1.2.3 From f645cbef37e74f0b35aa371808ef6243f791f46d Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 15 Jun 2001 20:14:42 +0000 Subject: 2001-06-15 Marcus Brinkmann * rc: Apply patch from Moritz Schulte to be more selective with what to clean from /var/run. --- debian/ChangeLog | 5 +++++ debian/rc | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index da6dbe37..a20f2e53 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +2001-06-15 Marcus Brinkmann + + * rc: Apply patch from Moritz Schulte to + be more selective with what to clean from /var/run. + 2001-04-29 Marcus Brinkmann * changelog: Update to reflect Debian upgrades. diff --git a/debian/rc b/debian/rc index 416f6d01..f623aeb9 100755 --- a/debian/rc +++ b/debian/rc @@ -77,9 +77,19 @@ if test -d /tmp; then unset -f remove_translators # because it relies on nullglob fi + if test -d /var/run; then - (cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) + (cd /var/run && { + find . ! -type d ! -name utmp ! -name innd.pid ! -name random-seed \ + -exec rm -f -- {} \; + cp /dev/null utmp + if grep -q ^utmp: /etc/group + then + chmod 664 utmp + chgrp utmp utmp + fi; }) fi + echo done # This file must exist for e2fsck to work. XXX -- cgit v1.2.3 From 354323352bae98c36360f2890a787f634b9eded3 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 15 Jun 2001 20:17:49 +0000 Subject: Streamline the CVS entry. --- debian/ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index a20f2e53..024cefbd 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,7 +1,7 @@ 2001-06-15 Marcus Brinkmann - * rc: Apply patch from Moritz Schulte to - be more selective with what to clean from /var/run. + * rc: Be more selective with what to clean from /var/run. + Patch by Moritz Schulte . 2001-04-29 Marcus Brinkmann -- cgit v1.2.3 From 848bbd7679e30e83f0b42cab17e43baee3cf71ae Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 15 Jun 2001 21:30:08 +0000 Subject: 2001-06-15 Marcus Brinkmann * rc: Merge in recent changes from daemons/rc.sh. --- debian/ChangeLog | 4 ++++ debian/rc | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 024cefbd..aac2359a 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-06-15 Marcus Brinkmann + + * rc: Merge in recent changes from daemons/rc.sh. + 2001-06-15 Marcus Brinkmann * rc: Be more selective with what to clean from /var/run. diff --git a/debian/rc b/debian/rc index f623aeb9..45592c9f 100755 --- a/debian/rc +++ b/debian/rc @@ -1,10 +1,16 @@ #!/bin/bash PATH=/bin:/sbin +# Start the default pager. It will bail if there is already one running. +/hurd/mach-defpager + +# Set up swap space. This will complain if no default pager is functioning. swapon -a +# Check filesystems. if [ -r /fastboot ] then + # ... or don't. rm -f /fastboot echo Fast boot ... skipping disk checks elif [ $1x = autobootx ] @@ -38,7 +44,7 @@ then ;; # Oh dear. *) - echo "Unknown error during fsck" + echo "Unknown error during fsck (exit status $?)" exit 1 ;; esac @@ -129,4 +135,3 @@ chmod 664 /etc/motd ) date - -- cgit v1.2.3 From ff7ed9efcfd09ec20f88f46264943bb13471388a Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 17 Jun 2001 13:46:21 +0000 Subject: 2001-06-17 Marcus Brinkmann * changelog: Update to current version. --- debian/ChangeLog | 4 ++++ debian/changelog | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index aac2359a..77b01b92 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-06-17 Marcus Brinkmann + + * changelog: Update to current version. + 2001-06-15 Marcus Brinkmann * rc: Merge in recent changes from daemons/rc.sh. diff --git a/debian/changelog b/debian/changelog index b2b56b9b..1c3a042e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +hurd (20010608) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + Compiled with -O2 rather than -O3. + + -- Marcus Brinkmann Fri, 8 Jun 2001 23:02:47 +0200 + +hurd (20010527) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Sat, 27 May 2001 01:34:21 +0200 + hurd (20010426) unstable; urgency=low * New snapshot from CVS. -- cgit v1.2.3 From f6a03533282b51e447df51fd7563be17ed999c59 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Tue, 26 Jun 2001 13:33:07 +0000 Subject: * configure.in: Add check for getgrouplist. --- configure.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index c0c8de61..61c963d2 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.19 2000/05/25 20:23:28 kettenis Exp $]) +AC_REVISION([$Id: configure.in,v 1.20 2001/06/26 13:33:07 kettenis Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -104,6 +104,9 @@ AC_CACHE_CHECK([for libio], hurd_cv_libio=yes, hurd_cv_libio=no)) +# Check if libc contains getgrouplist(). +AC_CHECK_FUNCS(getgrouplist) + # The versions of the symbols in libthreads have to match those in # libc.so. Since the symbols in a libc that includes libio will be # versioned differently from the ones in a libc that uses stdio, this -- cgit v1.2.3 From 4a195b9e39549cff9e98ef9780c24127f0ad9150 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 18 Jul 2001 18:46:12 +0000 Subject: 2001-07-18 Marcus Brinkmann * rc: Do not excempt random-seed when cleaning up /var/run. State data should be in /var/lib (FHS) or /var/state. * changelog: Update to current version. * debian/servers.boot: Add die $(serverboot). --- debian/ChangeLog | 7 +++++++ debian/changelog | 15 ++++++++++----- debian/rc | 2 +- debian/servers.boot | 3 +++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 77b01b92..8d6d4f25 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,10 @@ +2001-07-18 Marcus Brinkmann + + * rc: Do not excempt random-seed when cleaning up /var/run. State + data should be in /var/lib (FHS) or /var/state. + * changelog: Update to current version. + * debian/servers.boot: Add die $(serverboot). + 2001-06-17 Marcus Brinkmann * changelog: Update to current version. diff --git a/debian/changelog b/debian/changelog index 1c3a042e..3611a1a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +hurd (20010718-1) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + Compiled with -O2 rather than -O3. + + -- Marcus Brinkmann Thu, 18 Jul 2001 21:43:52 +0200 + hurd (20010608) unstable; urgency=low * New snapshot from CVS. @@ -274,8 +284,3 @@ hurd (19980716-1) unstable; urgency=low * Initial Version. -- Marcus Brinkmann Tue, 4 Aug 1998 21:58:55 +0200 - -Local variables: -mode: debian-changelog -add-log-mailing-address: "bug-hurd@gnu.org" -End: diff --git a/debian/rc b/debian/rc index 45592c9f..d56a5f3f 100755 --- a/debian/rc +++ b/debian/rc @@ -86,7 +86,7 @@ fi if test -d /var/run; then (cd /var/run && { - find . ! -type d ! -name utmp ! -name innd.pid ! -name random-seed \ + find . ! -type d ! -name utmp ! -name innd.pid \ -exec rm -f -- {} \; cp /dev/null utmp if grep -q ^utmp: /etc/group diff --git a/debian/servers.boot b/debian/servers.boot index 1ddd7b91..2eb4da05 100644 --- a/debian/servers.boot +++ b/debian/servers.boot @@ -17,3 +17,6 @@ # You can also add swap partitions to /etc/fstab. #/dev/hd0s2 $(add-linux-paging-file) +# Don't make serverboot the default pager. The real default pager will +# we started early in /libexec/rc. +die $(serverboot) -- cgit v1.2.3 From d4745b93f1ab7e76127769255ad3db22e4e8a52c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 18 Jul 2001 19:51:23 +0000 Subject: 2001-07-18 Marcus Brinkmann * copyright: Refer to new directory. * rules: Move documentation to share directory. Add -isp to dpkg-gencontrol invocation. Remove crufty hurd.info. * control: Bump up standards version. --- debian/ChangeLog | 8 ++++++++ debian/control | 2 +- debian/copyright | 2 +- debian/rules | 12 +++++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 8d6d4f25..065a778a 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,11 @@ +2001-07-18 Marcus Brinkmann + + * copyright: Refer to new directory. + * rules: Move documentation to share directory. + Add -isp to dpkg-gencontrol invocation. + Remove crufty hurd.info. + * control: Bump up standards version. + 2001-07-18 Marcus Brinkmann * rc: Do not excempt random-seed when cleaning up /var/run. State diff --git a/debian/control b/debian/control index 2f1bff32..0b6e9e50 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: hurd Section: base Priority: required Maintainer: GNU Hurd Maintainers -Standards-Version: 2.5.0.0 +Standards-Version: 3.5.5.0 Build-Depends: mig, texinfo, tetex-bin Package: hurd diff --git a/debian/copyright b/debian/copyright index 784f5768..4ad4e650 100644 --- a/debian/copyright +++ b/debian/copyright @@ -26,4 +26,4 @@ Public License). Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA On Debian GNU/Linux systems, the complete text of the GNU General -Public License can be found in `/usr/doc/copyright/GPL'. +Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/rules b/debian/rules index a1efd14e..765be358 100755 --- a/debian/rules +++ b/debian/rules @@ -28,7 +28,7 @@ PREFIX = /usr BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man INFODIR = $(PREFIX)/info -DOCDIR = $(PREFIX)/doc/$(package) +DOCDIR = $(PREFIX)/share/doc/$(package) # Package specific stuff. The idea is to try to make the rules # generic (gradually). @@ -125,8 +125,8 @@ binary-arch: build # now distribute the files # first the source package - $(make_directory) debian/$(package)-dev/{DEBIAN,usr/{doc,bin,lib}} - ln -s $(package) debian/$(package)-dev/usr/doc/$(package)-dev + $(make_directory) debian/$(package)-dev/{DEBIAN,usr/{share/doc,bin,lib}} + ln -s $(package) debian/$(package)-dev$(DOCDIR)-dev mv debian/tmp/include debian/$(package)-dev/usr/. mv debian/tmp/lib/*.a debian/$(package)-dev/usr/lib/. # Create development library links. @@ -136,7 +136,7 @@ binary-arch: build done rm -f debian/tmp/lib/*.so - dpkg-gencontrol -p$(package)-dev -Pdebian/$(package)-dev + dpkg-gencontrol -isp -p$(package)-dev -Pdebian/$(package)-dev chown -R root.root debian/$(package)-dev dpkg --build debian/$(package)-dev .. @@ -165,6 +165,8 @@ binary-arch: build # XXX-doc $(install_file) build/doc/hurd.info* debian/tmp$(INFODIR) -gzip -9frq debian/tmp$(INFODIR) +# XXX Remove the vague attempt of the makefiles to install the docs. + rm -fR debian/tmp/info $(install_file) debian/servers.boot debian/tmp/boot/servers.boot $(make_directory) debian/tmp/servers @@ -185,7 +187,7 @@ binary-arch: build debian/tmp/libexec/* debian/tmp/hurd/* \ debian/tmp/sbin/* ; do head -n1 $$f \ | sed -n -e '/^#!/!a\'$$'\n'$$f ; done` - dpkg-gencontrol -p$(package) -Pdebian/tmp + dpkg-gencontrol -isp -p$(package) -Pdebian/tmp chown -R root.root debian/tmp dpkg --build debian/tmp .. -- cgit v1.2.3 From 82f4992602a62e81f4a86f273c4e17ab14466c7a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 21 Jul 2001 05:17:53 +0000 Subject: 2001-07-20 Roland McGrath * panic.c: Fix obsolescent #endif syntax. --- serverboot/panic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/panic.c b/serverboot/panic.c index 4cc657f4..25924099 100644 --- a/serverboot/panic.c +++ b/serverboot/panic.c @@ -51,7 +51,7 @@ panic (const char *s, ...) #ifdef PC532 { int l; for (l=0;l < 1000000;l++) ; } -#endif PC532 +#endif /* PC532 */ #define RB_DEBUGGER 0x1000 /* enter debugger NOW */ (void) host_reboot(master_host_port, RB_DEBUGGER); for (;;); -- cgit v1.2.3 From 05ea9772212df2e538ba8e5ad3bdcb8821fa8861 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 21 Jul 2001 05:18:05 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index ce756ce0..c4b20e7d 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2001-07-20 Roland McGrath + + * panic.c: Fix obsolescent #endif syntax. + 2001-03-31 Roland McGrath * assert.h: Fix obsolescent #endif syntax. -- cgit v1.2.3 From 84891ea2b1e3af8d2e7e9ee029f1010e0734b0a2 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 21 Jul 2001 05:19:15 +0000 Subject: 2001-07-20 Roland McGrath * panic.c: Fix obsolescent #endif syntax. * ext2_file_io.c: Likewise. * disk_inode_ffs.h: Likewise. * ffs_file_io.c: Likewise. --- serverboot/disk_inode_ffs.h | 14 +++++++------- serverboot/ext2_file_io.c | 2 +- serverboot/ffs_file_io.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/serverboot/disk_inode_ffs.h b/serverboot/disk_inode_ffs.h index 43690b2f..ab352f84 100644 --- a/serverboot/disk_inode_ffs.h +++ b/serverboot/disk_inode_ffs.h @@ -1,25 +1,25 @@ -/* +/* * 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. */ @@ -96,4 +96,4 @@ #define f_blksize u.ffs.ffs_blksize #define f_blkno u.ffs.ffs_blkno -#endif _BOOT_UFS_DISK_INODE_FFS_H_ +#endif /* _BOOT_UFS_DISK_INODE_FFS_H_ */ diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c index 28ee2cb3..cb915c4a 100644 --- a/serverboot/ext2_file_io.c +++ b/serverboot/ext2_file_io.c @@ -658,7 +658,7 @@ ext2_open_file(master_device_port, path, fp) bcopy(fp->i_ic.i_block, namebuf, (unsigned) link_len); } else -#endif IC_FASTLINK +#endif /* IC_FASTLINK */ { /* * Read file for symbolic link diff --git a/serverboot/ffs_file_io.c b/serverboot/ffs_file_io.c index 0055c302..1105eacc 100644 --- a/serverboot/ffs_file_io.c +++ b/serverboot/ffs_file_io.c @@ -632,7 +632,7 @@ ffs_open_file(master_device_port, path, fp) bcopy(fp->i_symlink, namebuf, (unsigned) link_len); } else -#endif IC_FASTLINK +#endif /* IC_FASTLINK */ #if !defined(DISABLE_BSD44_FASTLINKS) /* * There is no bit for fastlinks in 4.4 but instead -- cgit v1.2.3 From 9122c9ebc5b519302d86cc0532be9b4a9e0976dd Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 21 Jul 2001 05:19:44 +0000 Subject: . --- serverboot/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index c4b20e7d..03ef843d 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,6 +1,9 @@ 2001-07-20 Roland McGrath * panic.c: Fix obsolescent #endif syntax. + * ext2_file_io.c: Likewise. + * disk_inode_ffs.h: Likewise. + * ffs_file_io.c: Likewise. 2001-03-31 Roland McGrath -- cgit v1.2.3 From 6da36980e09a2a8b1e7db0627be626aca884c797 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 10 Aug 2001 04:42:07 +0000 Subject: 2001-08-09 Roland McGrath * inode.c (diskfs_get_translator): Fail with EFTYPE if the length field stored on disk is unreasonable. Don't crash on ENOMEM. Use memcpy instead of bcopy. --- ufs/inode.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 2647754c..28f18dbd 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -602,7 +602,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) error_t err; daddr_t blkno; u_int datalen; - void *transloc; + const void *transloc; err = diskfs_catch_exception (); if (err) @@ -613,8 +613,15 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) transloc = disk_image + fsaddr (sblock, blkno); datalen = *(u_int *)transloc; - *namep = malloc (datalen); - bcopy (transloc + sizeof (u_int), *namep, datalen); + if (datalen > sblock->fs_bsize) + err = EFTYPE; + else + { + *namep = malloc (datalen); + if (*namep == NULL) + err = ENOMEM; + memcpy (*namep, transloc + sizeof (u_int), datalen); + } diskfs_end_catch_exception (); -- cgit v1.2.3 From 2f1c418840a1ba5a7029cb6f21c30052195051bc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 10 Aug 2001 04:42:15 +0000 Subject: . --- ufs/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 8f651624..871eaf78 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +2001-08-09 Roland McGrath + + * inode.c (diskfs_get_translator): Fail with EFTYPE if the length + field stored on disk is unreasonable. Don't crash on ENOMEM. + Use memcpy instead of bcopy. + 2001-06-09 Mark Kettenis * inode.c (diskfs_set_statfs): If number of free blocks is less -- cgit v1.2.3 From b6dc2a97a52a2e7ba3cc14771f48a14d6de64fe5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 10 Aug 2001 04:43:25 +0000 Subject: 2001-08-09 Roland McGrath * inode.c (diskfs_get_translator): Fail with EFTYPE if the length field stored on disk is unreasonable. Don't crash on ENOMEM. Use memcpy instead of bcopy. --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 28f18dbd..2098211f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -613,7 +613,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen) transloc = disk_image + fsaddr (sblock, blkno); datalen = *(u_int *)transloc; - if (datalen > sblock->fs_bsize) + if (datalen > sblock->fs_bsize - sizeof (u_int)) err = EFTYPE; else { -- cgit v1.2.3 From 8e7cfa8a006ba1e1616d8f88767666e4dda96de2 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 17 Aug 2001 04:48:03 +0000 Subject: 2001-08-16 Roland McGrath * Makefile (OBJS): Add userland-boot.o here. Add a vpath to find userland-boot.c in boot/ too. * bootstrap.c (parse_script): Pass new arg to boot_script_parse_line. * load.c: Include before "boot_script.h". --- serverboot/Makefile | 11 +++++++---- serverboot/bootstrap.c | 2 +- serverboot/load.c | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/serverboot/Makefile b/serverboot/Makefile index b274717e..b6b16c99 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1997, 1999 Free Software Foundation, Inc. +# Copyright (C) 1997,99,2001 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 @@ -30,11 +30,14 @@ HURDLIBS = threads installationdir = $(prefix)/boot UNZIP_OBJS = unzip.o inflate.o util.o do-bunzip2.o -OBJS = $(subst .c,.o,$(SRCS)) boot_script.o memory_objectServer.o \ - default_pagerServer.o excServer.o bootstrapServer.o \ - memory_object_defaultServer.o $(UNZIP_OBJS) +OBJS = $(subst .c,.o,$(SRCS)) \ + boot_script.o userland-boot.o \ + memory_objectServer.o \ + default_pagerServer.o excServer.o bootstrapServer.o \ + memory_object_defaultServer.o $(UNZIP_OBJS) vpath boot_script.c $(srcdir)/../boot +vpath userland-boot.c $(srcdir)/../boot # Look for zip stuff VPATH += $(srcdir)/../exec diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 46935a26..3d298a5a 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -474,7 +474,7 @@ parse_script (struct file *f) while (p < buf + f->f_size && *p != '\n') p++; *p = '\0'; - err = boot_script_parse_line (line); + err = boot_script_parse_line (0, line); if (err) boot_panic (err); if (p == buf + f->f_size) diff --git a/serverboot/load.c b/serverboot/load.c index 1665868b..21289bf1 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -24,6 +24,7 @@ * the rights to redistribute these changes. */ +#include #include #include #include @@ -237,7 +238,8 @@ mach_port_t boot_script_read_file (const char *file) { return MACH_PORT_NULL; } /* XXX */ int -boot_script_exec_cmd (task_t user_task, +boot_script_exec_cmd (void *hook, + task_t user_task, char *file_name, int arg_count, char **argv, char *argstrings, int argslen) -- cgit v1.2.3 From 9bb1538dbd5e1d7964132e8884fdfc6a53a98aed Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 17 Aug 2001 04:48:30 +0000 Subject: . --- serverboot/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 03ef843d..75a1feed 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +2001-08-16 Roland McGrath + + * Makefile (OBJS): Add userland-boot.o here. + Add a vpath to find userland-boot.c in boot/ too. + * bootstrap.c (parse_script): Pass new arg to boot_script_parse_line. + * load.c: Include before "boot_script.h". + 2001-07-20 Roland McGrath * panic.c: Fix obsolescent #endif syntax. -- cgit v1.2.3 From 7860a0cd494873b9df54c16911717ba54a9a7eeb Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 17 Aug 2001 20:18:04 +0000 Subject: 2001-08-17 Marcus Brinkmann * changelog: Update to current version. --- debian/ChangeLog | 4 ++++ debian/changelog | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 065a778a..329fc3bf 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-08-17 Marcus Brinkmann + + * changelog: Update to current version. + 2001-07-18 Marcus Brinkmann * copyright: Refer to new directory. diff --git a/debian/changelog b/debian/changelog index 3611a1a3..a454b495 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +hurd (20010816-1) unstable; urgency=low + + * New snapshot from CVS, closes: #105476, #39894. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + Compiled with -O2 rather than -O3. + + -- Marcus Brinkmann Fri, 17 Aug 2001 22:16:01 +0200 + hurd (20010718-1) unstable; urgency=low * New snapshot from CVS. -- cgit v1.2.3 From d71bdb24a229132e6a9c43c18461cf0ca58bb7d5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 26 Aug 2001 00:10:50 +0000 Subject: 2001-08-25 Roland McGrath * configure.in: Add a check for Parted's libraries. (PARTED_LIBS): New variable, substitute it. --- configure.in | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 61c963d2..93947bbb 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.20 2001/06/26 13:33:07 kettenis Exp $]) +AC_REVISION([$Id: configure.in,v 1.21 2001/08/26 00:10:50 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -104,9 +104,6 @@ AC_CACHE_CHECK([for libio], hurd_cv_libio=yes, hurd_cv_libio=no)) -# Check if libc contains getgrouplist(). -AC_CHECK_FUNCS(getgrouplist) - # The versions of the symbols in libthreads have to match those in # libc.so. Since the symbols in a libc that includes libio will be # versioned differently from the ones in a libc that uses stdio, this @@ -119,6 +116,29 @@ else fi AC_SUBST(VERSIONING) +# Check if libc contains getgrouplist(). +AC_CHECK_FUNCS(getgrouplist) + +AC_ARG_WITH(parted, dnl +[ --without-parted don't try to use GNU Parted libraries], + , with_parted=yes) + +# Check if we have the necessary stuff to build against GNU Parted libraries. +parted=$with_parted +save_LIBS= +LIBS= +test $parted = no || { + AC_CHECK_HEADER(parted/parted.h, , parted=no) +} +test $parted = no || { + AC_CHECK_LIB(uuid, uuid_generate, , parted=no) +} +test $parted = no || { + AC_CHECK_LIB(parted, ped_device_read, , parted=no) +} +PARTED_LIBS=$LIBS +LIBS=$save_LIBS +AC_SUBST(PARTED_LIBS) if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. -- cgit v1.2.3 From 0b74274e3ea112f389250eb1ea05f44566436de6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 Sep 2001 23:14:26 +0000 Subject: 2001-09-30 Roland McGrath * pass5.c (pass5): A little manual CSE makes buggy gcc not to crash. --- ufs-fsck/pass5.c | 80 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/ufs-fsck/pass5.c b/ufs-fsck/pass5.c index 7ea7aeed..cb426a7d 100644 --- a/ufs-fsck/pass5.c +++ b/ufs-fsck/pass5.c @@ -1,5 +1,5 @@ /* Pass 5 of GNU fsck -- check allocation maps and summaries - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994,96,2001 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -23,7 +23,7 @@ /* From ../ufs/subr.c: */ /* - * Update the frsum fields to reflect addition or deletion + * Update the frsum fields to reflect addition or deletion * of some frags. */ static void @@ -87,7 +87,7 @@ pass5 () sbcsums = alloca (fragroundup (sblock, sblock->fs_cssize)); - readblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, + readblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, fragroundup (sblock, sblock->fs_cssize)); /* Construct a CG structure; initialize everything that's the same @@ -105,37 +105,37 @@ pass5 () savednrpos = sblock->fs_nrpos; sblock->fs_nrpos = 8; break; - + case FS_DYNAMICPOSTBLFMT: /* Set fields unique to new cg structure */ newcg->cg_btotoff = &newcg->cg_space[0] - (u_char *)(&newcg->cg_link); newcg->cg_boff = newcg->cg_btotoff + sblock->fs_cpg * sizeof (long); newcg->cg_iusedoff = newcg->cg_boff + (sblock->fs_cpg - * sblock->fs_nrpos + * sblock->fs_nrpos * sizeof (short)); newcg->cg_freeoff = newcg->cg_iusedoff + howmany (sblock->fs_ipg, NBBY); if (sblock->fs_contigsumsize <= 0) { - newcg->cg_nextfreeoff = + newcg->cg_nextfreeoff = (newcg->cg_freeoff + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY)); } else { - newcg->cg_clustersumoff = + newcg->cg_clustersumoff = (newcg->cg_freeoff + howmany (sblock->fs_cpg * sblock->fs_spc / NSPF (sblock), NBBY) - sizeof (long)); - newcg->cg_clustersumoff = + newcg->cg_clustersumoff = roundup (newcg->cg_clustersumoff, sizeof (long)); - newcg->cg_clusteroff = - (newcg->cg_clustersumoff + newcg->cg_clusteroff = + (newcg->cg_clustersumoff + (sblock->fs_contigsumsize + 1) * sizeof (long)); - newcg->cg_nextfreeoff = - (newcg->cg_clusteroff - + howmany (sblock->fs_cpg * sblock->fs_spc / NSPB (sblock), + newcg->cg_nextfreeoff = + (newcg->cg_clusteroff + + howmany (sblock->fs_cpg * sblock->fs_spc / NSPB (sblock), NBBY)); } @@ -150,32 +150,32 @@ pass5 () default: errexit ("UNKNOWN POSTBL FORMAT"); } - + bzero (&cstotal, sizeof (struct csum)); /* Mark fragments past the end of the filesystem as used. */ j = blknum (sblock, sblock->fs_size + sblock->fs_frag - 1); for (i = sblock->fs_size; i < j; i++) setbmap (i); - + /* Now walk through the cylinder groups, checking each one. */ for (c = 0; c < sblock->fs_ncg; c++) { int dbase, dmax; - + /* Read the cylinder group structure */ readblock (fsbtodb (sblock, cgtod (sblock, c)), cg, sblock->fs_cgsize); writecg = 0; - + if (!cg_chkmagic (cg)) warning (1, "CG %d: BAD MAGIC NUMBER", c); - + /* Compute first and last data block addresses in this group */ dbase = cgbase (sblock, c); dmax = dbase + sblock->fs_fpg; if (dmax > sblock->fs_size) dmax = sblock->fs_size; - + /* Initialize newcg fully; values from cg for those we can't check. */ newcg->cg_time = cg->cg_time; @@ -230,7 +230,7 @@ pass5 () pfix ("FIXED"); } } - + /* Zero the block maps and summary areas */ bzero (&newcg->cg_frsum[0], sizeof newcg->cg_frsum); bzero (&cg_blktot (newcg)[0], sumsize + mapsize); @@ -267,8 +267,8 @@ pass5 () setbit (cg_inosused (newcg), i); newcg->cg_cs.cs_nifree--; } - - /* Walk through each data block, accounting for it in + + /* Walk through each data block, accounting for it in the block map and in newcg->cg_cs. */ /* In this look, D is the block number and I is the block number relative to this CG. */ @@ -277,7 +277,7 @@ pass5 () d += sblock->fs_frag, i += sblock->fs_frag) { int frags = 0; - + /* Set each free frag of this block in the block map; count how many frags were free. */ for (j = 0; j < sblock->fs_frag; j++) @@ -287,8 +287,8 @@ pass5 () setbit (cg_blksfree (newcg), i + j); frags++; } - - /* If all the frags were free, then count this as + + /* If all the frags were free, then count this as a free block too. */ if (frags == sblock->fs_frag) { @@ -308,7 +308,7 @@ pass5 () ffs_fragacct (sblock, blk, newcg->cg_frsum, 1); } } - + if (sblock->fs_contigsumsize > 0) { long *sump = cg_clustersum (newcg); @@ -316,7 +316,7 @@ pass5 () int map = *mapp++; int bit = 1; int run = 0; - + for (i = 0; i < newcg->cg_nclusterblks; i++) { if ((map & bit) != 0) @@ -363,7 +363,7 @@ pass5 () pfix ("FIXED"); } } - + /* Check inode and block maps */ if (bcmp (cg_inosused (newcg), cg_inosused (cg), mapsize)) { @@ -375,7 +375,7 @@ pass5 () pfix ("FIXED"); } } - + if (bcmp (&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize)) { problem (0, "SUMMARY INFORMATION FOR CG %d BAD", c); @@ -386,7 +386,7 @@ pass5 () pfix ("FIXED"); } } - + if (bcmp (newcg, cg, basesize)) { problem (0, "CYLINDER GROUP %d BAD", c); @@ -399,14 +399,14 @@ pass5 () } if (writecg) - writeblock (fsbtodb (sblock, cgtod (sblock, c)), + writeblock (fsbtodb (sblock, cgtod (sblock, c)), cg, sblock->fs_cgsize); } - + /* Restore nrpos */ if (sblock->fs_postblformat == FS_42POSTBLFMT) sblock->fs_nrpos = savednrpos; - + if (bcmp (&cstotal, &sblock->fs_cstotal, sizeof (struct csum))) { problem (0, "TOTAL FREE BLK COUNTS WRONG IN SUPERBLOCK"); @@ -430,21 +430,21 @@ pass5 () pfix ("MARKED CLEAN"); } } - + if (writesb) writeblock (SBLOCK, sblock, SBSIZE); if (writecsum) { + const int cssize = fragroundup (sblock, sblock->fs_cssize); struct csum *test; - - writeblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, + + writeblock (fsbtodb (sblock, sblock->fs_csaddr), sbcsums, fragroundup (sblock, sblock->fs_cssize)); - test = alloca (fragroundup (sblock, sblock->fs_cssize)); - readblock (fsbtodb (sblock, sblock->fs_csaddr), test, - fragroundup (sblock, sblock->fs_cssize)); - if (bcmp (test, sbcsums, fragroundup (sblock, sblock->fs_cssize))) + test = alloca (cssize); + readblock (fsbtodb (sblock, sblock->fs_csaddr), test, cssize); + if (bcmp (test, sbcsums, cssize)) warning (0, "CSUM WRITE INCONSISTENT"); } } -- cgit v1.2.3 From 22dc8fd28ca44399c8aade54e7ddd265c2f58d7b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 Sep 2001 23:14:31 +0000 Subject: . --- ufs-fsck/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 277fd9a7..0e678ab5 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +2001-09-30 Roland McGrath + + * pass5.c (pass5): A little manual CSE makes buggy gcc not to crash. + 2001-02-25 Roland McGrath * utilities.c: Include for decl. -- cgit v1.2.3 From b64ffb6ccda693a6ed39b48e8862a4dae862477c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 1 Oct 2001 08:28:17 +0000 Subject: 2001-10-01 Marcus Brinkmann * changelog: Update to current version. * update-rc.d: New file moved from dpkg to here. * rules: Install update-rc.d. --- debian/ChangeLog | 6 ++ debian/changelog | 11 ++- debian/rules | 1 + debian/update-rc.d | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 223 insertions(+), 2 deletions(-) create mode 100755 debian/update-rc.d diff --git a/debian/ChangeLog b/debian/ChangeLog index 329fc3bf..e03c462c 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,9 @@ +2001-10-01 Marcus Brinkmann + + * changelog: Update to current version. + * update-rc.d: New file moved from dpkg to here. + * rules: Install update-rc.d. + 2001-08-17 Marcus Brinkmann * changelog: Update to current version. diff --git a/debian/changelog b/debian/changelog index a454b495..1fd4da25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,11 @@ -hurd (20010816-1) unstable; urgency=low +hurd (20010817-2) unstable; urgency=low + + * Include a copy of update-rc.d, moved from dpkg to init providing + package. + + -- Marcus Brinkmann Sun, 2 Sep 2001 19:40:00 +0200 + +hurd (20010817-1) unstable; urgency=low * New snapshot from CVS, closes: #105476, #39894. * Additional patches: @@ -6,7 +13,7 @@ hurd (20010816-1) unstable; urgency=low Change terminal type to mach-color. Compiled with -O2 rather than -O3. - -- Marcus Brinkmann Fri, 17 Aug 2001 22:16:01 +0200 + -- Marcus Brinkmann Fri, 17 Aug 2001 22:16:01 +0200 hurd (20010718-1) unstable; urgency=low diff --git a/debian/rules b/debian/rules index 765be358..06fa19e5 100755 --- a/debian/rules +++ b/debian/rules @@ -176,6 +176,7 @@ binary-arch: build # We have our own rc, slightly modified. cp debian/rc debian/tmp/libexec/rc + $(install_script) debian/update-rc.d debian/tmp/sbin $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs diff --git a/debian/update-rc.d b/debian/update-rc.d new file mode 100755 index 00000000..83d12ffd --- /dev/null +++ b/debian/update-rc.d @@ -0,0 +1,207 @@ +#! /usr/bin/perl +# +# update-rc.d Update the links in /etc/rc[0-9S].d/ +# +# Version: @(#)update-rc.d.pl 2.02 05-Mar-1998 miquels@cistron.nl +# + +$initd = "/etc/init.d"; +$etcd = "/etc/rc"; +$notreally = 0; + +# Print usage message and die. + +sub usage { + print STDERR "update-rc.d: error: @_\n" if ($#_ >= 0); + print STDERR < remove + update-rc.d [-n] defaults [NN | sNN kNN] + update-rc.d [-n] start|stop NN runlvl [runlvl] [...] . + -n: not really + -f: force +EOF + exit (1); +} + +# Check out options. + +while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) { + shift @ARGV; + if (/^-n$/) { $notreally++; next } + if (/^-f$/) { $force++; next } + if (/^-h|--help$/) { &usage; } + &usage("unknown option"); +} + +# Action. + +&usage() if ($#ARGV < 1); +$bn = shift @ARGV; +if ($ARGV[0] ne 'remove') { + if (! -f "$initd/$bn") { + print STDERR "update-rc.d: $initd/$bn: file does not exist\n"; + exit (1); + } +} elsif (-f "$initd/$bn") { + if (!$force) { + printf STDERR "update-rc.d: $initd/$bn exists during rc.d purge (use -f to force)\n"; + exit (1); + } else { + printf STDERR "update-rc.d: $initd/$bn exists during rc.d purge (continuing)\n"; + } +} + +$_ = $ARGV[0]; +if (/^remove$/) { &checklinks ("remove"); } +elsif (/^defaults$/) { &defaults; &makelinks } +elsif (/^(start|stop)$/) { &startstop; &makelinks; } +else { &usage; } + +exit (0); + +# Check if there are links in /etc/rc[0-9S].d/ +# Remove if the first argument is "remove" and the links +# point to $bn. + +sub is_link () { + my ($op, $fn, $bn) = @_; + if (! -l $fn) { + print STDERR "update-rc.d: warning: $fn is not a symbolic link\n"; + return 0; + } else { + $linkdst = readlink ($fn); + if (! defined $linkdst) { + die ("update-rc.d: error reading symbolic link: $!\n"); + } + if (($linkdst ne "../init.d/$bn") && ($linkdst ne "../init.d/$bn")) { + print STDERR "update-rc.d: warning: $fn is not a link to ../init.d/$bn\n"; + return 0; + } + } + return 1; +} + +sub checklinks { + my ($i, $found, $fn, $islnk); + + print " Removing any system startup links for $initd/$bn ...\n" + if ($_[0] eq 'remove'); + + $found = 0; + + foreach $i (0..9, 'S') { + unless (chdir ("$etcd$i.d")) { + next if ($i =~ m/^[789S]$/); + die("update-rc.d: chdir $etcd$i.d: $!\n"); + } + opendir(DIR, "."); + foreach $_ (readdir(DIR)) { + next unless (/^[SK]\d\d$bn$/); + $fn = "$etcd$i.d/$_"; + $found = 1; + $islnk = &is_link ($_[0], $fn, $bn); + next if ($_[0] ne 'remove'); + if (! $islnk) { + print " $fn is not a link to ../init.d/$bn; not removing\n"; + next; + } + print " $etcd$i.d/$_\n"; + next if ($notreally); + unlink ("$etcd$i.d/$_") || + die("update-rc.d: unlink: $!\n"); + } + closedir(DIR); + } + $found; +} + +# Process the arguments after the "defaults" keyword. + +sub defaults { + my ($start, $stop) = (20, 20); + + &usage ("defaults takes only one or two codenumbers") if ($#ARGV > 2); + $start = $stop = $ARGV[1] if ($#ARGV >= 1); + $stop = $ARGV[2] if ($#ARGV >= 2); + &usage ("codenumber must be a number between 0 and 99") + if ($start !~ /^\d\d?$/ || $stop !~ /^\d\d?$/); + + $start = sprintf("%02d", $start); + $stop = sprintf("%02d", $stop); + + $stoplinks[0] = $stoplinks[1] = $stoplinks[6] = "K$stop"; + $startlinks[2] = $startlinks[3] = + $startlinks[4] = $startlinks[5] = "S$start"; + + 1; +} + +# Process the arguments after the start or stop keyword. + +sub startstop { + + my($letter, $NN, $level); + + while ($#ARGV >= 0) { + if ($ARGV[0] eq 'start') { $letter = 'S'; } + elsif ($ARGV[0] eq 'stop') { $letter = 'K' } + else { + &usage("expected start|stop"); + } + + if ($ARGV[1] !~ /^\d\d?$/) { + &usage("expected NN after $ARGV[0]"); + } + $NN = sprintf("%02d", $ARGV[1]); + + shift @ARGV; shift @ARGV; + $level = shift @ARGV; + do { + if ($level !~ m/^[0-9S]$/) { + &usage( + "expected runlevel [0-9S] (did you forget \".\" ?)"); + } + if (! -d "$etcd$level.d") { + print STDERR + "update-rc.d: $etcd$level.d: no such directory\n"; + exit(1); + } + $level = 99 if ($level eq 'S'); + $startlinks[$level] = "$letter$NN" if ($letter eq 'S'); + $stoplinks[$level] = "$letter$NN" if ($letter eq 'K'); + } while (($level = shift @ARGV) ne '.'); + &usage("action with list of runlevels not terminated by \`.'") + if ($level ne '.'); + } + 1; +} + +# Create the links. + +sub makelinks { + my($t, $i); + my @links; + + if (&checklinks) { + print " System startup links for $initd/$bn already exist.\n"; + exit (0); + } + print " Adding system startup for $initd/$bn ...\n"; + + # nice unreadable perl mess :) + + for($t = 0; $t < 2; $t++) { + @links = $t ? @startlinks : @stoplinks; + for($i = 0; $i <= $#links; $i++) { + $lvl = $i; + $lvl = 'S' if ($i == 99); + next if ($links[$i] eq ''); + print " $etcd$lvl.d/$links[$i]$bn -> ../init.d/$bn\n"; + next if ($notreally); + symlink("../init.d/$bn", "$etcd$lvl.d/$links[$i]$bn") + || die("update-rc.d: symlink: $!\n"); + } + } + + 1; +} -- cgit v1.2.3 From b005f7053b00dc5e7c6eeab6a104f7fc7b7b6ab5 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 1 Oct 2001 16:37:27 +0000 Subject: 2001-10-01 Marcus Brinkmann * ufs.h (swab_long_long): Use LL, not lL, for constant. Submitted by Maurizio Boriani . --- ufs/ChangeLog | 5 +++++ ufs/ufs.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 871eaf78..e013b8f5 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +2001-10-01 Marcus Brinkmann + + * ufs.h (swab_long_long): Use LL, not lL, for constant. + Submitted by Maurizio Boriani . + 2001-08-09 Roland McGrath * inode.c (diskfs_get_translator): Fail with EFTYPE if the length diff --git a/ufs/ufs.h b/ufs/ufs.h index 77fb50e0..5d823ebc 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -208,7 +208,7 @@ extern inline long long swab_long_long (long long arg) { return (((long long) swab_long (arg & 0xffffffff) << 32) - | swab_long ((arg & 0xffffffff00000000lL) >> 32)); + | swab_long ((arg & 0xffffffff00000000LL) >> 32)); } /* Return ENTRY, after byteswapping it if necessary */ -- cgit v1.2.3 From 2b2c8259c75d5a0650a8af1ced47474c4ff9e180 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 12 Oct 2001 00:04:58 +0000 Subject: 2001-10-12 Marcus Brinkmann * configure.in: If parted/parted.h is found, define HAVE_PARTED_PARTED_H explicitely. --- configure.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 93947bbb..3299af40 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.21 2001/08/26 00:10:50 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.22 2001/10/12 00:04:58 marcus Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -128,7 +128,9 @@ parted=$with_parted save_LIBS= LIBS= test $parted = no || { - AC_CHECK_HEADER(parted/parted.h, , parted=no) + AC_CHECK_HEADER(parted/parted.h, + [AC_DEFINE(HAVE_PARTED_PARTED_H)], + parted=no) } test $parted = no || { AC_CHECK_LIB(uuid, uuid_generate, , parted=no) -- cgit v1.2.3 From 4f3ae4d4b20260a83afba7ae4de74bdaff57caf7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 12 Oct 2001 23:25:24 +0000 Subject: 2001-10-13 Marcus Brinkmann * debian/rules: New dpkg-shlibdeps is more strict and complains about statically linked files, so a new filter is necessary. * debian/control: Add `file' to build dependencies. By Kevin Kreamer . * debian/changelog: Update for new release. --- debian/ChangeLog | 9 +++++++++ debian/changelog | 11 +++++++++++ debian/control | 2 +- debian/rules | 14 +++++++++----- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index e03c462c..f7454a32 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,12 @@ +2001-10-13 Marcus Brinkmann + + * debian/rules: New dpkg-shlibdeps is more strict and complains + about statically linked files, so a new filter is necessary. + * debian/control: Add `file' to build dependencies. + By Kevin Kreamer . + + * debian/changelog: Update for new release. + 2001-10-01 Marcus Brinkmann * changelog: Update to current version. diff --git a/debian/changelog b/debian/changelog index 1fd4da25..4fcefd7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +hurd (20010817-3) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + * debian/rules: Change way how to find executables by Kevin Kreamer. + * debian/control: Add `file' to build dependencies by Kevin Kreamer. + + -- Marcus Brinkmann Sat, 13 Oct 2001 01:05:30 +0200 + hurd (20010817-2) unstable; urgency=low * Include a copy of update-rc.d, moved from dpkg to init providing diff --git a/debian/control b/debian/control index 0b6e9e50..d704fa94 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 -Build-Depends: mig, texinfo, tetex-bin +Build-Depends: file, mig, texinfo, tetex-bin Package: hurd Priority: required diff --git a/debian/rules b/debian/rules index 06fa19e5..c5dea47f 100755 --- a/debian/rules +++ b/debian/rules @@ -183,11 +183,15 @@ binary-arch: build $(install_script) debian/postinst debian/tmp/DEBIAN/postinst $(install_script) debian/prerm debian/tmp/DEBIAN/prerm - # Filter out scripts. - dpkg-shlibdeps -p$(package) `for f in debian/tmp/bin/* \ - debian/tmp/libexec/* debian/tmp/hurd/* \ - debian/tmp/sbin/* ; do head -n1 $$f \ - | sed -n -e '/^#!/!a\'$$'\n'$$f ; done` + # Get list of dynamically linked executables + dpkg-shlibdeps -p$(package) \ + `file debian/tmp/bin/* \ + debian/tmp/hurd/* \ + debian/tmp/lib/* \ + debian/tmp/libexec/* \ + debian/tmp/sbin/* \ + | egrep '(executable.*dynamic)|(shared object)' \ + | cut -f 1 -d ':'` dpkg-gencontrol -isp -p$(package) -Pdebian/tmp chown -R root.root debian/tmp dpkg --build debian/tmp .. -- cgit v1.2.3 From 9d7e7cd11463a6c1bf64f6c9c222132a4b8f4d8e Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sat, 13 Oct 2001 01:00:33 +0000 Subject: Fix version number. --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4fcefd7a..754bc7c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hurd (20010817-3) unstable; urgency=low +hurd (20011013-1) unstable; urgency=low * New snapshot from CVS. * Additional patches: -- cgit v1.2.3 From 20b4ae7e800ace729b616182b691c08add8c3cc1 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 16 Oct 2001 17:45:19 +0000 Subject: 2001-10-16 Marcus Brinkmann * debian/changelog: Update for new Debian package. --- debian/ChangeLog | 4 ++++ debian/changelog | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index f7454a32..0ff288c2 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-10-16 Marcus Brinkmann + + * debian/changelog: Update for new Debian package. + 2001-10-13 Marcus Brinkmann * debian/rules: New dpkg-shlibdeps is more strict and complains diff --git a/debian/changelog b/debian/changelog index 754bc7c0..ec66329d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,20 @@ +hurd (20011016-1) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual. + Change terminal type to mach-color. + Compiled with -O2 rather than -O3. + + -- Marcus Brinkmann Tue, 16 Oct 2001 19:43:21 +0200 + hurd (20011013-1) unstable; urgency=low * New snapshot from CVS. * Additional patches: kbd, mouse as usual. Change terminal type to mach-color. + Compiled with -O2 rather than -O3. * debian/rules: Change way how to find executables by Kevin Kreamer. * debian/control: Add `file' to build dependencies by Kevin Kreamer. -- cgit v1.2.3 From 6ba7e0f836b4355526be7019bfb5b74966ae1249 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 4 Nov 2001 23:02:25 +0000 Subject: 2001-11-05 Marcus Brinkmann * debian/changelog: Update for new Debian package. --- debian/ChangeLog | 4 ++++ debian/changelog | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 0ff288c2..ae2d4606 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2001-11-05 Marcus Brinkmann + + * debian/changelog: Update for new Debian package. + 2001-10-16 Marcus Brinkmann * debian/changelog: Update for new Debian package. diff --git a/debian/changelog b/debian/changelog index ec66329d..c273e920 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +hurd (20011105-1) unstable; urgency=low + + * New snapshot from CVS. + * Additional patches: + kbd, mouse as usual (well, the intention was there :). + Change terminal type to mach-color. + Compiled with -O2 rather than -O3. + + -- Marcus Brinkmann Mon, 5 Nov 2001 00:00:26 +0100 + hurd (20011016-1) unstable; urgency=low * New snapshot from CVS. -- cgit v1.2.3 From 2647fe79a023583f6849054e1b9bb8511d9889c0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 21 Nov 2001 22:08:48 +0000 Subject: 2001-11-21 Roland McGrath * inode.c (read_disknode): Just always call getpid for the fsid value. --- ufs/inode.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index 2098211f..a258ea13 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -212,7 +212,6 @@ diskfs_new_hardrefs (struct node *np) static error_t read_disknode (struct node *np) { - static int fsid, fsidset; struct stat *st = &np->dn_stat; struct dinode *di = dino (np->dn->number); error_t err; @@ -221,14 +220,8 @@ read_disknode (struct node *np) if (err) return err; - if (! fsidset) - { - fsid = getpid (); - fsidset = 1; - } - st->st_fstype = FSTYPE_UFS; - st->st_fsid = fsid; + st->st_fsid = getpid (); /* This call is very cheap. */ st->st_ino = np->dn->number; st->st_gen = read_disk_entry (di->di_gen); st->st_rdev = read_disk_entry(di->di_rdev); -- cgit v1.2.3 From 7b2663dcd0afabce61218303c2c7709e37c0a3c8 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 21 Nov 2001 22:09:03 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index e013b8f5..a655a739 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +2001-11-21 Roland McGrath + + * inode.c (read_disknode): Just always call getpid for the fsid value. + 2001-10-01 Marcus Brinkmann * ufs.h (swab_long_long): Use LL, not lL, for constant. -- cgit v1.2.3 From f9dbbd18dcdcbf4b04c3f036d8981e4ec92dc8de Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 24 Nov 2001 22:05:47 +0000 Subject: 2001-11-24 Roland McGrath * Makefile (installationdir): Use $(bootdir). --- serverboot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverboot/Makefile b/serverboot/Makefile index b6b16c99..c4d37430 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -27,7 +27,7 @@ LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h \ disk_inode.h file_io.h minix_super.h mach-exec.h target = serverboot HURDLIBS = threads -installationdir = $(prefix)/boot +installationdir = $(bootdir) UNZIP_OBJS = unzip.o inflate.o util.o do-bunzip2.o OBJS = $(subst .c,.o,$(SRCS)) \ -- cgit v1.2.3 From 93014dc037535a9091d4a1302acedc633303729f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 24 Nov 2001 22:05:57 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 75a1feed..0647abeb 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2001-11-24 Roland McGrath + + * Makefile (installationdir): Use $(bootdir). + 2001-08-16 Roland McGrath * Makefile (OBJS): Add userland-boot.o here. -- cgit v1.2.3 From bff85f165632d2f62ed431f4ff5502e3f9a7fad3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 Dec 2001 22:06:54 +0000 Subject: 2001-12-02 Roland McGrath * mkfs.c (fsinit): Set the root directory's owner/group to the user's. Suggested by Michael Teichgraeber . --- ufs-utils/mkfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 1bfce2eb..6d544949 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.19 2001/02/26 04:16:18 roland Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.20 2001/12/02 22:06:54 roland Exp $"; #endif /* not lint */ #include @@ -1158,6 +1158,14 @@ fsinit(utime) node.di_model = IFDIR | UMASK; node.di_modeh = 0; node.di_nlink = PREDEFDIR; + + /* Set the uid/gid to non-root if run by a non-root user. This + is what mke2fs does in e2fsprogs-1.18 (actually it uses the + real IDs iff geteuid()!=0, but that is just wrong). */ + node.di_uid = geteuid(); + if (node.di_uid != 0) + node.di_gid = getegid(); + if (Oflag) node.di_size = makedir((struct directory_entry *)oroot_dir, PREDEFDIR); else -- cgit v1.2.3 From 6ff65bacaaf1b6e86a16eacadbe60c511098968a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 Dec 2001 22:06:58 +0000 Subject: . --- ufs-utils/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index a445b3a6..778cfe7b 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +2001-12-02 Roland McGrath + + * mkfs.c (fsinit): Set the root directory's owner/group to the user's. + Suggested by Michael Teichgraeber . + 2001-02-25 Roland McGrath * mkfs.c [!STANDALONE]: Include for decl. -- cgit v1.2.3 From ce5b1c54eca565115256b770d4aaf61a6892db01 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 7 Dec 2001 00:35:24 +0000 Subject: 2001-12-06 Roland McGrath * dlabel.c (fd_get_device): Only deallocate NODE if store_create fails. Found by Michael Teichgraeber . --- ufs-utils/dlabel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs-utils/dlabel.c b/ufs-utils/dlabel.c index 1bb30bbc..355cb3f6 100644 --- a/ufs-utils/dlabel.c +++ b/ufs-utils/dlabel.c @@ -1,6 +1,6 @@ /* Get the disklabel from a device node - Copyright (C) 1996, 1999 Free Software Foundation, Inc. + Copyright (C) 1996,99,2001 Free Software Foundation, Inc. Written by Miles Bader @@ -43,7 +43,7 @@ fd_get_device (int fd, device_t *device) if (node == MACH_PORT_NULL) return errno; - err = store_create (node, 0, 0, &store); + err = store_create (node, 0, 0, &store); /* consumes NODE on success */ if (! err) { if (store->class->id != STORAGE_DEVICE @@ -63,8 +63,8 @@ fd_get_device (int fd, device_t *device) } store_free (store); } - - mach_port_deallocate (mach_task_self (), node); + else + mach_port_deallocate (mach_task_self (), node); return err; } -- cgit v1.2.3 From 01d097b8f2cc411b9b91f44cf4de0283d81f1547 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 7 Dec 2001 00:35:31 +0000 Subject: . --- ufs-utils/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 778cfe7b..66cefd4c 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +2001-12-06 Roland McGrath + + * dlabel.c (fd_get_device): Only deallocate NODE if store_create fails. + Found by Michael Teichgraeber . + 2001-12-02 Roland McGrath * mkfs.c (fsinit): Set the root directory's owner/group to the user's. -- cgit v1.2.3 From 06f2e9476ffdecf1c3aa722bb26b38272f0892b5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 22 Dec 2001 20:45:48 +0000 Subject: 2001-12-22 Roland McGrath * configure.in (asm_syntax): Grok "powerpc" value for $host_cpu. Default asm_syntax to $host_cpu if not a known type. Complain about unsupported CPU iff libthreads/$asm_syntax/cthreads.h is missing; make that complaint a warning rather than fatal error. --- configure.in | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 3299af40..730e05e5 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.22 2001/10/12 00:04:58 marcus Exp $]) +AC_REVISION([$Id: configure.in,v 1.23 2001/12/22 20:45:48 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -20,11 +20,22 @@ none) AC_MSG_ERROR([ esac case "$host_cpu" in -i?86) asm_syntax=i386 ;; -*) AC_MSG_ERROR([unsupported CPU type]) ;; +i?86) + asm_syntax=i386 + ;; +powerpc) + asm_syntax=ppc + ;; +*) + asm_syntax="$host_cpu" + ;; esac AC_SUBST(asm_syntax) +test -r "$srcdir/libthreads/$asm_syntax/cthreads.h" || { + AC_MSG_WARN([unsupported CPU type $host_cpu]) +} + AC_ARG_ENABLE(profile, [ --disable-profile do not build profiled libraries and programs]) AC_SUBST(enable_profile) -- cgit v1.2.3 From 6d6f9125195c5b8d3c0cb4e89465e4f08d00a718 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sat, 29 Dec 2001 02:24:25 +0000 Subject: 2001-12-29 Marcus Brinkmann * control (Build-Depends): Add automake and autoconf to build dependencies. Reported by Jordi Mallach. --- debian/ChangeLog | 5 +++++ debian/control | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index ae2d4606..9ddb51d7 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +2001-12-29 Marcus Brinkmann + + * control (Build-Depends): Add automake and autoconf to build + dependencies. Reported by Jordi Mallach. + 2001-11-05 Marcus Brinkmann * debian/changelog: Update for new Debian package. diff --git a/debian/control b/debian/control index d704fa94..a699c426 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 -Build-Depends: file, mig, texinfo, tetex-bin +Build-Depends: file, mig, texinfo, tetex-bin, automake, autoconf Package: hurd Priority: required -- cgit v1.2.3 From 121c770c18a6f82ba70c3bffac81c18fd97c1978 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sat, 29 Dec 2001 11:42:28 +0000 Subject: 2001-12-29 Marcus Brinkmann * rules (configure): Don't call aclocal. * control (Build-Depends): We don't need automake. --- debian/ChangeLog | 5 +++++ debian/control | 2 +- debian/rules | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 9ddb51d7..c5bdf0db 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +2001-12-29 Marcus Brinkmann + + * rules (configure): Don't call aclocal. + * control (Build-Depends): We don't need automake. + 2001-12-29 Marcus Brinkmann * control (Build-Depends): Add automake and autoconf to build diff --git a/debian/control b/debian/control index a699c426..5c56e84f 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 -Build-Depends: file, mig, texinfo, tetex-bin, automake, autoconf +Build-Depends: file, mig, texinfo, tetex-bin, autoconf Package: hurd Priority: required diff --git a/debian/rules b/debian/rules index c5dea47f..2a657ca9 100755 --- a/debian/rules +++ b/debian/rules @@ -53,7 +53,6 @@ endef # Next is NOT a phony target. configure: configure.in - aclocal autoconf # The next IS a phony target. -- cgit v1.2.3 From 6a55014844637d118979142b8efcc5b07e08e553 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 31 Dec 2001 23:39:18 +0000 Subject: 2001-12-31 Roland McGrath * configure.in: Check mig for `retcode' keyword support. If not there, add -DRetCode=NoLong. --- configure.in | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 730e05e5..cf117be0 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.23 2001/12/22 20:45:48 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.24 2001/12/31 23:39:18 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -79,6 +79,29 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) AC_SUBST(LIBCRYPT) +# See if mig groks `retcode'. +AC_CACHE_CHECK(whether $MIG supports the retcode keyword, hurd_cv_mig_retcode, +[cat > conftest.defs <<\EOF +#include +#include +subsystem foobar 1000; +type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t; +simpleroutine foobar_reply ( + reply_port: reply_port_t; + err: kern_return_t, RetCode); +EOF +if AC_TRY_COMMAND([CC="${CC}" ${MIG-false} -n conftest.defs 1>&AC_FD_CC]); then + hurd_cv_mig_retcode=yes +else + hurd_cv_mig_retcode=no +fi +rm -f conftest*]) +if test $hurd_cv_mig_retcode = no; then + dnl NoLong is a harmless syntactically equivalent flag. + AC_DEFINE(RetCode, NoLong) +fi + # See if --version-script is available. AC_CACHE_CHECK(for ld --version-script, hurd_cv_ld_version_script_option, [dnl cat > conftest.c <<\EOF -- cgit v1.2.3 From c1099508d71e2abbcd25fdaf95a8f1a1e1397141 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jan 2002 01:47:59 +0000 Subject: 2002-01-01 Roland McGrath * configure.in: Fix last change to use IsNotLong instead of NoLong. --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index cf117be0..49fe056b 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.24 2001/12/31 23:39:18 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.25 2002/01/02 01:47:59 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -98,8 +98,8 @@ else fi rm -f conftest*]) if test $hurd_cv_mig_retcode = no; then - dnl NoLong is a harmless syntactically equivalent flag. - AC_DEFINE(RetCode, NoLong) + dnl IsNoTLong is a harmless syntactically equivalent flag. + AC_DEFINE(RetCode, IsNotLong) fi # See if --version-script is available. -- cgit v1.2.3 From e052e5945b29ad962091aa527f74a88b7f8cfe2b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jan 2002 01:56:39 +0000 Subject: 2002-01-01 Roland McGrath * configure.in: Make that "-DRETCODE=". --- configure.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 49fe056b..a1667a63 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.25 2002/01/02 01:47:59 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.26 2002/01/02 01:56:39 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -98,8 +98,7 @@ else fi rm -f conftest*]) if test $hurd_cv_mig_retcode = no; then - dnl IsNoTLong is a harmless syntactically equivalent flag. - AC_DEFINE(RetCode, IsNotLong) + AC_DEFINE(RETCODE,) fi # See if --version-script is available. -- cgit v1.2.3 From 460585a88100dfb6274d1753d7208964d41dfcb7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jan 2002 02:07:37 +0000 Subject: 2002-01-01 Roland McGrath * configure.in: If mig supports `retcode', define HAVE_MIG_RETCODE. --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index a1667a63..064e995f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.26 2002/01/02 01:56:39 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.27 2002/01/02 02:07:37 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -97,8 +97,8 @@ else hurd_cv_mig_retcode=no fi rm -f conftest*]) -if test $hurd_cv_mig_retcode = no; then - AC_DEFINE(RETCODE,) +if test $hurd_cv_mig_retcode = yes; then + AC_DEFINE(HAVE_MIG_RETCODE) fi # See if --version-script is available. -- cgit v1.2.3 From 9f27871605c4e7c76db82f73174ff45229952c1d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 19 Jan 2002 23:44:37 +0000 Subject: 2002-01-05 Roland McGrath * aclocal.m4 (hurd_MIG_RETCODE): New macro. * configure.in: Broken out of here, now use that. --- configure.in | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/configure.in b/configure.in index 064e995f..ca4e0703 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.27 2002/01/02 02:07:37 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.28 2002/01/19 23:44:37 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -79,27 +79,7 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt) AC_SUBST(LIBCRYPT) -# See if mig groks `retcode'. -AC_CACHE_CHECK(whether $MIG supports the retcode keyword, hurd_cv_mig_retcode, -[cat > conftest.defs <<\EOF -#include -#include -subsystem foobar 1000; -type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE - ctype: mach_port_t; -simpleroutine foobar_reply ( - reply_port: reply_port_t; - err: kern_return_t, RetCode); -EOF -if AC_TRY_COMMAND([CC="${CC}" ${MIG-false} -n conftest.defs 1>&AC_FD_CC]); then - hurd_cv_mig_retcode=yes -else - hurd_cv_mig_retcode=no -fi -rm -f conftest*]) -if test $hurd_cv_mig_retcode = yes; then - AC_DEFINE(HAVE_MIG_RETCODE) -fi +hurd_MIG_RETCODE # See if --version-script is available. AC_CACHE_CHECK(for ld --version-script, hurd_cv_ld_version_script_option, [dnl -- cgit v1.2.3 From 43b5906bb0c8d2aeaf523d1f68e33053c0b0778f Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 28 Jan 2002 13:21:12 +0000 Subject: 2002-01-28 Marcus Brinkmann * copyright: Remove Linuxism. --- debian/ChangeLog | 4 ++++ debian/copyright | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index c5bdf0db..03058e9b 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2002-01-28 Marcus Brinkmann + + * copyright: Remove Linuxism. + 2001-12-29 Marcus Brinkmann * rules (configure): Don't call aclocal. diff --git a/debian/copyright b/debian/copyright index 4ad4e650..51ed720a 100644 --- a/debian/copyright +++ b/debian/copyright @@ -25,5 +25,5 @@ Public License). along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -On Debian GNU/Linux systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. +On Debian systems, the complete text of the GNU General Public License +can be found in `/usr/share/common-licenses/GPL'. -- cgit v1.2.3 From 73b3e2418b370fba8528ac229fa64447fdec4cbc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 12 Mar 2002 03:01:02 +0000 Subject: 2002-03-11 Roland McGrath * configure.in (--enable-boot-store-types): Grok this arg. * config.make.in (boot-store-types): New variable, set by it. * Makeconf [$(dir) != libstore] ($(boot-store-types:%=../libstore/libstore_%.a)): Make these targets depend on ../libstore/libstore.so. --- configure.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index ca4e0703..2b7b8f3e 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.28 2002/01/19 23:44:37 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.29 2002/03/12 03:01:02 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -155,6 +155,16 @@ PARTED_LIBS=$LIBS LIBS=$save_LIBS AC_SUBST(PARTED_LIBS) +AC_ARG_ENABLE(boot-store-types, +[ --enable-boot-store-types=TYPES... + list of store types included in statically + linked filesystems used for booting])dnl +if test -z "$enable_boot_store_types"; then + boot_store_types='device gunzip bunzip2' + test $parted = no || boot_store_types="$boot_store_types part" +fi +AC_SUBST(boot_store_types)dnl + if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. makefiles= -- cgit v1.2.3 From d944b66ab2bc82aa80eb7fd351bdb8c7001ef5e5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 14 Mar 2002 21:11:37 +0000 Subject: 2002-03-11 Roland McGrath * Makefile (ufs.static): Depend on $(boot-store-types:%=../libstore/libstore_%.a). --- ufs/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ufs/Makefile b/ufs/Makefile index 183caa86..02cf38ba 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -1,6 +1,6 @@ # Makefile for ufs # -# Copyright (C) 1994,95,96,99,2000 Free Software Foundation, Inc. +# Copyright (C) 1994,95,96,99,2000,02 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 @@ -28,3 +28,5 @@ OBJS = $(SRCS:.c=.o) HURDLIBS = diskfs iohelp fshelp store pager threads ports ihash shouldbeinlibc include ../Makeconf + +ufs.static: $(boot-store-types:%=../libstore/libstore_%.a) -- cgit v1.2.3 From 4ea7077cd0bbe0fa90363323ab9b969652b2d1e5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 14 Mar 2002 21:11:48 +0000 Subject: . --- ufs/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index a655a739..b568623a 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +2002-03-11 Roland McGrath + + * Makefile (ufs.static): Depend on + $(boot-store-types:%=../libstore/libstore_%.a). + 2001-11-21 Roland McGrath * inode.c (read_disknode): Just always call getpid for the fsid value. -- cgit v1.2.3 From 267bd5c3ac1790e331aee4f73503f38e8df52f8c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 15 Mar 2002 09:51:54 +0000 Subject: 2002-03-15 Roland McGrath * configure.in: Remove the checks for libparted. Instead, check just for a static -lstore_part library and do that only if no --enable-boot-store-types option was given. * configure.in (boot_store_types): Add remap to the default list. --- configure.in | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/configure.in b/configure.in index 2b7b8f3e..9fdd7211 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.29 2002/03/12 03:01:02 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.30 2002/03/15 09:51:54 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -136,34 +136,29 @@ AC_ARG_WITH(parted, dnl [ --without-parted don't try to use GNU Parted libraries], , with_parted=yes) -# Check if we have the necessary stuff to build against GNU Parted libraries. -parted=$with_parted -save_LIBS= -LIBS= -test $parted = no || { - AC_CHECK_HEADER(parted/parted.h, - [AC_DEFINE(HAVE_PARTED_PARTED_H)], - parted=no) -} -test $parted = no || { - AC_CHECK_LIB(uuid, uuid_generate, , parted=no) -} -test $parted = no || { - AC_CHECK_LIB(parted, ped_device_read, , parted=no) -} -PARTED_LIBS=$LIBS -LIBS=$save_LIBS -AC_SUBST(PARTED_LIBS) - AC_ARG_ENABLE(boot-store-types, [ --enable-boot-store-types=TYPES... list of store types included in statically linked filesystems used for booting])dnl if test -z "$enable_boot_store_types"; then - boot_store_types='device gunzip bunzip2' - test $parted = no || boot_store_types="$boot_store_types part" + boot_store_types='device remap gunzip bunzip2' + + # Check for Parted's static store module. + if test "x$with_parted" != xno; then + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -static" + AC_CHECK_LIB(store_part, store_part_open, [dnl + boot_store_types="$boot_store_types part"], , -luuid -lstore) + LDFLAGS="$save_LDFLAGS" + fi +elif test "x$enable_boot_store_types" = xno; then + AC_MSG_WARN([you probably wanted --disable-static-progs]) +else + boot_store_types="$enable_boot_store_types" fi AC_SUBST(boot_store_types)dnl +AC_MSG_CHECKING(boot store types) +AC_MSG_RESULT($boot_store_types) if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. -- cgit v1.2.3 From d2b6eb374ad28580b1014986920c95c91a60f2a7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 24 Mar 2002 01:12:38 +0000 Subject: 2002-03-23 Roland McGrath Excised default pager functionality from serverboot. * Makefile (SRCS): Move def_pager_setup.c default_pager.c kalloc.c to (EXTRA_DIST): ... here. (OBJS): Remove *Server.o from here. (MIGSFLAGS): Variable removed. * bootstrap.c (main): Replace paging-file boot-script functions with a stub that prints an error. No longer call partition_init, default_pager_initialize, or default_pager. (default_pager_bootstrap_port): Variable removed. (main): Don't use it. (default_pager_exception_port): Declaration removed. (main): Don't use it. * default_pager.c (default_pager_bootstrap_port): Variable removed. (default_pager_demux_default): Don't use it. (default_pager_initialize): Likewise. (default_pager): Likewise. (do_bootstrap_privileged_ports, bootstrap_compat): Functions removed. [mips] (set_ras_address): Likewise. --- serverboot/Makefile | 15 +++++------ serverboot/bootstrap.c | 67 ++++++++------------------------------------------ 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/serverboot/Makefile b/serverboot/Makefile index c4d37430..967ca33f 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1997,99,2001 Free Software Foundation, Inc. +# 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 @@ -18,13 +18,14 @@ dir := serverboot makemode := utility -SRCS = bootstrap.c ffs_compat.c load.c wiring.c def_pager_setup.c \ - ffs_file_io.c minix_ffs_compat.c default_pager.c file_io.c\ - minix_file_io.c ext2_file_io.c kalloc.c strfcns.c exec.c \ +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) @@ -32,9 +33,7 @@ installationdir = $(bootdir) UNZIP_OBJS = unzip.o inflate.o util.o do-bunzip2.o OBJS = $(subst .c,.o,$(SRCS)) \ boot_script.o userland-boot.o \ - memory_objectServer.o \ - default_pagerServer.o excServer.o bootstrapServer.o \ - memory_object_defaultServer.o $(UNZIP_OBJS) + $(UNZIP_OBJS) vpath boot_script.c $(srcdir)/../boot vpath userland-boot.c $(srcdir)/../boot @@ -45,8 +44,6 @@ VPATH += $(srcdir)/../exec # It's crucial for serverboot, because swap is not enabled yet. CPPFLAGS += -I$(srcdir)/../exec -DGZIP -DBZIP2 -DSMALL_BZIP2 -MIGSFLAGS = -DSEQNOS - LDFLAGS += -static include ../Makeconf diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 3d298a5a..0b8b25a1 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -65,10 +65,6 @@ extern void default_pager(); extern void default_pager_initialize(); extern void default_pager_setup(); -/* initialized in default_pager_initialize */ -extern mach_port_t default_pager_exception_port; -extern mach_port_t default_pager_bootstrap_port; - /* * Convert ASCII to integer. */ @@ -153,25 +149,13 @@ main(argc, argv) char **argv; { int die = 0; - int script_paging_file (const struct cmd *cmd, int linux_signature) + int script_paging_file (const struct cmd *cmd, int *val) { - if (add_paging_file (bootstrap_master_device_port, cmd->path, - linux_signature)) - printf ("(serverboot): %s: Cannot add paging file\n", cmd->path); + 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_add_paging_file (const struct cmd *cmd, int *val) - { - return script_paging_file (cmd, 0); - } - int script_add_raw_paging_file (const struct cmd *cmd, int *val) - { - return script_paging_file (cmd, -1); - } - int script_add_linux_paging_file (const struct cmd *cmd, int *val) - { - return script_paging_file (cmd, 1); - } int script_serverboot_ctl (const struct cmd *cmd, int *val) { const char *const ctl = cmd->path; @@ -334,11 +318,6 @@ main(argc, argv) root_name[len] = 0; } - /* - * Set up the default pager. - */ - partition_init(); - { char *cmdline; @@ -352,12 +331,12 @@ main(argc, argv) || boot_script_set_variable ("boot-args", VAL_STR, (int) flag_string) || boot_script_define_function ("add-paging-file", VAL_NONE, - &script_add_paging_file) + &script_paging_file) || boot_script_define_function ("add-raw-paging-file", VAL_NONE, - &script_add_raw_paging_file) + &script_paging_file) || boot_script_define_function ("add-linux-paging-file", VAL_NONE, - &script_add_linux_paging_file) + &script_paging_file) || boot_script_define_function ("serverboot", VAL_NONE, &script_serverboot_ctl) @@ -382,22 +361,6 @@ main(argc, argv) safe_gets (xx, sizeof xx); } - /* - * task_set_exception_port and task_set_bootstrap_port - * both require a send right. - */ - (void) mach_port_insert_right(my_task, default_pager_bootstrap_port, - default_pager_bootstrap_port, - MACH_MSG_TYPE_MAKE_SEND); - (void) mach_port_insert_right(my_task, default_pager_exception_port, - default_pager_exception_port, - MACH_MSG_TYPE_MAKE_SEND); - - /* - * Change our exception port. - */ - (void) task_set_exception_port(my_task, default_pager_exception_port); - result = boot_script_exec (); if (result) @@ -440,19 +403,9 @@ main(argc, argv) } #endif - if (die) - { - printf ("(serverboot): terminating, not becoming default pager\n"); - while (1) - task_terminate (mach_task_self ()); - } - - default_pager_initialize (bootstrap_master_host_port); - - /* - * Become the default pager - */ - default_pager(); + printf ("(serverboot): terminating\n"); + while (1) + task_terminate (mach_task_self ()); /*NOTREACHED*/ } -- cgit v1.2.3 From 0c2db9c9b8dd0a16d8d6b88eae86dd01c2e3d9fe Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 24 Mar 2002 01:12:42 +0000 Subject: 2002-03-23 Roland McGrath Excised default pager functionality from serverboot. * Makefile (SRCS): Move def_pager_setup.c default_pager.c kalloc.c to (EXTRA_DIST): ... here. (OBJS): Remove *Server.o from here. (MIGSFLAGS): Variable removed. * bootstrap.c (main): Replace paging-file boot-script functions with a stub that prints an error. No longer call partition_init, default_pager_initialize, or default_pager. (default_pager_bootstrap_port): Variable removed. (main): Don't use it. (default_pager_exception_port): Declaration removed. (main): Don't use it. * default_pager.c (default_pager_bootstrap_port): Variable removed. (default_pager_demux_default): Don't use it. (default_pager_initialize): Likewise. (default_pager): Likewise. (do_bootstrap_privileged_ports, bootstrap_compat): Functions removed. [mips] (set_ras_address): Likewise. * default_pager.c (pager_truncate): New function. (struct dpager): New member `limit'. (pager_alloc): Initialize it. (default_pager_object_set_size): New function. (seqnos_memory_object_lock_completed): Rewritten, no longer a stub. (default_pager_demux_object): Try default_pager_server too. --- serverboot/default_pager.c | 346 ++++++++++++++++++++++++++------------------- 1 file changed, 203 insertions(+), 143 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index a7625447..be6b13be 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -651,6 +651,7 @@ struct dpager { #endif 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 */ p_index_t cur_partition; #ifdef CHECKSUM vm_offset_t *checksum; /* checksum - parallel to block map */ @@ -739,6 +740,7 @@ pager_alloc(pager, part, size) } pager->map = mapptr; pager->size = size; + pager->limit = (vm_size_t)-1; #ifdef CHECKSUM if (INDIRECT_PAGEMAP(size)) { @@ -913,11 +915,13 @@ pager_extend(pager, new_size) pager->writer = FALSE; #endif mutex_unlock(&pager->lock); +#if 0 ddprintf ("pager_extend 1 mapptr %x [3b] = %x\n", new_mapptr, new_mapptr[0x3b]); if (new_mapptr[0x3b].indirect > 0x10000 && new_mapptr[0x3b].indirect != NO_BLOCK) panic ("debug panic"); +#endif return; } @@ -941,11 +945,13 @@ pager_extend(pager, new_size) kfree((char *)old_mapptr, PAGEMAP_SIZE(old_size)); old_mapptr = new_mapptr; +#if 0 ddprintf ("pager_extend 2 mapptr %x [3b] = %x\n", new_mapptr, new_mapptr[0x3b]); if (new_mapptr[0x3b].indirect > 0x10000 && new_mapptr[0x3b].indirect != NO_BLOCK) panic ("debug panic"); +#endif /* * Now allocate indirect map. @@ -1015,6 +1021,110 @@ pager_extend(pager, new_size) mutex_unlock(&pager->lock); } +/* Truncate a memory object. First, any pages between the new size + and the (larger) old size are deallocated. Then, the size of + the pagemap may be reduced, an indirect map may be turned into + a direct map. + + The pager must be locked by the caller. */ +static void +pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */ +{ + dp_map_t new_mapptr; + dp_map_t old_mapptr; + int i; + vm_size_t old_size; + + /* This deallocates the pages necessary to truncate a direct map + previously of size NEW_SIZE to the smaller size OLD_SIZE. */ + inline void dealloc_direct (dp_map_t mapptr, + vm_size_t old_size, vm_size_t new_size) + { + vm_size_t i; + 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]); + } + } + + old_size = pager->size; + + if (INDIRECT_PAGEMAP(old_size)) + { + /* First handle the entire second-levels blocks that are being freed. */ + for (i = INDIRECT_PAGEMAP_ENTRIES(new_size); + i < INDIRECT_PAGEMAP_ENTRIES(old_size); + ++i) + { + const dp_map_t mapptr = pager->map[i].indirect; + pager->map[i].indirect = (dp_map_t)0; + dealloc_direct (mapptr, PAGEMAP_ENTRIES, 0); + kfree ((char *)mapptr, PAGEMAP_SIZE(PAGEMAP_ENTRIES)); + } + + /* Now truncate what's now the final nonempty direct block. */ + dealloc_direct (pager->map[(new_size - 1) / PAGEMAP_ENTRIES].indirect, + old_size & (PAGEMAP_ENTRIES - 1), + new_size & (PAGEMAP_ENTRIES - 1)); + + 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)); + } + } + else + { + /* We are truncating to a size small enough that it goes to using + a one-level map. We already have that map, as the first and only + nonempty element in our indirect map. */ + 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. */ + dealloc_direct (pager->map, old_size, new_size); + /* Now reduce the size of the direct map itself. We don't bother + with kalloc/kfree if it's not shrinking enough that kalloc.c + would actually use less. */ + if (PAGEMAP_SIZE (new_size) <= PAGEMAP_SIZE (old_size) / 2) + { + 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)); + kfree ((char *) old_mapptr, PAGEMAP_SIZE (old_size)); + } + } + + pager->size = new_size; + +#ifdef CHECKSUM +#error write me +#endif /* CHECKSUM */ +} + + /* * Given an offset within a paging object, find the * corresponding block within the paging partition. @@ -1709,7 +1819,6 @@ default_has_page(ds, offset) { return ( ! no_block(pager_read_offset(ds, offset)) ); } - /* */ @@ -1737,6 +1846,10 @@ struct dstruct { unsigned int readers; /* Reads in progress */ unsigned int writers; /* Writes in progress */ + /* This is the reply port of an outstanding + default_pager_object_set_size call. */ + mach_port_t lock_request; + unsigned int errors; /* Pageout error count */ struct dpager dpager; /* Actual pager */ }; @@ -2069,8 +2182,6 @@ mach_port_t default_pager_default_port; /* Port for memory_object_create. */ /* We catch exceptions on ourself & startup using this port. */ mach_port_t default_pager_exception_port; -/* We receive bootstrap requests on this port. */ -mach_port_t default_pager_bootstrap_port; mach_port_t default_pager_internal_set; /* Port set for internal objects. */ mach_port_t default_pager_external_set; /* Port set for external objects. */ @@ -2537,9 +2648,12 @@ ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_unlock: <%p>[s:%d, goto done; } - rc = default_read(&ds->dpager, dpt->dpt_buffer, - vm_page_size, offset, - &addr, protection_required & VM_PROT_WRITE); + if (offset >= ds->dpager.limit) + rc = PAGER_ERROR; + else + rc = default_read(&ds->dpager, dpt->dpt_buffer, + vm_page_size, offset, + &addr, protection_required & VM_PROT_WRITE); switch (rc) { case PAGER_SUCCESS: @@ -2762,21 +2876,39 @@ seqnos_memory_object_copy(old_memory_object, seqno, old_memory_control, return KERN_FAILURE; } +/* We get this when our memory_object_lock_request has completed + after we truncated an object. */ kern_return_t -seqnos_memory_object_lock_completed(pager, seqno, pager_request, - offset, length) - memory_object_t pager; - mach_port_seqno_t seqno; - mach_port_t pager_request; - vm_offset_t offset; - vm_size_t length; +seqnos_memory_object_lock_completed (memory_object_t pager, + mach_port_seqno_t seqno, + mach_port_t pager_request, + vm_offset_t offset, + vm_size_t length) { -#ifdef lint - pager++; seqno++; pager_request++; offset++; length++; -#endif /* lint */ + default_pager_t ds; - panic("%slock_completed",my_name); - return(KERN_FAILURE); + 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; } kern_return_t @@ -2897,7 +3029,8 @@ ddprintf ("DPAGER DEMUX OBJECT <%p>: %d\n", in, in->msgh_id); rval = (seqnos_memory_object_server(in, out) || seqnos_memory_object_default_server(in, out) || - default_pager_notify_server(in, out)); + default_pager_notify_server(in, out) || + default_pager_server(in, out)); ddprintf ("DPAGER DEMUX OBJECT DONE <%p>: %d\n", in, in->msgh_id); return rval; } @@ -2929,20 +3062,6 @@ return rval; */ return exc_server(in, out); - } else if (in->msgh_local_port == default_pager_bootstrap_port) { - /* - * We receive bootstrap requests - * from the startup task. - */ - - if (in->msgh_id == 999999) { - /* compatibility for old bootstrap interface */ - - bootstrap_compat(in, out); - return TRUE; - } - - return bootstrap_server(in, out); } else { panic(my_name); return FALSE; @@ -3086,14 +3205,6 @@ default_pager_initialize(host_port) if (kr != KERN_SUCCESS) panic(my_name); - /* - * Initialize the bootstrap port. - */ - kr = mach_port_allocate(default_pager_self, MACH_PORT_RIGHT_RECEIVE, - &default_pager_bootstrap_port); - if (kr != KERN_SUCCESS) - panic(my_name); - /* * Arrange for wiring privileges. */ @@ -3169,12 +3280,6 @@ default_pager() if (kr != KERN_SUCCESS) panic(my_name); - kr = mach_port_move_member(default_pager_self, - default_pager_bootstrap_port, - default_pager_default_set); - if (kr != KERN_SUCCESS) - panic(my_name); - /* * Now we create the threads that will actually * manage objects. @@ -3600,6 +3705,57 @@ default_pager_object_pages(pager, object, pagesp, countp) return KERN_SUCCESS; } + +kern_return_t +default_pager_object_set_size(mach_port_t pager, + mach_port_seqno_t seqno, + mach_port_t reply_to, + vm_size_t limit) +{ + kern_return_t kr; + default_pager_t ds; + + ds = pager_port_lookup(pager); + if (ds == DEFAULT_PAGER_NULL) + 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) + { + /* 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); + if (kr != KERN_SUCCESS) + panic ("memory_object_lock_request: %d", kr); + ds->lock_request = reply_to; + kr = MIG_NO_REPLY; + } + else + /* There is already another call in progress. Tough titties. */ + kr = KERN_FAILURE; + + pager_port_unlock(ds, seqno); + + return kr; +} + /* * Add/remove extra paging space */ @@ -3747,99 +3903,3 @@ catch_exception_raise(exception_port, thread, task, exception, code, subcode) return KERN_FAILURE; } - -/* - * Handle bootstrap requests. - */ - -kern_return_t -do_bootstrap_privileged_ports(bootstrap, hostp, devicep) - mach_port_t bootstrap; - mach_port_t *hostp, *devicep; -{ - *hostp = bootstrap_master_host_port; - *devicep = bootstrap_master_device_port; - return KERN_SUCCESS; -} - -void -bootstrap_compat(in, out) - mach_msg_header_t *in, *out; -{ - mig_reply_header_t *reply = (mig_reply_header_t *) out; - mach_msg_return_t mr; - - struct imsg { - mach_msg_header_t hdr; - mach_msg_type_t port_desc_1; - mach_port_t port_1; - mach_msg_type_t port_desc_2; - mach_port_t port_2; - } imsg; - - /* - * Send back the host and device ports. - */ - - imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | - MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); - /* msgh_size doesn't need to be initialized */ - imsg.hdr.msgh_remote_port = in->msgh_remote_port; - imsg.hdr.msgh_local_port = MACH_PORT_NULL; - /* msgh_seqno doesn't need to be initialized */ - imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ - - imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; - imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); - imsg.port_desc_1.msgt_number = 1; - imsg.port_desc_1.msgt_inline = TRUE; - imsg.port_desc_1.msgt_longform = FALSE; - imsg.port_desc_1.msgt_deallocate = FALSE; - imsg.port_desc_1.msgt_unused = 0; - - imsg.port_1 = bootstrap_master_host_port; - - imsg.port_desc_2 = imsg.port_desc_1; - - imsg.port_2 = bootstrap_master_device_port; - - /* - * Send the reply message. - * (mach_msg_server can not do this, because the reply - * is not in standard format.) - */ - - mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, - sizeof imsg, 0, MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - if (mr != MACH_MSG_SUCCESS) - (void) mach_port_deallocate(default_pager_self, - imsg.hdr.msgh_remote_port); - - /* - * Tell mach_msg_server to do nothing. - */ - - reply->RetCode = MIG_NO_REPLY; -} - -#ifdef mips -/* - * set_ras_address for default pager - * Default pager does not have emulator support - * so it needs a local version of set_ras_address. - */ -int -set_ras_address(basepc, boundspc) - vm_offset_t basepc; - vm_offset_t boundspc; -{ - kern_return_t status; - - status = task_ras_control(mach_task_self(), basepc, boundspc, - TASK_RAS_CONTROL_INSTALL_ONE); - if (status != KERN_SUCCESS) - return -1; - return 0; -} -#endif -- cgit v1.2.3 From 39e9fc5f44081ab7948f16ecd4b8a6b40c000d4d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 24 Mar 2002 01:14:58 +0000 Subject: . --- serverboot/ChangeLog | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 0647abeb..6c33ebb1 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,31 @@ +2002-03-23 Roland McGrath + + Excised default pager functionality from serverboot. + * Makefile (SRCS): Move def_pager_setup.c default_pager.c kalloc.c to + (EXTRA_DIST): ... here. + (OBJS): Remove *Server.o from here. + (MIGSFLAGS): Variable removed. + * bootstrap.c (main): Replace paging-file boot-script functions with a + stub that prints an error. No longer call partition_init, + default_pager_initialize, or default_pager. + (default_pager_bootstrap_port): Variable removed. + (main): Don't use it. + (default_pager_exception_port): Declaration removed. + (main): Don't use it. + * default_pager.c (default_pager_bootstrap_port): Variable removed. + (default_pager_demux_default): Don't use it. + (default_pager_initialize): Likewise. + (default_pager): Likewise. + (do_bootstrap_privileged_ports, bootstrap_compat): Functions removed. + [mips] (set_ras_address): Likewise. + + * default_pager.c (pager_truncate): New function. + (struct dpager): New member `limit'. + (pager_alloc): Initialize it. + (default_pager_object_set_size): New function. + (seqnos_memory_object_lock_completed): Rewritten, no longer a stub. + (default_pager_demux_object): Try default_pager_server too. + 2001-11-24 Roland McGrath * Makefile (installationdir): Use $(bootdir). -- cgit v1.2.3 From cc3e076ee4848c8720dcfac332a88beab6533ac1 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 18 Apr 2002 13:23:11 +0000 Subject: Update for new Debian package. --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index c273e920..228e2a86 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +hurd (20020418-1) unstable; urgency=low + + * New snapshot from CVS. + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Thu, 18 Apr 2002 15:22:39 +0200 + hurd (20011105-1) unstable; urgency=low * New snapshot from CVS. -- cgit v1.2.3 From c401a34f0106f6b18eca8952a0ab04d77f2e1724 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 23 Apr 2002 02:23:09 +0000 Subject: We have no use for this file. See copyright.list on GNU central. --- assigns | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 assigns diff --git a/assigns b/assigns deleted file mode 100644 index ec8083c1..00000000 --- a/assigns +++ /dev/null @@ -1,4 +0,0 @@ -HURD Mark Kettenis Netherlands 1973 1999-03-11 -Assigns past and future changes (trans/password.c, pfinet/ethernet.c, -pfinet/options.c, minor revisions throughout). -kettenis@gnu.org, kettenis@wins.uva.nl -- cgit v1.2.3 From bbadb23926a1f873777e9a48da93934c1f94d0b9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 3 May 2002 22:58:09 +0000 Subject: 2002-04-27 Roland McGrath * configure.in: Match $host_cpu of powerpc*, not just powerpc. Match $host_cpu of alpha* to set asm_syntax=alpha. --- configure.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 9fdd7211..3603403f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.30 2002/03/15 09:51:54 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.31 2002/05/03 22:58:09 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -20,10 +20,13 @@ none) AC_MSG_ERROR([ esac case "$host_cpu" in +alpha*) + asm_syntax=alpha + ;; i?86) asm_syntax=i386 ;; -powerpc) +powerpc*) asm_syntax=ppc ;; *) -- cgit v1.2.3 From 1786d6362ca651fbbb84668ac3b9c87eb4056c02 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 8 May 2002 09:29:40 +0000 Subject: 2002-05-07 Roland McGrath * default_pager.c (part_id): Add const to argument type. --- serverboot/default_pager.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index be6b13be..f0cb4d49 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -142,8 +142,7 @@ void set_partition_of(x, p) * Saves space, filenames can be long. */ unsigned int -part_id(name) - unsigned char *name; +part_id(const unsigned char *name) { register unsigned int len, id, xorid; -- cgit v1.2.3 From 3c965cc61e14f1d5956b3a13def48a2b40a1db39 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 8 May 2002 09:32:17 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 6c33ebb1..2026a1d4 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2002-05-07 Roland McGrath + + * default_pager.c (part_id): Add const to argument type. + 2002-03-23 Roland McGrath Excised default pager functionality from serverboot. -- cgit v1.2.3 From ec432c9be247ee138cfce70b1d4aa3ada5090aad Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 8 May 2002 09:59:52 +0000 Subject: 2002-05-08 Roland McGrath * main.c (diskfs_append_args): Fix argument type. (main): Use %z format modifier for size_t arg. * dir.c (dirscanblock): Use %z format modifier for vm_address_t arg. (diskfs_dirempty): int -> vm_address_t (count_dirents): int -> size_t (diskfs_get_directs): u_int -> size_t --- ufs/dir.c | 13 ++++++------- ufs/main.c | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 7880ca21..3256bc42 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,5 @@ /* Directory management routines - Copyright (C) 1994,95,96,97,98,99,2000 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,98,99,2000,02 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 @@ -379,7 +379,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, || DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen) || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { - fprintf (stderr, "Bad directory entry: inode: %d offset: %d\n", + fprintf (stderr, "Bad directory entry: inode: %d offset: %zd\n", dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ); return ENOENT; } @@ -729,8 +729,7 @@ diskfs_dirempty(struct node *dp, struct protid *cred) { struct directory_entry *entry; - int curoff; - vm_address_t buf; + vm_address_t buf, curoff; memory_object_t memobj; error_t err; @@ -798,7 +797,7 @@ diskfs_drop_dirstat (struct node *dp, struct dirstat *ds) static error_t count_dirents (struct node *dp, int nb, char *buf) { - int amt; + size_t amt; char *offinblk; struct directory_entry *entry; int count = 0; @@ -833,7 +832,7 @@ diskfs_get_directs (struct node *dp, int entry, int nentries, char **data, - u_int *datacnt, + size_t *datacnt, vm_size_t bufsiz, int *amt) { @@ -848,7 +847,7 @@ diskfs_get_directs (struct node *dp, char *datap; struct directory_entry *entryp; int allocsize; - int checklen; + size_t checklen; struct dirent *userp; nblks = dp->dn_stat.st_size/DIRBLKSIZ; diff --git a/ufs/main.c b/ufs/main.c index 8c79d707..242107f4 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994,95,96,97,98,99 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,98,99,2002 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 @@ -136,7 +136,7 @@ struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; /* Override the standard diskfs routine so we can add our own output. */ error_t -diskfs_append_args (char **argz, unsigned *argz_len) +diskfs_append_args (char **argz, size_t *argz_len) { error_t err; @@ -166,7 +166,7 @@ main (int argc, char **argv) &store_parsed, &bootstrap); if (store->block_size > DEV_BSIZE) - error (4, 0, "%s: Bad device block size %d (should be <= %d)", + error (4, 0, "%s: Bad device block size %zd (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); if (store->size < SBSIZE + SBOFF) error (5, 0, "%s: Disk too small (%Ld bytes)", diskfs_disk_name, -- cgit v1.2.3 From 287caf2227a7432a3b4a3adaf7c7a85c120df4f4 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 8 May 2002 10:00:26 +0000 Subject: . --- ufs/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index b568623a..f0192426 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,12 @@ +2002-05-08 Roland McGrath + + * main.c (diskfs_append_args): Fix argument type. + (main): Use %z format modifier for size_t arg. + * dir.c (dirscanblock): Use %z format modifier for vm_address_t arg. + (diskfs_dirempty): int -> vm_address_t + (count_dirents): int -> size_t + (diskfs_get_directs): u_int -> size_t + 2002-03-11 Roland McGrath * Makefile (ufs.static): Depend on -- cgit v1.2.3 From a3822430ff8a34f83156290f4a6787f1c3b634d6 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 13 May 2002 12:59:10 +0000 Subject: 2002-05-13 Marcus Brinkmann * rules (INFODIR): Move to /share. * postinst: Likewise. Submitted by Guillem Jover , Closes: #146797. --- debian/ChangeLog | 6 ++++++ debian/postinst | 2 +- debian/rules | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 03058e9b..58865338 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,9 @@ +2002-05-13 Marcus Brinkmann + + * rules (INFODIR): Move to /share. + * postinst: Likewise. + Submitted by Guillem Jover , Closes: #146797. + 2002-01-28 Marcus Brinkmann * copyright: Remove Linuxism. diff --git a/debian/postinst b/debian/postinst index 89c26bec..05e30d3e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -16,7 +16,7 @@ set -e # Install info files into the dir file. -install-info --quiet --section "Hurd" "The Hurd" /usr/info/hurd.info.gz +install-info --quiet --section "Hurd" "The Hurd" /usr/share/info/hurd.info.gz # Manage alternatives. diff --git a/debian/rules b/debian/rules index 2a657ca9..fb0e3971 100755 --- a/debian/rules +++ b/debian/rules @@ -27,7 +27,7 @@ LDFLAGS = -s PREFIX = /usr BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man -INFODIR = $(PREFIX)/info +INFODIR = $(PREFIX)/share/info DOCDIR = $(PREFIX)/share/doc/$(package) # Package specific stuff. The idea is to try to make the rules -- cgit v1.2.3 From 515f42fd241cfe13ccbbd58f065a44c2cb6b1857 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 May 2002 21:30:47 +0000 Subject: 2002-05-16 Roland McGrath * configure.in (asm_syntax): Add patterns for all the flavors we have pfinet/linux-src/include/asm-* directories for: arm, m68k, mips, sparc, sparc64. --- configure.in | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 3603403f..c5cd14cd 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.31 2002/05/03 22:58:09 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.32 2002/05/18 21:30:47 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -23,12 +23,27 @@ case "$host_cpu" in alpha*) asm_syntax=alpha ;; +arm*) + asm_syntax=arm + ;; +m68k | m680?0) + asm_syntax=m68k + ;; +mips*) + asm_syntax=mips + ;; i?86) asm_syntax=i386 ;; powerpc*) asm_syntax=ppc ;; +sparc64* | ultrasparc*) + asm_syntax=sparc64 + ;; +sparc*) + asm_syntax=sparc + ;; *) asm_syntax="$host_cpu" ;; -- cgit v1.2.3 From 2b49f591e608962a852b173f5b7af80e45cd5397 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 23 May 2002 13:17:23 +0000 Subject: libstore/ 2002-05-20 Ognyan Kulev * Makefile: Move inclusion of ../Makeconf before using $(srcdir). serverboot/ 2002-05-20 Ognyan Kulev * Makefile: Move inclusion of ../Makeconf before using $(srcdir) and constrain vpath directives to avoid using ../exec/exec.o. --- serverboot/ChangeLog | 5 +++++ serverboot/Makefile | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 2026a1d4..6feacd03 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +2002-05-20 Ognyan Kulev + + * Makefile: Move inclusion of ../Makeconf before using $(srcdir) + and constrain vpath directives to avoid using ../exec/exec.o. + 2002-05-07 Roland McGrath * default_pager.c (part_id): Add const to argument type. diff --git a/serverboot/Makefile b/serverboot/Makefile index 967ca33f..7f66f45a 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -19,7 +19,7 @@ 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\ + 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 \ @@ -35,18 +35,18 @@ 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 += $(srcdir)/../exec +vpath %.c $(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 -include ../Makeconf - # Don't even bother. CFLAGS := $(filter-out -Wall,$(CFLAGS)) -- cgit v1.2.3 From 93c174ecf50f081ac981421bad7186ab5d56d58d Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 23 May 2002 13:30:47 +0000 Subject: 2002-05-23 Marcus Brinkmann * control (Provides, Replaces, Conflicts): Add fakeroot. * changelog: Update for Debian package. --- debian/ChangeLog | 5 +++++ debian/changelog | 8 ++++++++ debian/control | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 58865338..944aa50d 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +2002-05-23 Marcus Brinkmann + + * control (Provides, Replaces, Conflicts): Add fakeroot. + * changelog: Update for Debian package. + 2002-05-13 Marcus Brinkmann * rules (INFODIR): Move to /share. diff --git a/debian/changelog b/debian/changelog index 228e2a86..d9db077e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +hurd (20020523-1) unstable; urgency=low + + * New snapshot from CVS. + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Thu, 23 May 2002 15:29:40 +0200 + hurd (20020418-1) unstable; urgency=low * New snapshot from CVS. diff --git a/debian/control b/debian/control index 5c56e84f..3a5ed37d 100644 --- a/debian/control +++ b/debian/control @@ -10,9 +10,9 @@ Priority: required Section: base Essential: yes Depends: ${hurd:Depends} -Provides: makedev, login -Replaces: makedev, login -Conflicts: makedev, login +Provides: makedev, login, fakeroot +Replaces: makedev, login, fakeroot +Conflicts: makedev, login, fakeroot Architecture: hurd-i386 Description: The GNU Hurd This is the GNU Hurd package. It contains essential system software and -- cgit v1.2.3 From 6dfb85a075998483bdd93a189c3d7fd1d859dcec Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 23 May 2002 17:40:40 +0000 Subject: 2002-05-23 Marcus Brinkmann * Makefile: Fix last change, constraining vpath even further. --- serverboot/ChangeLog | 4 ++++ serverboot/Makefile | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 6feacd03..9acad23e 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2002-05-23 Marcus Brinkmann + + * Makefile: Fix last change, constraining vpath even further. + 2002-05-20 Ognyan Kulev * Makefile: Move inclusion of ../Makeconf before using $(srcdir) diff --git a/serverboot/Makefile b/serverboot/Makefile index 7f66f45a..454b228f 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -41,7 +41,11 @@ vpath boot_script.c $(srcdir)/../boot vpath userland-boot.c $(srcdir)/../boot # Look for zip stuff -vpath %.c $(srcdir)/../exec +vpath unzip.c $(srcdir)/../exec +vpath inflate.c $(srcdir)/../exec +vpath util.c $(srcdir)/../exec +vpath do-bunzip2.c $(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 -- cgit v1.2.3 From a58c7cccf74c865a66a4d8a9c49629bab7fd912f Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 23 May 2002 21:44:51 +0000 Subject: 2002-05-23 Marcus Brinkmann * Makefile: Fix last change properly, by relaxing the rule again and adding our source dir before the exec dir. --- serverboot/ChangeLog | 5 +++++ serverboot/Makefile | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 9acad23e..1013cf83 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,8 @@ +2002-05-23 Marcus Brinkmann + + * Makefile: Fix last change properly, by relaxing the rule again + and adding our source dir before the exec dir. + 2002-05-23 Marcus Brinkmann * Makefile: Fix last change, constraining vpath even further. diff --git a/serverboot/Makefile b/serverboot/Makefile index 454b228f..653d5963 100644 --- a/serverboot/Makefile +++ b/serverboot/Makefile @@ -41,10 +41,7 @@ vpath boot_script.c $(srcdir)/../boot vpath userland-boot.c $(srcdir)/../boot # Look for zip stuff -vpath unzip.c $(srcdir)/../exec -vpath inflate.c $(srcdir)/../exec -vpath util.c $(srcdir)/../exec -vpath do-bunzip2.c $(srcdir)/../exec +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. -- cgit v1.2.3 From 1a457446a0bf7e70d59db846ba748c7595c7e17c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 Jun 2002 21:46:22 +0000 Subject: 2002-05-29 Roland McGrath * bootstrap.c (main): int -> integer_t for boot_script values. --- serverboot/bootstrap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 0b8b25a1..64f7c5eb 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -149,14 +149,14 @@ main(argc, argv) char **argv; { int die = 0; - int script_paging_file (const struct cmd *cmd, int *val) + 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, int *val) + int script_serverboot_ctl (const struct cmd *cmd, integer_t *val) { const char *const ctl = cmd->path; if (!strcmp (ctl, "die")) @@ -323,13 +323,13 @@ main(argc, argv) /* Initialize boot script variables. */ if (boot_script_set_variable ("host-port", VAL_PORT, - (int) bootstrap_master_host_port) + (integer_t) bootstrap_master_host_port) || boot_script_set_variable ("device-port", VAL_PORT, - (int) bootstrap_master_device_port) + (integer_t) bootstrap_master_device_port) || boot_script_set_variable ("root-device", VAL_STR, - (int) root_name) + (integer_t) root_name) || boot_script_set_variable ("boot-args", VAL_STR, - (int) flag_string) + (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, @@ -347,7 +347,7 @@ main(argc, argv) if (cmdline != NULL && boot_script_set_variable ("kernel-command-line", VAL_STR, - (int) cmdline)) + (integer_t) cmdline)) panic ("bootstrap: error setting boot script variables"); parse_script (&scriptf); -- cgit v1.2.3 From 890adb45a2f7f2abf357af3f36e6a88a99a9c7bc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 2 Jun 2002 21:46:57 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 1013cf83..602b3454 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2002-05-29 Roland McGrath + + * bootstrap.c (main): int -> integer_t for boot_script values. + 2002-05-23 Marcus Brinkmann * Makefile: Fix last change properly, by relaxing the rule again -- cgit v1.2.3 From 155165974f8fbe5d448345e939792c5b30a20882 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:40:58 +0000 Subject: 2002-06-08 Roland McGrath * dir.c (diskfs_direnter_hard): Use size_t for OLDSIZE. Fail with EOVERFLOW when it would exceed that width. * alloc.c, dir.c: Use %Ld format for ino_t values. * alloc.c (diskfs_alloc_node): Use %Ld format for blkcnt_t values. --- ufs/dir.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 3256bc42..b67e45f6 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -379,7 +379,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, || DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen) || memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry))) { - fprintf (stderr, "Bad directory entry: inode: %d offset: %zd\n", + fprintf (stderr, "Bad directory entry: inode: %Ld offset: %zd\n", dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ); return ENOENT; } @@ -502,7 +502,7 @@ diskfs_direnter_hard(struct node *dp, vm_address_t fromoff, tooff; int totfreed; error_t err; - off_t oldsize = 0; + size_t oldsize = 0; assert (ds->type == CREATE); @@ -585,6 +585,12 @@ diskfs_direnter_hard(struct node *dp, assert (needed <= DIRBLKSIZ); oldsize = dp->dn_stat.st_size; + if ((off_t)(oldsize + DIRBLKSIZ) != dp->dn_stat.st_size) + { + /* We can't possibly map the whole directory in. */ + munmap ((caddr_t) ds->mapbuf, ds->mapextent); + return EOVERFLOW; + } while (oldsize + DIRBLKSIZ > dp->allocsize) { err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred); -- cgit v1.2.3 From 0df695e2e07f18089ce49a5bc728dc8643ed871e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:41:03 +0000 Subject: 2002-06-08 Roland McGrath * alloc.c, dir.c: Use %Ld format for ino_t values. * alloc.c (diskfs_alloc_node): Use %Ld format for blkcnt_t values. --- ufs/alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ufs/alloc.c b/ufs/alloc.c index e76b7703..48ee60cc 100644 --- a/ufs/alloc.c +++ b/ufs/alloc.c @@ -1,5 +1,5 @@ /* Disk allocation routines - Copyright (C) 1993, 94, 95, 96, 98 Free Software Foundation, Inc. + Copyright (C) 1993,94,95,96,98,2002 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -685,7 +685,7 @@ diskfs_alloc_node (struct node *dir, assert ("duplicate allocation" && !np->dn_stat.st_mode); assert (! (np->dn_stat.st_mode & S_IPTRANS)); if (np->dn_stat.st_blocks) { - printf("free inode %d had %ld blocks\n", + printf("free inode %Ld had %Ld blocks\n", ino, np->dn_stat.st_blocks); np->dn_stat.st_blocks = 0; np->dn_set_ctime = 1; @@ -1395,7 +1395,7 @@ ffs_blkfree(register struct node *np, assert ((u_int)size <= fs->fs_bsize && !fragoff (fs, size)); cg = dtog(fs, bno); if ((u_int)bno >= fs->fs_size) { - printf("bad block %ld, ino %d\n", bno, np->dn->number); + printf("bad block %ld, ino %Ld\n", bno, np->dn->number); /* ffs_fserr(fs, ip->i_uid, "bad block"); */ return; } @@ -1518,7 +1518,7 @@ diskfs_free_node (struct node *np, mode_t mode) cgp->cg_time = diskfs_mtime->seconds; ino %= fs->fs_ipg; if (isclr(cg_inosused(cgp), ino)) { -/* printf("dev = 0x%x, ino = %d, fs = %s\n", +/* printf("dev = 0x%x, ino = %Ld, fs = %s\n", pip->i_dev, ino, fs->fs_fsmnt); */ assert (diskfs_readonly); } -- cgit v1.2.3 From 0b6e196e43b7d496615d30d077df313e6642256c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:41:06 +0000 Subject: 2002-06-08 Roland McGrath * inode.c (diskfs_cached_lookup): Use ino_t for argument. --- ufs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs/inode.c b/ufs/inode.c index a258ea13..a8bb661f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,5 @@ /* Inode management routines - Copyright (C) 1994,95,96,97,98,2000,01 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,97,98,2000,01,02 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 @@ -47,7 +47,7 @@ inode_init () /* Fetch inode INUM, set *NPP to the node structure; gain one user reference and lock the node. */ error_t -diskfs_cached_lookup (int inum, struct node **npp) +diskfs_cached_lookup (ino_t inum, struct node **npp) { struct disknode *dn; struct node *np; -- cgit v1.2.3 From e735b3cd2a3e630eb215081784c53825c88cedd7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:41:14 +0000 Subject: 2002-06-08 Roland McGrath * dir.c, pass1.c, pass2.c, utilities.c: Use %Ld for ino_t values. --- ufs-fsck/dir.c | 98 ++++++++++++++++++++++++++-------------------------- ufs-fsck/pass1.c | 78 ++++++++++++++++++++--------------------- ufs-fsck/pass2.c | 49 +++++++++++++------------- ufs-fsck/utilities.c | 6 ++-- 4 files changed, 114 insertions(+), 117 deletions(-) diff --git a/ufs-fsck/dir.c b/ufs-fsck/dir.c index 04541c4f..85757b16 100644 --- a/ufs-fsck/dir.c +++ b/ufs-fsck/dir.c @@ -1,5 +1,5 @@ /* Directory management subroutines - Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. + Copyright (C) 1994,96,99,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -28,19 +28,19 @@ record_directory (struct dinode *dp, ino_t number) { u_int blks; struct dirinfo *dnp; - + blks = howmany (dp->di_size, sblock->fs_bsize); if (blks > NDADDR) blks = NDADDR + NIADDR; blks *= sizeof (daddr_t); dnp = malloc (sizeof (struct dirinfo) + blks); - + dnp->i_number = number; dnp->i_parent = dnp->i_dotdot = 0; dnp->i_isize = dp->di_size; dnp->i_numblks = blks; bcopy (dp->di_db, dnp->i_blks, blks); - + if (dirarrayused == dirarraysize) { if (dirarraysize == 0) @@ -68,12 +68,12 @@ struct dirinfo * lookup_directory (ino_t ino) { int i; - + for (i = 0; i < dirarrayused; i++) if (dirarray[i]->i_number == ino) return dirarray[i]; - - errexit ("Cannot find chached directory I=%d\n", ino); + + errexit ("Cannot find cached directory I=%Ld\n", ino); } /* Check to see if DIR is really a readable directory; if it @@ -87,23 +87,23 @@ validdir (ino_t dir, char *action) case DIRECTORY: case DIRECTORY|DIR_REF: return 1; - + case UNALLOC: - warning (1, "CANNOT %s I=%d; NOT ALLOCATED", action, dir); + warning (1, "CANNOT %s I=%Ld; NOT ALLOCATED", action, dir); return 0; - + case BADDIR: - warning (1, "CANNOT %s I=%d; BAD BLOCKS", action, dir); + warning (1, "CANNOT %s I=%Ld; BAD BLOCKS", action, dir); return 0; - + case REG: - warning (1, "CANNOT %s I=%d; NOT DIRECTORY", action, dir); + warning (1, "CANNOT %s I=%Ld; NOT DIRECTORY", action, dir); return 0; default: errexit ("ILLEGAL STATE"); } -} +} /* Search directory DIR for name NAME. If NAME is found, then set *INO to the inode of the entry; otherwise clear INO. Returns 1 if all @@ -114,7 +114,7 @@ searchdir (ino_t dir, char *name, ino_t *ino) struct dinode dino; int len; - /* Scan through one directory block and see if it + /* Scan through one directory block and see if it contains NAME. */ void check1block (void *buf) @@ -147,7 +147,7 @@ searchdir (ino_t dir, char *name, ino_t *ino) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; - + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize @@ -160,7 +160,7 @@ searchdir (ino_t dir, char *name, ino_t *ino) } return 1; } - + *ino = 0; if (!validdir (dir, "READ")) @@ -220,7 +220,7 @@ changeino (ino_t dir, char *name, ino_t ino) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; - + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize @@ -236,10 +236,10 @@ changeino (ino_t dir, char *name, ino_t ino) } return 1; } - + if (!validdir (dir, "REWRITE")) return 0; - + getinode (dir, &dino); len = strlen (name); madechange = 0; @@ -254,7 +254,7 @@ expanddir (struct dinode *dp) { daddr_t lastbn, newblk; char *cp, buf[sblock->fs_bsize]; - + lastbn = lblkno (sblock, dp->di_size); if (blkoff (sblock, dp->di_size) && lastbn >= NDADDR - 1) return 0; @@ -264,24 +264,24 @@ expanddir (struct dinode *dp) return 0; else if (!blkoff (sblock, dp->di_size) && dp->di_db[lastbn]) return 0; - + newblk = allocblk (sblock->fs_frag); if (!newblk) return 0; - + if (blkoff (sblock, dp->di_size)) dp->di_db[lastbn + 1] = dp->di_db[lastbn]; dp->di_db[lastbn] = newblk; dp->di_size += sblock->fs_bsize; dp->di_blocks += sblock->fs_bsize / DEV_BSIZE; - + for (cp = buf; cp < buf + sblock->fs_bsize; cp += DIRBLKSIZ) { struct directory_entry *dir = (struct directory_entry *) cp; dir->d_ino = 0; dir->d_reclen = DIRBLKSIZ; } - + writeblock (fsbtodb (sblock, newblk), buf, sblock->fs_bsize); return 1; } @@ -297,10 +297,10 @@ makeentry (ino_t dir, ino_t ino, char *name) struct dinode dino; int needed; int madeentry; - + /* Read a directory block and see if it contains room for the new entry. If so, add it and return 1; otherwise return 0. */ - int + int check1block (void *buf) { struct directory_entry *dp; @@ -341,7 +341,7 @@ makeentry (ino_t dir, ino_t ino, char *name) } } return 0; - } + } /* Read part of a directory and look to see if it contains NAME. Return 1 if we should keep looking @@ -351,7 +351,7 @@ makeentry (ino_t dir, ino_t ino, char *name) { void *buf = alloca (nfrags * sblock->fs_fsize); void *bufp; - + readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize @@ -367,10 +367,10 @@ makeentry (ino_t dir, ino_t ino, char *name) } return 1; } - + if (!validdir (dir, "MODIFY")) return 0; - + getinode (dir, &dino); len = strlen (name); needed = DIRSIZ (len); @@ -379,7 +379,7 @@ makeentry (ino_t dir, ino_t ino, char *name) if (!madeentry) { /* Attempt to expand the directory. */ - problem (0, "NO SPACE LEFT IN DIR INO=%d", dir); + problem (0, "NO SPACE LEFT IN DIR INO=%Ld", dir); if (preen || reply ("EXPAND")) { if (expanddir (&dino)) @@ -408,7 +408,7 @@ allocdir (ino_t parent, ino_t request, mode_t mode) ino_t ino; mode |= IFDIR; - + ino = allocino (request, mode); if (!ino) return 0; @@ -416,11 +416,11 @@ allocdir (ino_t parent, ino_t request, mode_t mode) goto bad; if (!makeentry (ino, parent, "..")) goto bad; - + linkfound[ino]++; linkfound[parent]++; return ino; - + bad: freeino (ino); return 0; @@ -471,16 +471,16 @@ linkup (ino_t ino, ino_t parent) } } } - + getinode (lfdir, &lfdino); if ((lfdino.di_model & IFMT) != IFDIR) { ino_t oldlfdir; - + problem (1, "`%s' IS NOT A DIRECTORY", lfname); if (! reply ("REALLOCATE")) return 0; - + oldlfdir = lfdir; lfdir = allocdir (ROOTINO, 0, lfmode); @@ -494,20 +494,20 @@ linkup (ino_t ino, ino_t parent) warning (1, "SORRY, CANNOT CREATE `%s' DIRECTORY", lfname); return 0; } - + /* One less link to the old one */ linkfound[oldlfdir]--; - + getinode (lfdir, &lfdino); } - + if (inodestate[lfdir] != DIRECTORY && inodestate[lfdir] != (DIRECTORY|DIR_REF)) { warning (1, "SORRY. `%s' DIRECTORY NOT ALLOCATED", lfname); return 0; } - asprintf (&tempname, "#%d", ino); + asprintf (&tempname, "#%Ld", ino); search_failed = !searchdir (lfdir, tempname, &foo); while (foo) { @@ -531,7 +531,7 @@ linkup (ino_t ino, ino_t parent) } free (tempname); linkfound[ino]++; - + if (parent != -1) { /* Reset `..' in ino */ @@ -539,7 +539,7 @@ linkup (ino_t ino, ino_t parent) { if (!changeino (ino, "..", lfdir)) { - warning (1, "CANNOT ADJUST `..' LINK I=%u", ino); + warning (1, "CANNOT ADJUST `..' LINK I=%Ld", ino); return 0; } /* Forget about link to old parent */ @@ -547,21 +547,21 @@ linkup (ino_t ino, ino_t parent) } else if (!makeentry (ino, lfdir, "..")) { - warning (1, "CANNOT CREAT `..' LINK I=%u", ino); + warning (1, "CANNOT CREAT `..' LINK I=%Ld", ino); return 0; } - + /* Account for link to lost+found; update inode directly here to avoid confusing warning later. */ linkfound[lfdir]++; linkcount[lfdir]++; lfdino.di_nlink++; write_inode (lfdir, &lfdino); - + if (parent) - warning (0, "DIR I=%u CONNECTED; PARENT WAS I=%u", ino, parent); + warning (0, "DIR I=%Ld CONNECTED; PARENT WAS I=%Ld", ino, parent); else - warning (0, "DIR I=%u CONNECTED", ino); + warning (0, "DIR I=%Ld CONNECTED", ino); } return 1; } diff --git a/ufs-fsck/pass1.c b/ufs-fsck/pass1.c index 066f4649..bd41cc62 100644 --- a/ufs-fsck/pass1.c +++ b/ufs-fsck/pass1.c @@ -1,5 +1,5 @@ /* Pass one of GNU fsck -- count blocks and verify inodes - Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -24,7 +24,7 @@ static struct dinode zino; -/* Find all the blocks in use by files and filesystem reserved blocks. +/* Find all the blocks in use by files and filesystem reserved blocks. Set them in the global block map. For each file, if a block is found allocated twice, then record the block and inode in DUPLIST. Initialize INODESTATE, LINKCOUNT, and TYPEMAP. */ @@ -52,7 +52,7 @@ pass1 () node. Increment NBLOCKS by the number of data blocks held. Set BLKERROR if this block is invalid. Return RET_GOOD, RET_BAD, RET_STOP if the block is good, - bad, or if we should entirely stop checking blocks in this + bad, or if we should entirely stop checking blocks in this inode. */ int checkblock (daddr_t bno, int nfrags, off_t offset) @@ -69,10 +69,10 @@ pass1 () blkerror = 1; wasbad = 1; if (nblkrngerrors == 0) - warning (0, "I=%d HAS BAD BLOCKS", number); + warning (0, "I=%Ld HAS BAD BLOCKS", number); if (nblkrngerrors++ > MAXBAD) { - problem (0, "EXCESSIVE BAD BLKS I=%d", number); + problem (0, "EXCESSIVE BAD BLKS I=%Ld", number); if (preen || reply ("SKIP")) { pfail ("SKIPPING"); @@ -93,12 +93,12 @@ pass1 () { blkerror = 1; if (nblkduperrors == 0) - warning (0, "I=%d HAS DUPLICATE BLOCKS", number); + warning (0, "I=%Ld HAS DUPLICATE BLOCKS", number); warning (0, "DUPLICATE BLOCK %ld", bno); wasbad = 1; if (nblkduperrors++ > MAXBAD) { - problem (0, "EXCESSIVE DUP BLKS I=%d", number); + problem (0, "EXCESSIVE DUP BLKS I=%Ld", number); if (preen || reply ("SKIP")) { pfail ("SKIPPING"); @@ -128,16 +128,16 @@ pass1 () } return wasbad ? RET_BAD : RET_GOOD; } - + /* Account for blocks used by meta data */ for (cg = 0; cg < sblock->fs_ncg; cg++) { daddr_t firstdata, firstcgblock, bno; - + /* Each cylinder group past the first reserves data from its cylinder group copy to (but not including) - the first datablock. + the first datablock. The first, however, reserves from the very front of the cylinder group (thus including the boot block), and it also @@ -155,7 +155,7 @@ pass1 () for (bno = firstcgblock; bno < firstdata; bno++) setbmap (bno); } - + /* Loop through each inode, doing initial checks */ for (number = 0, cg = 0; cg < sblock->fs_ncg; cg++) for (i = 0; i < sblock->fs_ipg; i++, number++) @@ -165,15 +165,15 @@ pass1 () int dbwarn = 0, ibwarn = 0; /* if (!preen && !(number % 10000)) - printf ("I=%d\n", number); */ + printf ("I=%Ld\n", number); */ if (number < ROOTINO) continue; - + getinode (number, dp); mode = DI_MODE (dp); type = mode & IFMT; - + /* If the node is not allocated, then make sure it's properly clear */ if (type == 0) @@ -184,7 +184,7 @@ pass1 () || DI_MODE (dp) || dp->di_size) { - problem (0, "PARTIALLY ALLOCATED INODE I=%d", number); + problem (0, "PARTIALLY ALLOCATED INODE I=%Ld", number); if (preen || reply ("CLEAR")) { clear_inode (number, dp); @@ -196,15 +196,15 @@ pass1 () else { /* Node is allocated. */ - + /* Check to see if we think the node should be cleared */ /* Verify size for basic validity */ holdallblocks = 0; - + if (dp->di_size + sblock->fs_bsize - 1 < dp->di_size) { - problem (1, "OVERFLOW IN FILE SIZE I=%d (SIZE == %lld)", number, + problem (1, "OVERFLOW IN FILE SIZE I=%Ld (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -213,12 +213,12 @@ pass1 () continue; } inodestate[number] = UNALLOC; - warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED", + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld AS ALLOCATED", number); holdallblocks = 1; } - /* Decode type and set NDB + /* Decode type and set NDB also set inodestate correctly. */ inodestate[number] = REG; switch (type) @@ -227,19 +227,19 @@ pass1 () case IFCHR: ndb = 1; break; - + case IFIFO: case IFSOCK: ndb = 0; break; - + case IFLNK: if (sblock->fs_maxsymlinklen != -1) { /* Check to see if this is a fastlink. The old fast link format has fs_maxsymlinklen of zero and di_blocks zero; the new format has - fs_maxsymlinklen set and we ignore di_blocks. + fs_maxsymlinklen set and we ignore di_blocks. So check for either. */ if ((sblock->fs_maxsymlinklen && dp->di_size < sblock->fs_maxsymlinklen) @@ -262,16 +262,16 @@ pass1 () else ndb = howmany (dp->di_size, sblock->fs_bsize); break; - + case IFDIR: inodestate[number] = DIRECTORY; /* Fall through */ case IFREG: ndb = howmany (dp->di_size, sblock->fs_bsize); break; - + default: - problem (1, "UNKNOWN FILE TYPE I=%d (MODE=%ol)", number, mode); + problem (1, "UNKNOWN FILE TYPE I=%Ld (MODE=%ol)", number, mode); if (reply ("CLEAR")) { clear_inode (number, dp); @@ -280,14 +280,14 @@ pass1 () } inodestate[number] = UNALLOC; holdallblocks = 1; - warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d " + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld " "AS ALLOCATED", number); ndb = 0; } if (ndb < 0) { - problem (1, "BAD FILE SIZE I= %d (SIZE == %lld)", number, + problem (1, "BAD FILE SIZE I= %Ld (SIZE == %lld)", number, dp->di_size); if (reply ("CLEAR")) { @@ -296,7 +296,7 @@ pass1 () continue; } inodestate[number] = UNALLOC; - warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%d AS ALLOCATED", + warning (0, "WILL TREAT ANY BLOCKS HELD BY I=%Ld AS ALLOCATED", number); holdallblocks = 1; } @@ -308,10 +308,10 @@ pass1 () if (!holdallblocks) { if (dp->di_size - && (type == IFBLK || type == IFCHR + && (type == IFBLK || type == IFCHR || type == IFSOCK || type == IFIFO)) { - problem (1, "SPECIAL NODE I=%d (MODE=%ol) HAS SIZE %lld", + problem (1, "SPECIAL NODE I=%Ld (MODE=%ol) HAS SIZE %lld", number, mode, dp->di_size); if (reply ("TRUNCATE")) { @@ -319,10 +319,10 @@ pass1 () write_inode (number, dp); } } - + /* If we haven't set NDB speciall above, then it is set from the file size correctly by the size check. */ - + /* Check all the direct and indirect blocks that are past the amount necessary to be zero. */ for (lbn = ndb; lbn < NDADDR; lbn++) @@ -332,7 +332,7 @@ pass1 () if (!dbwarn) { dbwarn = 1; - problem (0, "INODE I=%d HAS EXTRA DIRECT BLOCKS", + problem (0, "INODE I=%Ld HAS EXTRA DIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { @@ -357,7 +357,7 @@ pass1 () if (ibwarn) { ibwarn = 1; - problem (0, "INODE I=%d HAS EXTRA INDIRECT BLOCKS", + problem (0, "INODE I=%Ld HAS EXTRA INDIRECT BLOCKS", number); if (preen || reply ("DEALLOCATE")) { @@ -373,7 +373,7 @@ pass1 () write_inode (number, dp); } } - + /* If this node is really allocated (as opposed to something that we should clear but the user won't) then set LINKCOUNT and TYPEMAP entries. */ @@ -397,7 +397,7 @@ pass1 () warning (1, "DUPLICATE or BAD BLOCKS"); else { - problem (0, "I=%d has ", number); + problem (0, "I=%Ld has ", number); if (nblkduperrors) { pextend ("%d DUPLICATE BLOCKS", nblkduperrors); @@ -418,7 +418,7 @@ pass1 () } else if (dp->di_blocks != nblocks) { - problem (0, "INCORRECT BLOCK COUNT I=%d (%ld should be %d)", + problem (0, "INCORRECT BLOCK COUNT I=%Ld (%ld should be %d)", number, dp->di_blocks, nblocks); if (preen || reply ("CORRECT")) { @@ -435,5 +435,3 @@ pass1 () } } } - - diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index a2d5996c..d95929ef 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -1,5 +1,5 @@ /* Pass 2 of GNU fsck -- examine all directories for validity - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994,96,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -70,7 +70,7 @@ pass2 () for (bp = (char *)buf; bp < (char *)buf + DIRBLKSIZ; bp++) if (*bp) goto reclen_problem; - + problem (0, "NULL BLOCK IN DIRECTORY"); if (preen || reply ("PATCH")) { @@ -83,7 +83,7 @@ pass2 () else return mod; } - + reclen_problem: problem (1, "BAD RECLEN IN DIRECTORY"); if (reply ("SALVAGE")) @@ -98,7 +98,7 @@ pass2 () /* But give up regardless */ return mod; } - + /* Check INO */ if (dp->d_ino > maxino) { @@ -113,7 +113,7 @@ pass2 () if (!dp->d_ino) continue; - + /* Check INO */ if (inodestate[dp->d_ino] == UNALLOC) { @@ -138,7 +138,7 @@ pass2 () dp->d_ino = 0; mod = 1; } - } + } else { /* Check for illegal characters */ @@ -165,7 +165,7 @@ pass2 () } } } - + if (!dp->d_ino) continue; @@ -181,10 +181,10 @@ pass2 () mod = 1; } } - + /* Here we should check for duplicate directory entries; that's too much trouble right now. */ - + /* Account for the inode in the linkfound map */ if (inodestate[dp->d_ino] != UNALLOC) linkfound[dp->d_ino]++; @@ -205,7 +205,7 @@ pass2 () { problem (0, "EXTRANEOUS LINK `%s' TO DIR I=%ld", dp->d_name, dp->d_ino); - pextend (" FOUND IN DIR I=%d", dnp->i_number); + pextend (" FOUND IN DIR I=%Ld", dnp->i_number); if (preen || reply ("REMOVE")) { dp->d_ino = 0; @@ -234,9 +234,9 @@ pass2 () readblock (fsbtodb (sblock, bno), buf, nfrags * sblock->fs_fsize); rewrite = 0; - for (bufp = buf; + for (bufp = buf; bufp - buf < nfrags * sblock->fs_fsize - && offset + (bufp - buf) + DIRBLKSIZ <= dnp->i_isize; + && offset + (bufp - buf) + DIRBLKSIZ <= dnp->i_isize; bufp += DIRBLKSIZ) { if (check1block (bufp)) @@ -251,7 +251,7 @@ pass2 () { default: errexit ("BAD STATE %d FOR ROOT INODE", (int) (inodestate[ROOTINO])); - + case DIRECTORY: break; @@ -262,7 +262,7 @@ pass2 () if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) errexit ("CANNOT ALLOCATE ROOT INODE"); break; - + case REG: problem (1, "ROOT INODE NOT DIRECTORY"); if (reply ("REALLOCATE")) @@ -270,7 +270,7 @@ pass2 () if (allocdir (ROOTINO, ROOTINO, 0755) != ROOTINO) errexit ("CANNOT ALLOCATE ROOT INODE"); break; - + case BADDIR: problem (1, "DUPLICATE or BAD BLOCKS IN ROOT INODE"); if (reply ("REALLOCATE")) @@ -283,20 +283,20 @@ pass2 () errexit ("ABORTING"); break; } - + /* Sort inpsort */ qsort (dirsorted, dirarrayused, sizeof (struct dirinfo *), sortfunc); - + /* Check basic integrity of each directory */ for (nd = 0; nd < dirarrayused; nd++) { dnp = dirsorted[nd]; - + if (dnp->i_isize == 0) continue; if (dnp->i_isize % DIRBLKSIZ) { - problem (0, "DIRECTORY INO=%d: LENGTH %d NOT MULTIPLE OF %d", + problem (0, "DIRECTORY INO=%Ld: LENGTH %d NOT MULTIPLE OF %d", dnp->i_number, dnp->i_isize, DIRBLKSIZ); if (preen || reply ("ADJUST")) { @@ -310,10 +310,10 @@ pass2 () dino.di_size = dnp->i_isize; assert (dnp->i_numblks <= (NDADDR + NIADDR) * sizeof (daddr_t)); bcopy (dnp->i_blks, dino.di_db, dnp->i_numblks); - + datablocks_iterate (&dino, checkdirblock); } - + /* At this point for each directory: If this directory is an entry in another directory, then i_parent is @@ -323,12 +323,12 @@ pass2 () for (nd = 0; nd < dirarrayused; nd++) { dnp = dirsorted[nd]; - + /* Root is considered to be its own parent even though it isn't listed. */ if (dnp->i_number == ROOTINO && !dnp->i_parent) dnp->i_parent = ROOTINO; - + /* Check `.' to make sure it exists and is correct */ if (dnp->i_dot == 0) { @@ -397,5 +397,4 @@ pass2 () } } } -} - +} diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index f3a2b670..5e081fe8 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -1,5 +1,5 @@ /* Miscellaneous functions for fsck - Copyright (C) 1994, 1995, 1996, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1994,95,96,99,2001,02 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -355,7 +355,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) } if (ino < ROOTINO || ino > maxino) - pextend (" (BOGUS INODE) I=%d", ino); + pextend (" (BOGUS INODE) I=%Ld", ino); else { char *p; @@ -364,7 +364,7 @@ pinode (int severe, ino_t ino, char *fmt, ...) getinode (ino, &dino); - pextend (" %s I=%d", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE", + pextend (" %s I=%Ld", (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE", ino); pw = getpwuid (dino.di_uid); -- cgit v1.2.3 From 7bf1315710bcbc20b44edb41db15131fba273673 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:41:17 +0000 Subject: 2002-06-08 Roland McGrath * fsck.h: Use ino_t for lfdir. * setup.c: Likewise. * fsck.h (struct dirinfo): Use size_t for i_isize. --- ufs-fsck/fsck.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index 7d55bea6..f9b0acd3 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. +/* + Copyright (C) 1994,95,96,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -59,7 +59,7 @@ char *blockmap; extern char *device_name; -/* Command line flags */ +/* Command line flags */ int nowrite; /* all questions fail */ int noquery; /* all questions succeed */ @@ -81,7 +81,7 @@ struct dirinfo ino_t i_parent; /* inode entry of parent */ ino_t i_dotdot; /* inode number of `..' */ ino_t i_dot; /* inode number of `.' */ - ino_t i_isize; /* size of inode */ + size_t i_isize; /* size of inode */ u_int i_numblks; /* size of block array in bytes */ daddr_t i_blks[0]; /* array of inode block addresses */ }; @@ -121,7 +121,7 @@ extern int fix_denied; extern int fsmodified; -extern int lfdir; +extern ino_t lfdir; /* Total number of files found on the partition. */ extern daddr_t num_files; @@ -145,7 +145,7 @@ extern char *lfname; #define DI_MODE(dp) (((dp)->di_modeh << 16) | (dp)->di_model) - + int setup (char *); void pass1 (), pass1b (), pass2 (), pass3 (), pass4 (), pass5 (); -- cgit v1.2.3 From 9bad1d3b6da8a2f54d0443d643e29f98a434d31f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:41:20 +0000 Subject: 2002-06-08 Roland McGrath * fsck.h: Use ino_t for lfdir. * setup.c: Likewise. --- ufs-fsck/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-fsck/setup.c b/ufs-fsck/setup.c index 6309a901..9433bd68 100644 --- a/ufs-fsck/setup.c +++ b/ufs-fsck/setup.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. + Copyright (C) 1994,96,99,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -42,7 +42,7 @@ int fix_denied = 0; int fsmodified = 0; -int lfdir; +ino_t lfdir; /* Get ready to run on device with pathname DEV. */ int -- cgit v1.2.3 From 4dde66e67d59b37f0af66be9289d9620d3b725a7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:43:05 +0000 Subject: 2002-06-08 Roland McGrath * dir.c, pass1.c, pass1b.c, pass2.c: Use %Ld for ino_t values. * utilities.c: Likewise. --- ufs-fsck/pass1b.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ufs-fsck/pass1b.c b/ufs-fsck/pass1b.c index 0cf50a17..4da86974 100644 --- a/ufs-fsck/pass1b.c +++ b/ufs-fsck/pass1b.c @@ -1,5 +1,5 @@ /* Pass 1b of fsck -- scan inodes for references to duplicate blocks - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994,96,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -31,7 +31,7 @@ pass1b () struct dups *duphead = duplist; /* Check each block of file DP; if the block is in the dup block - list then add it to the dup block list under this file. + list then add it to the dup block list under this file. Return RET_GOOD or RET_BAD if the block is good or bad, respectively. */ int @@ -39,7 +39,7 @@ pass1b () { struct dups *dlp; int hadbad = 0; - + for (; nfrags > 0; bno++, nfrags--) { if (check_range (bno, 1)) @@ -76,7 +76,7 @@ pass1b () allblock_iterate (dp, checkblock); if (dupblk) { - problem (1, "I=%d HAS %d DUPLICATE BLOCKS", number, dupblk); + problem (1, "I=%Ld HAS %d DUPLICATE BLOCKS", number, dupblk); if (reply ("CLEAR")) { clear_inode (number, dp); @@ -88,5 +88,3 @@ pass1b () } } } - - -- cgit v1.2.3 From 5245c79279dc564672fcdcd48659ca8da43aa5ba Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:43:19 +0000 Subject: 2002-06-08 Roland McGrath * mkfs.c (iput): Use %Ld format for ino_t values. --- ufs-utils/mkfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index 6d544949..f423f003 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.20 2001/12/02 22:06:54 roland Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.21 2002/06/11 21:43:19 roland Exp $"; #endif /* not lint */ #include @@ -1279,7 +1279,7 @@ iput(ip, ino) sblock.fs_cstotal.cs_nifree--; fscs[0].cs_nifree--; if (ino >= sblock.fs_ipg * sblock.fs_ncg) - deverr (32, 0, "fsinit: inode value out of range (%d)", ino); + deverr (32, 0, "fsinit: inode value out of range (%Ld)", ino); d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino)); rdfs(d, sblock.fs_bsize, buf); buf[ino_to_fsbo(&sblock, ino)] = *ip; -- cgit v1.2.3 From 4769366ca8af3f3c39cabc604de33c7aef5814ed Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 11 Jun 2002 21:43:43 +0000 Subject: . --- ufs-fsck/ChangeLog | 10 ++++++++++ ufs-utils/ChangeLog | 4 ++++ ufs/ChangeLog | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 0e678ab5..7260520b 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,13 @@ +2002-06-08 Roland McGrath + + * dir.c, pass1.c, pass1b.c, pass2.c: Use %Ld for ino_t values. + * utilities.c: Likewise. + + * fsck.h: Use ino_t for lfdir. + * setup.c: Likewise. + + * fsck.h (struct dirinfo): Use size_t for i_isize. + 2001-09-30 Roland McGrath * pass5.c (pass5): A little manual CSE makes buggy gcc not to crash. diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index 66cefd4c..f65e9ce1 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,7 @@ +2002-06-08 Roland McGrath + + * mkfs.c (iput): Use %Ld format for ino_t values. + 2001-12-06 Roland McGrath * dlabel.c (fd_get_device): Only deallocate NODE if store_create fails. diff --git a/ufs/ChangeLog b/ufs/ChangeLog index f0192426..06e3b323 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,13 @@ +2002-06-08 Roland McGrath + + * inode.c (diskfs_cached_lookup): Use ino_t for argument. + + * dir.c (diskfs_direnter_hard): Use size_t for OLDSIZE. + Fail with EOVERFLOW when it would exceed that width. + + * alloc.c, dir.c: Use %Ld format for ino_t values. + * alloc.c (diskfs_alloc_node): Use %Ld format for blkcnt_t values. + 2002-05-08 Roland McGrath * main.c (diskfs_append_args): Fix argument type. -- cgit v1.2.3 From 5b9a11ce115c2410d09b5b793eb33d62343406ca Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 13 Jun 2002 20:57:57 +0000 Subject: 2002-06-13 Roland McGrath * fsck.h (struct dirinfo): Revert i_isize to using u_int. --- ufs-fsck/fsck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index f9b0acd3..e80dfc84 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -81,7 +81,7 @@ struct dirinfo ino_t i_parent; /* inode entry of parent */ ino_t i_dotdot; /* inode number of `..' */ ino_t i_dot; /* inode number of `.' */ - size_t i_isize; /* size of inode */ + u_int i_isize; /* size of inode */ u_int i_numblks; /* size of block array in bytes */ daddr_t i_blks[0]; /* array of inode block addresses */ }; -- cgit v1.2.3 From 4d6112d7817bd5b6cf4fdc7435d8b39f7c302705 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 13 Jun 2002 20:59:43 +0000 Subject: . --- ufs-fsck/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 7260520b..6415a78a 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +2002-06-13 Roland McGrath + + * fsck.h (struct dirinfo): Revert i_isize to using u_int. + 2002-06-08 Roland McGrath * dir.c, pass1.c, pass1b.c, pass2.c: Use %Ld for ino_t values. -- cgit v1.2.3 From dbd034e9e847cec81df15065bb1a84992ecbd6da Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 14 Jun 2002 21:47:12 +0000 Subject: 2002-06-14 Roland McGrath * default_pager.c: #include "default_pager_S.h" --- serverboot/default_pager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index f0cb4d49..e495ee95 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -50,6 +50,8 @@ #include +#include "default_pager_S.h" + #define debug 0 extern void *kalloc(); -- cgit v1.2.3 From df6acae39c82916cf76ce76da3395a6d8f8be142 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 14 Jun 2002 21:47:22 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 602b3454..5eb5fd59 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2002-06-14 Roland McGrath + + * default_pager.c: #include "default_pager_S.h" + 2002-05-29 Roland McGrath * bootstrap.c (main): int -> integer_t for boot_script values. -- cgit v1.2.3 From 3e452f9fd0628d41f39f1e6a265f04c07eb0c958 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 23 Jun 2002 04:29:11 +0000 Subject: 2002-06-22 Roland McGrath * load.c (boot_script_exec_cmd): Twiddle decls of serverboot_bunzip2 and serverboot_gunzip. * load.c (boot_script_exec_cmd): Cast int to intptr_t before char *. --- serverboot/load.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/serverboot/load.c b/serverboot/load.c index 21289bf1..e95a64d7 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -318,8 +318,8 @@ boot_script_exec_cmd (void *hook, * It might be gzip file. */ int err; - extern int - serverboot_gunzip(struct file *, void **, size_t *); + extern int serverboot_gunzip(struct file *, + vm_offset_t *, size_t *); err = serverboot_gunzip(st.fp, &(st.image_addr), @@ -343,8 +343,8 @@ boot_script_exec_cmd (void *hook, * It might be bzip2 file. */ int err; - extern int - serverboot_bunzip2(struct file *, void **, size_t *); + extern int serverboot_bunzip2(struct file *, + vm_offset_t *, size_t *); err = serverboot_bunzip2(st.fp, &(st.image_addr), @@ -449,7 +449,7 @@ boot_script_exec_cmd (void *hook, /* * first the argument count */ - *k_ap++ = (char *)arg_count; + *k_ap++ = (char *)(intptr_t)arg_count; /* * Then the strings and string pointers for each argument -- cgit v1.2.3 From e2695d0b76a150ae2a46b205fa2cb4c7f7efc8a5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 23 Jun 2002 04:29:14 +0000 Subject: 2002-06-22 Roland McGrath * elf-load.c (exec_load) [__alpha__]: Grok Elf64_* headers and check for EM_ALPHA. * exec.c (set_regs) [__alpha__]: Alpha implementation snarfed from CMU file bootstrap/alpha/exec.c in MK83a. --- serverboot/elf-load.c | 152 ++++++++++++++++++++++++++++++++------------------ serverboot/exec.c | 73 +++++++++++++++++++++--- 2 files changed, 165 insertions(+), 60 deletions(-) diff --git a/serverboot/elf-load.c b/serverboot/elf-load.c index a30124a2..af11635e 100644 --- a/serverboot/elf-load.c +++ b/serverboot/elf-load.c @@ -1,22 +1,22 @@ /* - * 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 + * 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 @@ -31,9 +31,7 @@ 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; - Elf32_Ehdr x; - Elf32_Phdr *phdr, *ph; - vm_size_t phsize; + union { Elf32_Ehdr h; Elf64_Ehdr h64; } x; int i; int result; @@ -43,50 +41,98 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, if (actual < sizeof(x)) return EX_NOT_EXECUTABLE; - if ((x.e_ident[EI_MAG0] != ELFMAG0) || - (x.e_ident[EI_MAG1] != ELFMAG1) || - (x.e_ident[EI_MAG2] != ELFMAG2) || - (x.e_ident[EI_MAG3] != ELFMAG3)) + 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 - if ((x.e_ident[EI_CLASS] != ELFCLASS32) || - (x.e_ident[EI_DATA] != ELFDATA2LSB) || - (x.e_machine != EM_386)) - return EX_WRONG_ARCH; +# 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 - /* XXX others */ - out_info->entry = (vm_offset_t) x.e_entry; + if ((x.h.e_ident[EI_CLASS] != ELFCLASS64) || + (x.h.e_ident[EI_DATA] != ELFDATA2LSB) || + (x.h.e_machine != EM_ALPHA)) + return EX_WRONG_ARCH; - phsize = x.e_phnum * x.e_phentsize; - phdr = (Elf32_Phdr *)alloca(phsize); + if (MY_CLASS == ELFCLASS64) + { + Elf64_Phdr *phdr, *ph; + vm_size_t phsize; - result = (*read)(handle, x.e_phoff, phdr, phsize, &actual); - if (result) - return result; - if (actual < phsize) - return EX_CORRUPT; + /* XXX others */ + out_info->entry = (vm_offset_t) x.h64.e_entry; + out_info->init_dp = 0; /* ? */ - for (i = 0; i < x.e_phnum; i++) - { - ph = (Elf32_Phdr *)((vm_offset_t)phdr + i * x.e_phentsize); + 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); - } - } + { + 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; + + /* 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 index a0773f4c..a487fb5d 100644 --- a/serverboot/exec.c +++ b/serverboot/exec.c @@ -1,25 +1,25 @@ -/* +/* * 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. */ @@ -29,11 +29,14 @@ #include #include -#include #include "mach-exec.h" #include +#ifdef i386 + +#include + /* * Machine-dependent portions of execve() for the i386. */ @@ -86,3 +89,59 @@ char *set_regs( 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)®s, + ®_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)®s, + reg_size); + + return (char *)regs.r30; +} + +#else +# error "Not ported to this architecture!" +#endif -- cgit v1.2.3 From 326befddc3284037f66026acfb02fa2669ad330b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 23 Jun 2002 04:29:22 +0000 Subject: . --- serverboot/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 5eb5fd59..c0879be3 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,15 @@ +2002-06-22 Roland McGrath + + * load.c (boot_script_exec_cmd): Twiddle decls of serverboot_bunzip2 + and serverboot_gunzip. + + * elf-load.c (exec_load) [__alpha__]: Grok Elf64_* headers and check + for EM_ALPHA. + * exec.c (set_regs) [__alpha__]: Alpha implementation snarfed from CMU + file bootstrap/alpha/exec.c in MK83a. + + * load.c (boot_script_exec_cmd): Cast int to intptr_t before char *. + 2002-06-14 Roland McGrath * default_pager.c: #include "default_pager_S.h" -- cgit v1.2.3 From 1cee232ca26f3be1584fa29369c0a04610fbbbe2 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 3 Jul 2002 19:08:04 +0000 Subject: 2002-07-03 Roland McGrath * elf-load.c (exec_load): Fix typos in last change. --- serverboot/elf-load.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serverboot/elf-load.c b/serverboot/elf-load.c index af11635e..5de838c3 100644 --- a/serverboot/elf-load.c +++ b/serverboot/elf-load.c @@ -60,9 +60,9 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, #error Not ported to this architecture! #endif - if ((x.h.e_ident[EI_CLASS] != ELFCLASS64) || - (x.h.e_ident[EI_DATA] != ELFDATA2LSB) || - (x.h.e_machine != EM_ALPHA)) + if ((x.h.e_ident[EI_CLASS] != MY_CLASS) || + (x.h.e_ident[EI_DATA] != MY_DATA) || + (x.h.e_machine != MY_MACHINE)) return EX_WRONG_ARCH; if (MY_CLASS == ELFCLASS64) -- cgit v1.2.3 From f32e97da0560f0af3995ed4d25b06fe43588c993 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 3 Jul 2002 19:08:08 +0000 Subject: . --- serverboot/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index c0879be3..f68f559e 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,7 @@ +2002-07-03 Roland McGrath + + * elf-load.c (exec_load): Fix typos in last change. + 2002-06-22 Roland McGrath * load.c (boot_script_exec_cmd): Twiddle decls of serverboot_bunzip2 -- cgit v1.2.3 From b51239a09ffcf29c5edf4f81a310f83f2da40a37 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 3 Jul 2002 19:35:03 +0000 Subject: 2002-07-03 Roland McGrath * elf-load.c (exec_load): Fix e_machine checking. --- serverboot/elf-load.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/serverboot/elf-load.c b/serverboot/elf-load.c index 5de838c3..603eadf0 100644 --- a/serverboot/elf-load.c +++ b/serverboot/elf-load.c @@ -61,8 +61,7 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, #endif if ((x.h.e_ident[EI_CLASS] != MY_CLASS) || - (x.h.e_ident[EI_DATA] != MY_DATA) || - (x.h.e_machine != MY_MACHINE)) + (x.h.e_ident[EI_DATA] != MY_DATA)) return EX_WRONG_ARCH; if (MY_CLASS == ELFCLASS64) @@ -70,6 +69,9 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, 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; /* ? */ @@ -104,6 +106,9 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, 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; /* ? */ -- cgit v1.2.3 From b8a0323832dcb9feb0823e0ccad0d8db74a06bb9 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 3 Jul 2002 19:35:09 +0000 Subject: . --- serverboot/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index f68f559e..68f6cbe8 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,5 +1,7 @@ 2002-07-03 Roland McGrath + * elf-load.c (exec_load): Fix e_machine checking. + * elf-load.c (exec_load): Fix typos in last change. 2002-06-22 Roland McGrath -- cgit v1.2.3 From 25a921e6e16dfad15b5cdb37f0b6e81eacb8afe1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 1 Aug 2002 00:59:34 +0000 Subject: 2002-07-31 Roland McGrath * dir.c (diskfs_direnter_hard): Fix test in last change. --- ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/dir.c b/ufs/dir.c index b67e45f6..83b30e72 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -585,7 +585,7 @@ diskfs_direnter_hard(struct node *dp, assert (needed <= DIRBLKSIZ); oldsize = dp->dn_stat.st_size; - if ((off_t)(oldsize + DIRBLKSIZ) != dp->dn_stat.st_size) + if ((off_t)(oldsize + DIRBLKSIZ) != dp->dn_stat.st_size + DIRBLKSIZ) { /* We can't possibly map the whole directory in. */ munmap ((caddr_t) ds->mapbuf, ds->mapextent); -- cgit v1.2.3 From 5f792f6e012b161d85629a070b282ed76965df93 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 1 Aug 2002 00:59:41 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 06e3b323..f0776c59 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +2002-07-31 Roland McGrath + + * dir.c (diskfs_direnter_hard): Fix test in last change. + 2002-06-08 Roland McGrath * inode.c (diskfs_cached_lookup): Use ino_t for argument. -- cgit v1.2.3 From b7f75b1bfc656c5614e3f0344c9604f55ec6c244 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 4 Aug 2002 01:17:18 +0000 Subject: 2002-08-03 Jeff Bailey * rules: Symlinks should point to relative location, not absolute. --- debian/ChangeLog | 4 ++++ debian/rules | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 944aa50d..a224d8a3 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2002-08-03 Jeff Bailey + + * rules: Symlinks should point to relative location, not absolute. + 2002-05-23 Marcus Brinkmann * control (Provides, Replaces, Conflicts): Add fakeroot. diff --git a/debian/rules b/debian/rules index fb0e3971..f6365a2b 100755 --- a/debian/rules +++ b/debian/rules @@ -131,7 +131,7 @@ binary-arch: build # Create development library links. for file in `cd debian/tmp/lib && ls *.so.*`; do \ linkname=`echo "$$file" | sed 's/\..*$$/.so/'`; \ - ln -sf /lib/$$file debian/$(package)-dev/usr/lib/$$linkname; \ + ln -sf $$file debian/$(package)-dev/usr/lib/$$linkname; \ done rm -f debian/tmp/lib/*.so -- cgit v1.2.3 From cd00d5d95831a7e3f3732d262c48a67101807003 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 4 Aug 2002 18:43:41 +0000 Subject: 2002-08-04 Marcus Brinkmann * control (Uploaders): New field, suggested by Jeff Bailey. --- debian/ChangeLog | 4 ++++ debian/control | 1 + 2 files changed, 5 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index a224d8a3..d305796d 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2002-08-04 Marcus Brinkmann + + * control (Uploaders): New field, suggested by Jeff Bailey. + 2002-08-03 Jeff Bailey * rules: Symlinks should point to relative location, not absolute. diff --git a/debian/control b/debian/control index 3a5ed37d..c47d2cb4 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,7 @@ Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 Build-Depends: file, mig, texinfo, tetex-bin, autoconf +Uploaders: Marcus Brinkmann Package: hurd Priority: required -- cgit v1.2.3 From aac1f2e2cc0fd3c2bec414db47ce8516f6579dd7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 4 Aug 2002 19:00:26 +0000 Subject: 2002-08-04 Marcus Brinkmann * control (Uploaders): New field, suggested by Jeff Bailey. (Build-Depends): Add version requirement for mig. * shlibs: Update version to 0.3, add version restriction. * shlibs.local: Likewise. * changelog: Update for next upload. --- debian/ChangeLog | 4 ++++ debian/changelog | 8 ++++++++ debian/control | 2 +- debian/shlibs | 30 +++++++++++++++--------------- debian/shlibs.local | 30 +++++++++++++++--------------- 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index d305796d..f08e2868 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,6 +1,10 @@ 2002-08-04 Marcus Brinkmann * control (Uploaders): New field, suggested by Jeff Bailey. + (Build-Depends): Add version requirement for mig. + * shlibs: Update version to 0.3, add version restriction. + * shlibs.local: Likewise. + * changelog: Update for next upload. 2002-08-03 Jeff Bailey diff --git a/debian/changelog b/debian/changelog index d9db077e..75c1b193 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +hurd (20020804-1) unstable; urgency=low + + * New snapshot from CVS. + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Sun, 4 Aug 2002 20:46:28 +0200 + hurd (20020523-1) unstable; urgency=low * New snapshot from CVS. diff --git a/debian/control b/debian/control index c47d2cb4..179c4ee7 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 -Build-Depends: file, mig, texinfo, tetex-bin, autoconf +Build-Depends: file, mig (>= 1.3-2), texinfo, tetex-bin, autoconf Uploaders: Marcus Brinkmann Package: hurd diff --git a/debian/shlibs b/debian/shlibs index 267f4976..5c026c84 100644 --- a/debian/shlibs +++ b/debian/shlibs @@ -1,15 +1,15 @@ -libshouldbeinlibc 0.2 hurd -libftpconn 0.2 hurd -libports 0.2 hurd -libthreads 0.2 hurd -libhurdbugaddr 0.2 hurd -libstore 0.2 hurd -libihash 0.2 hurd -libpipe 0.2 hurd -libtrivfs 0.2 hurd -libpager 0.2 hurd -libnetfs 0.2 hurd -libiohelp 0.2 hurd -libfshelp 0.2 hurd -libps 0.2 hurd -libdiskfs 0.2 hurd +libshouldbeinlibc 0.3 hurd (>= 20020804-1) +libftpconn 0.3 hurd (>= 20020804-1) +libports 0.3 hurd (>= 20020804-1) +libthreads 0.3 hurd (>= 20020804-1) +libhurdbugaddr 0.3 hurd (>= 20020804-1) +libstore 0.3 hurd (>= 20020804-1) +libihash 0.3 hurd (>= 20020804-1) +libpipe 0.3 hurd (>= 20020804-1) +libtrivfs 0.3 hurd (>= 20020804-1) +libpager 0.3 hurd (>= 20020804-1) +libnetfs 0.3 hurd (>= 20020804-1) +libiohelp 0.3 hurd (>= 20020804-1) +libfshelp 0.3 hurd (>= 20020804-1) +libps 0.3 hurd (>= 20020804-1) +libdiskfs 0.3 hurd (>= 20020804-1) diff --git a/debian/shlibs.local b/debian/shlibs.local index 910a73c7..e518f87d 100644 --- a/debian/shlibs.local +++ b/debian/shlibs.local @@ -1,15 +1,15 @@ -libshouldbeinlibc 0.2 -libftpconn 0.2 -libports 0.2 -libthreads 0.2 -libhurdbugaddr 0.2 -libstore 0.2 -libihash 0.2 -libpipe 0.2 -libtrivfs 0.2 -libpager 0.2 -libnetfs 0.2 -libiohelp 0.2 -libfshelp 0.2 -libps 0.2 -libdiskfs 0.2 +libshouldbeinlibc 0.3 +libftpconn 0.3 +libports 0.3 +libthreads 0.3 +libhurdbugaddr 0.3 +libstore 0.3 +libihash 0.3 +libpipe 0.3 +libtrivfs 0.3 +libpager 0.3 +libnetfs 0.3 +libiohelp 0.3 +libfshelp 0.3 +libps 0.3 +libdiskfs 0.3 -- cgit v1.2.3 From a3fecf07d573b6aa959400991e2a04e1989a406e Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 22 Aug 2002 21:25:04 +0000 Subject: 2002-08-22 Marcus Brinkmann * aclocal.m4 (hurd_LIB_NCURSESW): New test, modified from GNU inetutils 1.4.0. * configure.in: Use hurd_LIB_NCURSESW. * config.make.in (LIBNCURSESW): New variable, substituted by configure. (NCURSESW_INCLUDE): Likewise. * Makefile (lib-subdirs): Add libcons. (prog-subdirs): Add console. console/ 2002-08-22 Marcus Brinkmann * console.h: Move file to ../hurd/. * Makefile (LCLHDRS): Remove console.h. * display.c: Include instead "console.h". * console.c: Likewise. hurd/ 2002-08-22 Marcus Brinkmann * console.h: Move here from ../console/. * Makefile (INSTHDRS): Add console.h. utils/ 2002-08-22 Marcus Brinkmann * Makefile: Include `../config.make' early on to get LIBNCURSESW variable from configure before including Makeconf. (targets) [LIBNCURSES]: Add console-ncurses. (SRCS) [LIBNCURSES]: Add console-ncurses.c. (HURDLIBS) [LIBNCURSES]: Add cons. (console-ncurses): New target. (console-ncurses-CPPFLAGS): New variable. (console-ncurses-LDLIBS): Likewise. --- configure.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index c5cd14cd..91b178aa 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.32 2002/05/18 21:30:47 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.33 2002/08/22 21:25:03 marcus Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -178,6 +178,9 @@ AC_SUBST(boot_store_types)dnl AC_MSG_CHECKING(boot store types) AC_MSG_RESULT($boot_store_types) +# Check for ncursesw, which is needed for the console-curses client. +hurd_LIB_NCURSESW + if test -f ./$ac_unique_file; then # Configuring in source directory; don't create any Makefiles. makefiles= -- cgit v1.2.3 From 95143e01a33efc18f709db243a42bedd166be957 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 30 Aug 2002 00:27:32 +0000 Subject: 2002-08-26 Roland McGrath * configure.in: Check for uselocale function. --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 91b178aa..73f253ee 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.33 2002/08/22 21:25:03 marcus Exp $]) +AC_REVISION([$Id: configure.in,v 1.34 2002/08/30 00:27:32 roland Exp $]) AC_PREREQ(2.12) dnl Minimum Autoconf version required. AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. @@ -147,8 +147,8 @@ else fi AC_SUBST(VERSIONING) -# Check if libc contains getgrouplist(). -AC_CHECK_FUNCS(getgrouplist) +# Check if libc contains getgrouplist and/or uselocale. +AC_CHECK_FUNCS(getgrouplist uselocale) AC_ARG_WITH(parted, dnl [ --without-parted don't try to use GNU Parted libraries], -- cgit v1.2.3 From 2db6727730507d13edbb7cda64ec4ef26c8711f5 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 17 Sep 2002 17:36:36 +0000 Subject: 2002-09-17 Marcus Brinkmann * changelog: Update for new Debian package. --- debian/ChangeLog | 4 ++++ debian/changelog | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index f08e2868..907aa2d2 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,7 @@ +2002-09-17 Marcus Brinkmann + + * changelog: Update for new Debian package. + 2002-08-04 Marcus Brinkmann * control (Uploaders): New field, suggested by Jeff Bailey. diff --git a/debian/changelog b/debian/changelog index 75c1b193..931e52ea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +hurd (20020917-1) unstable; urgency=low + + * New snapshot from CVS. + kbd, mouse as usual. + Change terminal type to mach-color. + + -- Marcus Brinkmann Tue, 17 Sep 2002 18:13:06 +0200 + hurd (20020804-1) unstable; urgency=low * New snapshot from CVS. -- cgit v1.2.3 From 16329bd0e901012f78edc0d3d4567e3b67b7cff4 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 18 Sep 2002 21:21:58 +0000 Subject: Small date change because upload is delayed. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 931e52ea..f2146400 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -hurd (20020917-1) unstable; urgency=low +hurd (20020918-1) unstable; urgency=low * New snapshot from CVS. kbd, mouse as usual. Change terminal type to mach-color. - -- Marcus Brinkmann Tue, 17 Sep 2002 18:13:06 +0200 + -- Marcus Brinkmann Tue, 18 Sep 2002 23:13:06 +0200 hurd (20020804-1) unstable; urgency=low -- cgit v1.2.3 From 463e7ede15501a85dcf21d1b06633f8059d6dfea Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 29 Sep 2002 23:45:34 +0000 Subject: 2002-09-29 Marcus Brinkmann * control (Build-Depends): Add libncursesw5-dev. * changelog: Add a note about this here. --- debian/ChangeLog | 5 +++++ debian/changelog | 3 +++ debian/control | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 907aa2d2..30795c27 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,8 @@ +2002-09-29 Marcus Brinkmann + + * control (Build-Depends): Add libncursesw5-dev. + * changelog: Add a note about this here. + 2002-09-17 Marcus Brinkmann * changelog: Update for new Debian package. diff --git a/debian/changelog b/debian/changelog index f2146400..a6e3053d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,6 @@ + + * debian/control: Add libncursesw5-dev as build-dependency. + hurd (20020918-1) unstable; urgency=low * New snapshot from CVS. diff --git a/debian/control b/debian/control index 179c4ee7..c08a3d61 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: base Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 -Build-Depends: file, mig (>= 1.3-2), texinfo, tetex-bin, autoconf +Build-Depends: file, mig (>= 1.3-2), texinfo, tetex-bin, autoconf, libncursesw5-dev Uploaders: Marcus Brinkmann Package: hurd -- cgit v1.2.3 From 71d3ce15abd822ff64f395f8a06876c847515840 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 4 Oct 2002 20:55:48 +0000 Subject: 2002-10-03 Roland McGrath * dir.h (MAXNAMLEN): #undef before defining. --- ufs/dir.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ufs/dir.h b/ufs/dir.h index 2b1e3469..e37b1e9c 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -70,6 +70,7 @@ * dp->d_ino set to 0. */ #define DIRBLKSIZ DEV_BSIZE +#undef MAXNAMLEN #define MAXNAMLEN 255 /* Don't call this struct DIRECT because the library defines that -- cgit v1.2.3 From 03dc572901fa888f0ea0c57d2ab2fba5cea3ace5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 4 Oct 2002 20:55:55 +0000 Subject: . --- ufs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index f0776c59..e2409670 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +2002-10-03 Roland McGrath + + * dir.h (MAXNAMLEN): #undef before defining. + 2002-07-31 Roland McGrath * dir.c (diskfs_direnter_hard): Fix test in last change. -- cgit v1.2.3 From 94ce95c48cd543f6564b1cd7c47fb6d8ea6618fd Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 18 Nov 2002 21:11:19 +0000 Subject: 2002-11-18 Marcus Brinkmann * control (Uploader): Add Neal. * shlibs: Add pthreads. * rules: Add debian/tmp/lib/hurd/console/* to search path for shared objects. * changelog: Add Neal's last release and my upcoming. --- debian/ChangeLog | 8 ++++++++ debian/changelog | 18 +++++++++++++++++- debian/control | 2 +- debian/rules | 1 + debian/shlibs | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/debian/ChangeLog b/debian/ChangeLog index 30795c27..d8cb47c8 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,11 @@ +2002-11-18 Marcus Brinkmann + + * control (Uploader): Add Neal. + * shlibs: Add pthreads. + * rules: Add debian/tmp/lib/hurd/console/* to search path for + shared objects. + * changelog: Add Neal's last release and my upcoming. + 2002-09-29 Marcus Brinkmann * control (Build-Depends): Add libncursesw5-dev. diff --git a/debian/changelog b/debian/changelog index a6e3053d..6aac530e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,21 @@ +hurd (20021118-1) unstable; urgency=low - * debian/control: Add libncursesw5-dev as build-dependency. + * New snapshot from CVS. + kbd, mouse as usual, with bug fixes from David Walter. + Change terminal type to mach-color. + + -- Marcus Brinkmann Tue, 18 Nov 2002 21:32:22 +0200 + +hurd (20021011-1) unstable; urgency=low + + * New snapshot from CVS. + kbd, mouse as usual. + Build libpthread. + debian/control: Add libncursesw5-dev as build-dependency. + debian/shlibs: Add libpthread + debian/control: Add myself as an uploader. + + -- Neal H. Walfield Fri, 11 Oct 2002 21:42:21 -0400 hurd (20020918-1) unstable; urgency=low diff --git a/debian/control b/debian/control index c08a3d61..e02b70c5 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: required Maintainer: GNU Hurd Maintainers Standards-Version: 3.5.5.0 Build-Depends: file, mig (>= 1.3-2), texinfo, tetex-bin, autoconf, libncursesw5-dev -Uploaders: Marcus Brinkmann +Uploaders: Marcus Brinkmann , Neal H. Walfield Package: hurd Priority: required diff --git a/debian/rules b/debian/rules index f6365a2b..94ec8fe3 100755 --- a/debian/rules +++ b/debian/rules @@ -187,6 +187,7 @@ binary-arch: build `file debian/tmp/bin/* \ debian/tmp/hurd/* \ debian/tmp/lib/* \ + debian/tmp/lib/hurd/console/* \ debian/tmp/libexec/* \ debian/tmp/sbin/* \ | egrep '(executable.*dynamic)|(shared object)' \ diff --git a/debian/shlibs b/debian/shlibs index 5c026c84..54a3f7c1 100644 --- a/debian/shlibs +++ b/debian/shlibs @@ -13,3 +13,4 @@ libiohelp 0.3 hurd (>= 20020804-1) libfshelp 0.3 hurd (>= 20020804-1) libps 0.3 hurd (>= 20020804-1) libdiskfs 0.3 hurd (>= 20020804-1) +libpthread 0.3 hurd (>= 20021011-1) -- cgit v1.2.3 From ab3e8872dee7fa61eac22b732a9188f3ff287657 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 Feb 2003 23:57:50 +0000 Subject: 2002-10-23 Jeff Bailey Update for Autoconf 2.54. * configure.in: Replace AC_FD_CC with AS_MESSAGE_LOG_FD. (AC_PREREQ): Require Autoconf 2.54. (AC_INIT): Update to no arguments syntax. Call AC_CONFIG_SRCDIR. (AC_OUTPUT): Update to no arguments syntax. Call AC_CONFIG_FILES. (AC_CHECK_TOOL, hurd_PROG_CC): Replace with ... (AC_PROG_CC): ... this. * aclocal.m4: Replace AC_FD_CC with AS_MESSAGE_LOG_FD. (hurd_PROG_CC, hurd_PROG_CC_WORKS): Removed. --- configure.in | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 73f253ee..8d493da5 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,8 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.34 2002/08/30 00:27:32 roland Exp $]) -AC_PREREQ(2.12) dnl Minimum Autoconf version required. -AC_INIT(hurd/hurd_types.h) dnl A distinctive file to look for in srcdir. +AC_REVISION([$Id: configure.in,v 1.35 2003/02/15 23:57:50 roland Exp $]) +AC_PREREQ(2.54) dnl Minimum Autoconf version required. +AC_INIT +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. @@ -75,10 +76,7 @@ AC_SUBST(enable_static_progs) AC_PROG_INSTALL AC_PROG_AWK -AC_CHECK_TOOL(CC, gcc) -# That check handles cross-compilation well, but AC_PROG_CC tests for GCC -# and sets default CFLAGS nicely for us, so do that too. -hurd_PROG_CC +AC_PROG_CC # Require GCC. if test x$GCC != xyes; then AC_MSG_ERROR([this code uses GNU C extensions, you must compile with GCC]) @@ -114,11 +112,11 @@ VERS_2 { } VERS_1; EOF -if AC_TRY_COMMAND([eval $ac_compile 1>&AC_FD_CC]) && +if AC_TRY_COMMAND([eval $ac_compile 1>&AS_MESSAGE_LOG_FD()]) && AC_TRY_COMMAND([${CC-cc} $CFLAGS -shared -o conftest.so conftest.o -nostartfiles -nostdlib -Wl,--version-script,conftest.map - 1>&AC_FD_CC]); then + 1>&AS_MESSAGE_LOG_FD()]); then hurd_cv_ld_version_script_option=yes else hurd_cv_ld_version_script_option=no @@ -193,7 +191,8 @@ else echo ${file}:build.mk.in; done`" fi -AC_OUTPUT(config.make ${makefiles}) +AC_CONFIG_FILES([config.make ${makefiles}]) +AC_OUTPUT dnl Local Variables: dnl comment-start: "dnl " -- cgit v1.2.3 From 123aa4f6626fb1f55449efd262563af49cdfe89b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 15 Feb 2003 23:58:22 +0000 Subject: 2003-02-15 Roland McGrath * configure: New generated file, now in the repository. --- configure | 4211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4211 insertions(+) create mode 100755 configure diff --git a/configure b/configure new file mode 100755 index 00000000..61a485a4 --- /dev/null +++ b/configure @@ -0,0 +1,4211 @@ +#! /bin/sh +# From configure.in Id: configure.in,v 1.35 2003/02/15 23:57:50 roland Exp . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.57. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="hurd/hurd_types.h" +ac_default_prefix= +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os asm_syntax enable_profile enable_static_progs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LD ac_ct_LD OBJCOPY ac_ct_OBJCOPY AR ac_ct_AR RANLIB ac_ct_RANLIB MIG ac_ct_MIG LIBCRYPT VERSIONING boot_store_types NCURSESW_INCLUDE LIBNCURSESW LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS + +# +# Report the --help message. +# +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. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-profile do not build profiled libraries and programs + --enable-static-progs=PROGRAMS... + build statically-linked PROGRAM.static versions + of (only) the listed programs ext2fs,ufs + --enable-boot-store-types=TYPES... + list of store types included in statically + linked filesystems used for booting + --disable-ncursesw Do not use ncursesw + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --without-parted don't try to use GNU Parted libraries + --with-ncursesw-include-dir=DIR + Set directory containing the include files for + use with -lncursesw, when it isn't installed as + the default curses library. If DIR is "none", + then no special ncursesw include files are used. + --without-ncursesw-include-dir + Equivalent to --with-ncursesw-include-dir=none + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_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 +generated by GNU Autoconf 2.57. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +case "$host_os" in +gnu*) ;; +none) { { echo "$as_me:$LINENO: 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." >&5 +echo "$as_me: 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." >&2;} + { (exit 1); exit 1; }; } ;; +*) { { echo "$as_me:$LINENO: 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." >&5 +echo "$as_me: 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." >&2;} + { (exit 1); exit 1; }; } ;; +esac + +case "$host_cpu" in +alpha*) + asm_syntax=alpha + ;; +arm*) + asm_syntax=arm + ;; +m68k | m680?0) + asm_syntax=m68k + ;; +mips*) + asm_syntax=mips + ;; +i?86) + asm_syntax=i386 + ;; +powerpc*) + asm_syntax=ppc + ;; +sparc64* | ultrasparc*) + asm_syntax=sparc64 + ;; +sparc*) + asm_syntax=sparc + ;; +*) + asm_syntax="$host_cpu" + ;; +esac + + +test -r "$srcdir/libthreads/$asm_syntax/cthreads.h" || { + { echo "$as_me:$LINENO: WARNING: unsupported CPU type $host_cpu" >&5 +echo "$as_me: WARNING: unsupported CPU type $host_cpu" >&2;} +} + +# Check whether --enable-profile or --disable-profile was given. +if test "${enable_profile+set}" = set; then + enableval="$enable_profile" + +fi; + + +# Check whether --enable-static-progs or --disable-static-progs was given. +if test "${enable_static_progs+set}" = set; then + enableval="$enable_static_progs" + +fi; +case "$enable_static_progs" in +'no') enable_static_progs= ;; # we got --disable-static +'') enable_static_progs='ext2fs,ufs' ;; +esac +# Convert comma/space-separated list into space-separated list. +enable_static_progs=`echo "$enable_static_progs" | sed 's/[, ][, ]*/ /g'` + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# Require GCC. +if test x$GCC != xyes; then + { { echo "$as_me:$LINENO: error: this code uses GNU C extensions, you must compile with GCC" >&5 +echo "$as_me: error: this code uses GNU C extensions, you must compile with GCC" >&2;} + { (exit 1); exit 1; }; } +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. +set dummy ${ac_tool_prefix}ld; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LD="${ac_tool_prefix}ld" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LD=$ac_cv_prog_LD +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_LD"; then + ac_ct_LD=$LD + # Extract the first word of "ld", so it can be a program name with args. +set dummy ld; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_LD"; then + ac_cv_prog_ac_ct_LD="$ac_ct_LD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LD="ld" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_LD=$ac_cv_prog_ac_ct_LD +if test -n "$ac_ct_LD"; then + echo "$as_me:$LINENO: result: $ac_ct_LD" >&5 +echo "${ECHO_T}$ac_ct_LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + LD=$ac_ct_LD +else + LD="$ac_cv_prog_LD" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. +set dummy ${ac_tool_prefix}objcopy; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_OBJCOPY+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$OBJCOPY"; then + ac_cv_prog_OBJCOPY="$OBJCOPY" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJCOPY="${ac_tool_prefix}objcopy" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +OBJCOPY=$ac_cv_prog_OBJCOPY +if test -n "$OBJCOPY"; then + echo "$as_me:$LINENO: result: $OBJCOPY" >&5 +echo "${ECHO_T}$OBJCOPY" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_OBJCOPY"; then + ac_ct_OBJCOPY=$OBJCOPY + # Extract the first word of "objcopy", so it can be a program name with args. +set dummy objcopy; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_OBJCOPY"; then + ac_cv_prog_ac_ct_OBJCOPY="$ac_ct_OBJCOPY" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJCOPY="objcopy" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY +if test -n "$ac_ct_OBJCOPY"; then + echo "$as_me:$LINENO: result: $ac_ct_OBJCOPY" >&5 +echo "${ECHO_T}$ac_ct_OBJCOPY" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + OBJCOPY=$ac_ct_OBJCOPY +else + OBJCOPY="$ac_cv_prog_OBJCOPY" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + AR=$ac_ct_AR +else + AR="$ac_cv_prog_AR" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args. +set dummy ${ac_tool_prefix}mig; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_MIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$MIG"; then + ac_cv_prog_MIG="$MIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MIG="${ac_tool_prefix}mig" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +MIG=$ac_cv_prog_MIG +if test -n "$MIG"; then + echo "$as_me:$LINENO: result: $MIG" >&5 +echo "${ECHO_T}$MIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_MIG"; then + ac_ct_MIG=$MIG + # Extract the first word of "mig", so it can be a program name with args. +set dummy mig; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_MIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_MIG"; then + ac_cv_prog_ac_ct_MIG="$ac_ct_MIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MIG="mig" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_MIG=$ac_cv_prog_ac_ct_MIG +if test -n "$ac_ct_MIG"; then + echo "$as_me:$LINENO: result: $ac_ct_MIG" >&5 +echo "${ECHO_T}$ac_ct_MIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + MIG=$ac_ct_MIG +else + MIG="$ac_cv_prog_MIG" +fi + + + + +# See if there's a separate libcrypt (many systems put crypt there). + +echo "$as_me:$LINENO: checking for crypt in -lcrypt" >&5 +echo $ECHO_N "checking for crypt in -lcrypt... $ECHO_C" >&6 +if test "${ac_cv_lib_crypt_crypt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypt $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char crypt (); +int +main () +{ +crypt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_crypt_crypt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_crypt_crypt=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_crypt_crypt" >&5 +echo "${ECHO_T}$ac_cv_lib_crypt_crypt" >&6 +if test $ac_cv_lib_crypt_crypt = yes; then + LIBCRYPT=-lcrypt +fi + + + +# See if mig groks `retcode'. +echo "$as_me:$LINENO: checking whether $MIG supports the retcode keyword" >&5 +echo $ECHO_N "checking whether $MIG supports the retcode keyword... $ECHO_C" >&6 +if test "${hurd_cv_mig_retcode+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat > conftest.defs <<\EOF +#include +#include +subsystem foobar 1000; +type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t; +simpleroutine foobar_reply ( + reply_port: reply_port_t; + err: kern_return_t, RetCode); +EOF +if { ac_try='CC="${CC}" ${MIG-false} -n conftest.defs 1>&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + hurd_cv_mig_retcode=yes +else + hurd_cv_mig_retcode=no +fi +rm -f conftest* +fi +echo "$as_me:$LINENO: result: $hurd_cv_mig_retcode" >&5 +echo "${ECHO_T}$hurd_cv_mig_retcode" >&6 +if test $hurd_cv_mig_retcode = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_MIG_RETCODE 1 +_ACEOF + +fi + +# See if --version-script is available. +echo "$as_me:$LINENO: checking for ld --version-script" >&5 +echo $ECHO_N "checking for ld --version-script... $ECHO_C" >&6 +if test "${hurd_cv_ld_version_script_option+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat > conftest.c <<\EOF +void foobar() {} +EOF +cat > conftest.map <<\EOF +VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +EOF + +if { ac_try='eval $ac_compile 1>&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o + -nostartfiles -nostdlib + -Wl,--version-script,conftest.map + 1>&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + hurd_cv_ld_version_script_option=yes +else + hurd_cv_ld_version_script_option=no +fi +rm -f conftest* +fi +echo "$as_me:$LINENO: result: $hurd_cv_ld_version_script_option" >&5 +echo "${ECHO_T}$hurd_cv_ld_version_script_option" >&6 + +# See if libc was built with --enable-libio. +echo "$as_me:$LINENO: checking for libio" >&5 +echo $ECHO_N "checking for libio... $ECHO_C" >&6 +if test "${hurd_cv_libio+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifndef _STDIO_USES_IOSTREAM +# error No libio found. +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + hurd_cv_libio=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +hurd_cv_libio=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $hurd_cv_libio" >&5 +echo "${ECHO_T}$hurd_cv_libio" >&6 + +# The versions of the symbols in libthreads have to match those in +# libc.so. Since the symbols in a libc that includes libio will be +# versioned differently from the ones in a libc that uses stdio, this +# isn't easy to accomplish. Instead we leave things unversioned if +# libio isn't found. +if test $hurd_cv_libio = yes; then + VERSIONING=$hurd_cv_ld_version_script_option +else + VERSIONING=no +fi + + +# Check if libc contains getgrouplist and/or uselocale. + + +for ac_func in getgrouplist uselocale +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ +#ifdef __STDC__ +# include +#else +# include +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +# Check whether --with-parted or --without-parted was given. +if test "${with_parted+set}" = set; then + withval="$with_parted" + +else + with_parted=yes +fi; + +# Check whether --enable-boot-store-types or --disable-boot-store-types was given. +if test "${enable_boot_store_types+set}" = set; then + enableval="$enable_boot_store_types" + +fi; if test -z "$enable_boot_store_types"; then + boot_store_types='device remap gunzip bunzip2' + + # Check for Parted's static store module. + if test "x$with_parted" != xno; then + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -static" + echo "$as_me:$LINENO: checking for store_part_open in -lstore_part" >&5 +echo $ECHO_N "checking for store_part_open in -lstore_part... $ECHO_C" >&6 +if test "${ac_cv_lib_store_part_store_part_open+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lstore_part -luuid -lstore $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char store_part_open (); +int +main () +{ +store_part_open (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_store_part_store_part_open=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_store_part_store_part_open=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_store_part_store_part_open" >&5 +echo "${ECHO_T}$ac_cv_lib_store_part_store_part_open" >&6 +if test $ac_cv_lib_store_part_store_part_open = yes; then + boot_store_types="$boot_store_types part" +fi + + LDFLAGS="$save_LDFLAGS" + fi +elif test "x$enable_boot_store_types" = xno; then + { echo "$as_me:$LINENO: WARNING: you probably wanted --disable-static-progs" >&5 +echo "$as_me: WARNING: you probably wanted --disable-static-progs" >&2;} +else + boot_store_types="$enable_boot_store_types" +fi +echo "$as_me:$LINENO: checking boot store types" >&5 +echo $ECHO_N "checking boot store types... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $boot_store_types" >&5 +echo "${ECHO_T}$boot_store_types" >&6 + +# Check for ncursesw, which is needed for the console-curses client. + + # Check whether --enable-ncursesw or --disable-ncursesw was given. +if test "${enable_ncursesw+set}" = set; then + enableval="$enable_ncursesw" + +else + enable_ncursesw=yes +fi; + if test "$enable_ncursesw" = yes; then + echo "$as_me:$LINENO: checking for initscr in -lncursesw" >&5 +echo $ECHO_N "checking for initscr in -lncursesw... $ECHO_C" >&6 +if test "${ac_cv_lib_ncursesw_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncursesw $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ncursesw_initscr=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ncursesw_initscr=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_ncursesw_initscr" >&6 +if test $ac_cv_lib_ncursesw_initscr = yes; then + LIBNCURSESW="-lncursesw" +fi + + if test "$LIBNCURSESW"; then + +# Check whether --with-ncursesw-include-dir or --without-ncursesw-include-dir was given. +if test "${with_ncursesw_include_dir+set}" = set; then + withval="$with_ncursesw_include_dir" + +fi; if test "${with_ncursesw_include_dir+set}" = set; then + echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 +echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6 + case "$with_ncursesw_include_dir" in + no|none) + hurd_cv_includedir_ncursesw=none;; + *) + hurd_cv_includedir_ncursesw="$with_ncursesw_include_dir";; + esac + echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 +echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6 + else + echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 +echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6 +if test "${hurd_cv_includedir_ncursesw+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + for D in $includedir $prefix/include /local/include /usr/local/include /include /usr/include; do + if test -d $D/ncursesw; then + hurd_cv_includedir_ncursesw="$D/ncursesw" + break + fi + test "$hurd_cv_includedir_ncursesw" \ + || hurd_cv_includedir_ncursesw=none + done +fi +echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 +echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6 + fi + if test "$hurd_cv_includedir_ncursesw" = none; then + NCURSESW_INCLUDE="" + else + NCURSESW_INCLUDE="-I$hurd_cv_includedir_ncursesw" + fi + fi + fi + + + +if test -f ./$ac_unique_file; then + # Configuring in source directory; don't create any Makefiles. + makefiles= +else + # We are configuring in a separate build tree. + # Create a Makefile in the top-level build directory and + # one for each subdirectory Makefile in the source. + makefiles="Makeconf:build.mkcf.in \ + `cd $srcdir; for file in Makefile */Makefile; do \ + echo ${file}:build.mk.in; done`" +fi + + ac_config_files="$ac_config_files config.make ${makefiles}" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.57, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "config.make" ) CONFIG_FILES="$CONFIG_FILES config.make" ;; + "${makefiles}" ) CONFIG_FILES="$CONFIG_FILES ${makefiles}" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@asm_syntax@,$asm_syntax,;t t +s,@enable_profile@,$enable_profile,;t t +s,@enable_static_progs@,$enable_static_progs,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@AWK@,$AWK,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@LD@,$LD,;t t +s,@ac_ct_LD@,$ac_ct_LD,;t t +s,@OBJCOPY@,$OBJCOPY,;t t +s,@ac_ct_OBJCOPY@,$ac_ct_OBJCOPY,;t t +s,@AR@,$AR,;t t +s,@ac_ct_AR@,$ac_ct_AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@MIG@,$MIG,;t t +s,@ac_ct_MIG@,$ac_ct_MIG,;t t +s,@LIBCRYPT@,$LIBCRYPT,;t t +s,@VERSIONING@,$VERSIONING,;t t +s,@boot_store_types@,$boot_store_types,;t t +s,@NCURSESW_INCLUDE@,$NCURSESW_INCLUDE,;t t +s,@LIBNCURSESW@,$LIBNCURSESW,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + + -- cgit v1.2.3 From 0ca1a04ce9bbf12356d73e9a3dfde141400a31f7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 7 May 2003 13:41:58 +0000 Subject: . --- serverboot/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index 68f6cbe8..e532d2a7 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +2003-05-07 Ognyan Kulev + + * strfcns.c: #include instead of . + (strbuild): Use -style for handling variable argument + list. + * load.c: Don't #include . + 2002-07-03 Roland McGrath * elf-load.c (exec_load): Fix e_machine checking. -- cgit v1.2.3 From de1fc902c7f387657d792191efb092127950c08c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 7 May 2003 13:42:14 +0000 Subject: 2003-05-07 Ognyan Kulev * strfcns.c: #include instead of . (strbuild): Use -style for handling variable argument list. * load.c: Don't #include . --- serverboot/load.c | 1 - serverboot/strfcns.c | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/serverboot/load.c b/serverboot/load.c index e95a64d7..aa481943 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "mach-exec.h" #include "../boot/boot_script.h" diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 82a76728..cbead7e4 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -27,7 +27,7 @@ * Character subroutines */ -#include +#include #define EXPORT_BOOLEAN #include @@ -40,21 +40,20 @@ */ /*VARARGS1*/ char * -strbuild(dest, va_alist) - register char * dest; - va_dcl +strbuild(char *dest, ...) { va_list argptr; register char * src; register int c; - va_start(argptr); + 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); } -- cgit v1.2.3 From bdbf8298282447e1e2fed4140329846d532275c6 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 29 Jul 2003 16:25:28 +0000 Subject: 2003-07-29 Marcus Brinkmann * fsck.h (num_files): Change type to long. --- ufs-fsck/ChangeLog | 4 ++++ ufs-fsck/fsck.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ufs-fsck/ChangeLog b/ufs-fsck/ChangeLog index 6415a78a..c050a94e 100644 --- a/ufs-fsck/ChangeLog +++ b/ufs-fsck/ChangeLog @@ -1,3 +1,7 @@ +2003-07-29 Marcus Brinkmann + + * fsck.h (num_files): Change type to long. + 2002-06-13 Roland McGrath * fsck.h (struct dirinfo): Revert i_isize to using u_int. diff --git a/ufs-fsck/fsck.h b/ufs-fsck/fsck.h index e80dfc84..4a5dabf5 100644 --- a/ufs-fsck/fsck.h +++ b/ufs-fsck/fsck.h @@ -124,7 +124,7 @@ extern int fsmodified; extern ino_t lfdir; /* Total number of files found on the partition. */ -extern daddr_t num_files; +extern long num_files; extern mode_t lfmode; extern char *lfname; -- cgit v1.2.3 From 993c89ad6e8b6413bab81e0720dd55d60d2f8173 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 3 Aug 2003 14:23:21 +0000 Subject: Remove file that shouldn't be there. --- ufs/mapbuf.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 ufs/mapbuf.c diff --git a/ufs/mapbuf.c b/ufs/mapbuf.c deleted file mode 100644 index edf432a5..00000000 --- a/ufs/mapbuf.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Cache mappings of the disk - Copyright (C) 1994 Free Software Foundation, Inc. - Written by Michael I. Bushnell. - - 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. */ - - -#include "ufs.h" - -struct mapbuf *mblist; -spin_lock_t mblistlock = SPIN_LOCK_INITIALIZER; - -struct mapbuf * -map_region (vm_offset_t diskloc, vm_size_t length) -{ - struct mapbuf *mb; - - /* Check to see if we are already mapping this region */ - spin_lock (&mblistlock); - for (mb = mblist; mb; mb = mb->next) - { - -- cgit v1.2.3 From 1464abbace6e7175ea53641a9702044e7f58bcfc Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Mon, 27 Oct 2003 20:18:57 +0000 Subject: Gratuitous commit to test IRC log notification --- debian/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/Makefile b/debian/Makefile index 7afd6dc7..f94ee802 100644 --- a/debian/Makefile +++ b/debian/Makefile @@ -1,4 +1,4 @@ -# Makefile for Debian Hurd packaging directory +# Makefile for Debian Hurd packaging directory # Copyright (C) 1999 Free Software Foundation, Inc. # Gordon Matzigkeit , 1999-03-17 # -- cgit v1.2.3 From 5b514b7415bc5ac73f8bc3f4ad77a36838aebe3b Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Mon, 27 Oct 2003 20:22:37 +0000 Subject: Another gratuitous commit to test my fix for my typo --- debian/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/Makefile b/debian/Makefile index f94ee802..7afd6dc7 100644 --- a/debian/Makefile +++ b/debian/Makefile @@ -1,4 +1,4 @@ -# Makefile for Debian Hurd packaging directory +# Makefile for Debian Hurd packaging directory # Copyright (C) 1999 Free Software Foundation, Inc. # Gordon Matzigkeit , 1999-03-17 # -- cgit v1.2.3 From 476c33fb54335f1e64969e8ddb9a589fa7f33571 Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Mon, 27 Oct 2003 20:37:14 +0000 Subject: Another gratuitous commit --- debian/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/Makefile b/debian/Makefile index 7afd6dc7..f94ee802 100644 --- a/debian/Makefile +++ b/debian/Makefile @@ -1,4 +1,4 @@ -# Makefile for Debian Hurd packaging directory +# Makefile for Debian Hurd packaging directory # Copyright (C) 1999 Free Software Foundation, Inc. # Gordon Matzigkeit , 1999-03-17 # -- cgit v1.2.3 From fa29e3786497eee9ede7ae0886f6cf0e659130c3 Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Tue, 28 Oct 2003 15:43:52 +0000 Subject: Gratuitous commit for final test --- debian/README.Debian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/README.Debian b/debian/README.Debian index 6d0c3b8b..2e62dc8d 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,5 +1,5 @@ GNU Hurd for Debian -------------------- +=================== This is the Hurd release for Debian GNU/Hurd. It contains essential system software and libraries. -- cgit v1.2.3 From 5031bec048c9c840c6f8e9dfa211f8fdedd12d52 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 18 Mar 2004 21:19:06 +0000 Subject: 2004-03-14 Marcus Brinkmann * README.CVS: New file. --- README.CVS | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 README.CVS diff --git a/README.CVS b/README.CVS new file mode 100644 index 00000000..781acdeb --- /dev/null +++ b/README.CVS @@ -0,0 +1,22 @@ +-*- Text -*- +GNU Hurd CVS version. + + +This is the Hurd. Welcome. + +For installation instructions, you might try your luck with the files +README, INSTALL, and INSTALL-cross. However, they have not been +updated for a long time. + +For now, this file documents the version requirements for the CVS +version of the Hurd. Other combinations might work, but the stated +minimum requirements are best tested by the developers. + +GNU MiG at least 1.3 +GNU Mach at least 1.3 +GNU C library CVS from 2004-03-09 or later +GNU C compiler at least 3.3.2 + +Obviously, you also need somewhat recent versions of binutils, make, +bash and some other tools. No hard requirements are currently known +for these, though. -- cgit v1.2.3 From faf99c4817bcc8a4dd0f5f24743db9efa8df6447 Mon Sep 17 00:00:00 2001 From: "Alfred M. Szmidt" Date: Thu, 7 Apr 2005 20:48:41 +0000 Subject: 2005-04-07 Alfred M. Szmidt * configure.in: Error out if MiG couldn't be found. * configure: Regenerated. --- configure | 560 +++++++++++++++++++++++++++++++++++++++-------------------- configure.in | 10 +- 2 files changed, 385 insertions(+), 185 deletions(-) diff --git a/configure b/configure index 61a485a4..e335a198 100755 --- a/configure +++ b/configure @@ -1,10 +1,9 @@ #! /bin/sh # From configure.in Id: configure.in,v 1.35 2003/02/15 23:57:50 roland Exp . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.57. +# Generated by GNU Autoconf 2.59. # -# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -21,9 +20,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -42,7 +42,7 @@ for as_var in \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -219,16 +219,17 @@ rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -632,7 +633,7 @@ done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir + localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in @@ -672,10 +673,10 @@ if test -z "$srcdir"; then # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -763,9 +764,9 @@ _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -869,12 +870,45 @@ case $srcdir in ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. @@ -885,13 +919,13 @@ ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then + test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd $ac_popdir + cd "$ac_popdir" done fi @@ -899,8 +933,7 @@ test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -912,7 +945,7 @@ 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 -generated by GNU Autoconf 2.57. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -989,19 +1022,19 @@ do 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. + ac_must_keep_next=false # Got value, back to normal. else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. @@ -1035,12 +1068,12 @@ _ASBOX case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } @@ -1069,7 +1102,7 @@ _ASBOX for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi @@ -1088,7 +1121,7 @@ _ASBOX echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core core.* *.core && + rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 @@ -1168,7 +1201,7 @@ fi # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" @@ -1185,13 +1218,13 @@ echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. @@ -1411,6 +1444,7 @@ enable_static_progs=`echo "$enable_static_progs" | sed 's/[, ][, ]*/ /g'` # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 @@ -1427,6 +1461,7 @@ do case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -1434,20 +1469,20 @@ case $as_dir/ in # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done done ;; @@ -1854,7 +1889,6 @@ ac_compiler=`set X $ac_compile; echo $2` (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -1874,8 +1908,8 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output" >&5 -echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 @@ -1895,23 +1929,23 @@ do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; + ;; conftest.$ac_ext ) - # This is the source file. - ;; + # This is the source file. + ;; [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; + # We found the default executable, but exeext='' is most + # certainly right. + break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; * ) - break;; + break;; esac done else @@ -1985,8 +2019,8 @@ for ac_file in conftest.exe conftest conftest.*; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; + export ac_cv_exeext + break;; * ) break;; esac done @@ -2011,7 +2045,6 @@ if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2062,7 +2095,6 @@ if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2082,11 +2114,20 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2099,7 +2140,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi @@ -2115,7 +2156,6 @@ if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2132,11 +2172,20 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2149,7 +2198,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 @@ -2176,7 +2225,6 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2204,6 +2252,16 @@ static char *f (char * (*g) (char **, int), char **p, ...) va_end (v); return s; } + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2230,11 +2288,20 @@ do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2247,7 +2314,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext +rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC @@ -2275,19 +2342,27 @@ cat >conftest.$ac_ext <<_ACEOF _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ - ''\ - '#include ' \ + '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ @@ -2295,14 +2370,13 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include $ac_declaration +#include int main () { @@ -2313,11 +2387,20 @@ exit (42); _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2330,9 +2413,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 continue fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2349,11 +2431,20 @@ exit (42); _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2365,7 +2456,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then @@ -2379,7 +2470,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2788,6 +2879,20 @@ else MIG="$ac_cv_prog_MIG" fi +# Require MiG. +if test x${MIG} = x; then + { { echo "$as_me:$LINENO: error: +*** You need GNU MiG to compile the GNU Hurd, please see +*** http://www.gnu.org/software/hurd/mig.html for further details, or +*** download it directly from the main GNU server (ftp.gnu.org) or any +*** GNU mirror." >&5 +echo "$as_me: error: +*** You need GNU MiG to compile the GNU Hurd, please see +*** http://www.gnu.org/software/hurd/mig.html for further details, or +*** download it directly from the main GNU server (ftp.gnu.org) or any +*** GNU mirror." >&2;} + { (exit 1); exit 1; }; } +fi @@ -2801,7 +2906,6 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypt $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2825,11 +2929,20 @@ crypt (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2842,7 +2955,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_crypt_crypt=no fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_crypt_crypt" >&5 @@ -2940,7 +3054,6 @@ if test "${hurd_cv_libio+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2960,11 +3073,20 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2977,7 +3099,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 hurd_cv_libio=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $hurd_cv_libio" >&5 echo "${ECHO_T}$hurd_cv_libio" >&6 @@ -3006,21 +3128,28 @@ if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ + #ifdef __STDC__ # include #else # include #endif + +#undef $ac_func + /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" @@ -3051,11 +3180,20 @@ return f != $ac_func; _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3068,7 +3206,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 @@ -3109,7 +3248,6 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lstore_part -luuid -lstore $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3133,11 +3271,20 @@ store_part_open (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3150,7 +3297,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_store_part_store_part_open=no fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_store_part_store_part_open" >&5 @@ -3190,7 +3338,6 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lncursesw $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3214,11 +3361,20 @@ initscr (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3231,7 +3387,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ncursesw_initscr=no fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 @@ -3327,13 +3484,13 @@ _ACEOF # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | @@ -3363,13 +3520,13 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ + ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; +s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; -s/^[^=]*=[ ]*$//; +s/^[^=]*=[ ]*$//; }' fi @@ -3383,13 +3540,13 @@ fi cat >confdef2opt.sed <<\_ACEOF t clear : clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote d : quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g s,\[,\\&,g s,\],\\&,g s,\$,$$,g @@ -3411,7 +3568,7 @@ ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' @@ -3455,9 +3612,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -3476,7 +3634,7 @@ for as_var in \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -3655,16 +3813,17 @@ rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -3691,7 +3850,7 @@ _ASBOX cat >&5 <<_CSEOF This file was extended by $as_me, which was -generated by GNU Autoconf 2.57. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3735,7 +3894,7 @@ Usage: $0 [OPTIONS] [FILE]... -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + instantiate the configuration file FILE Configuration files: $config_files @@ -3746,11 +3905,10 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.57, +configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir @@ -4002,9 +4160,9 @@ _ACEOF (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end @@ -4022,21 +4180,21 @@ for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -4052,10 +4210,10 @@ echo X"$ac_file" | as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -4093,12 +4251,45 @@ case $srcdir in ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac case $INSTALL in @@ -4106,11 +4297,6 @@ ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -4120,7 +4306,7 @@ echo "$as_me: creating $ac_file" >&6;} configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." + sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. @@ -4129,26 +4315,32 @@ echo "$as_me: creating $ac_file" >&6;} case $f in -) echo $tmp/stdin ;; [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - echo $f;; + echo "$f";; *) # Relative - if test -f "$f"; then - # Build tree - echo $f - elif test -f "$srcdir/$f"; then - # Source tree - echo $srcdir/$f - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - fi;; + fi;; esac done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub diff --git a/configure.in b/configure.in index 8d493da5..74fc9d13 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.35 2003/02/15 23:57:50 roland Exp $]) +AC_REVISION([$Id: configure.in,v 1.36 2005/04/07 20:48:40 ams Exp $]) AC_PREREQ(2.54) dnl Minimum Autoconf version required. AC_INIT AC_CONFIG_SRCDIR([hurd/hurd_types.h]) dnl File to look for in srcdir. @@ -87,6 +87,14 @@ AC_CHECK_TOOL(OBJCOPY, objcopy) AC_CHECK_TOOL(AR, ar) AC_CHECK_TOOL(RANLIB, ranlib) AC_CHECK_TOOL(MIG, mig) +# Require MiG. +if test x${MIG} = x; then + AC_MSG_ERROR([ +*** You need GNU MiG to compile the GNU Hurd, please see +*** http://www.gnu.org/software/hurd/mig.html for further details, or +*** download it directly from the main GNU server (ftp.gnu.org) or any +*** GNU mirror.]) +fi dnl Let these propagate from the environment. AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) -- cgit v1.2.3 From b3e5743bb26240cf69b2822446231178c50e2d9e Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 14 Mar 2006 23:26:37 +0000 Subject: 2006-03-15 Thomas Schwinge * dir.h (DIRECT_NAMELEN): Don't use ?: as a lvalue. --- ufs/ChangeLog | 4 ++++ ufs/dir.h | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index e2409670..aa30e784 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,7 @@ +2006-03-15 Thomas Schwinge + + * dir.h (DIRECT_NAMELEN): Don't use ?: as a lvalue. + 2002-10-03 Roland McGrath * dir.h (MAXNAMLEN): #undef before defining. diff --git a/ufs/dir.h b/ufs/dir.h index e37b1e9c..5730ef44 100644 --- a/ufs/dir.h +++ b/ufs/dir.h @@ -91,13 +91,13 @@ struct directory_entry { /* Return the namlen from a struct direct, paying attention to whether this filesystem supports the type extension */ #if (BYTE_ORDER == LITTLE_ENDIAN) -#define DIRECT_NAMLEN(dp) (direct_symlink_extension || swab_disk \ - ? (dp)->d_namlen \ - : (dp)->d_type) +#define DIRECT_NAMLEN(dp) (*(direct_symlink_extension || swab_disk \ + ? &(dp)->d_namlen \ + : &(dp)->d_type)) #else -#define DIRECT_NAMLEN(dp) (!direct_symlink_extension && swab_disk \ - ? (dp)->d_type \ - : (dp)->d_namlen) +#define DIRECT_NAMLEN(dp) (*(!direct_symlink_extension && swab_disk \ + ? &(dp)->d_type \ + : &(dp)->d_namlen)) #endif /* -- cgit v1.2.3 From 1f1bc868258f571e92492e5273fd60bf9a8da244 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 14 Mar 2006 23:27:50 +0000 Subject: 2006-03-15 Thomas Schwinge * mkfs.c (parse_opt): Move UP's functionality into UP_INT in order to fix invalid lvalues. --- ufs-utils/ChangeLog | 5 +++++ ufs-utils/mkfs.c | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ufs-utils/ChangeLog b/ufs-utils/ChangeLog index f65e9ce1..24b373c0 100644 --- a/ufs-utils/ChangeLog +++ b/ufs-utils/ChangeLog @@ -1,3 +1,8 @@ +2006-03-15 Thomas Schwinge + + * mkfs.c (parse_opt): Move UP's functionality into UP_INT in order to + fix invalid lvalues. + 2002-06-08 Roland McGrath * mkfs.c (iput): Use %Ld format for ino_t values. diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c index f423f003..aef3ea92 100644 --- a/ufs-utils/mkfs.c +++ b/ufs-utils/mkfs.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/ -static char *rcsid = "$Id: mkfs.c,v 1.21 2002/06/11 21:43:19 roland Exp $"; +static char *rcsid = "$Id: mkfs.c,v 1.22 2006/03/14 23:27:50 tschwinge Exp $"; #endif /* not lint */ #include @@ -279,10 +279,8 @@ main (int argc, char **argv) case 'N': Nflag = 1; break; case 'O': Oflag = 1; break; - /* Mark &VAR as being a uparam, and return a lvalue for VAR. */ -#define UP(var) (amarks_add (&uparams, &var), var) - /* Record an integer uparam into VAR. */ -#define UP_INT(var) { int _i = atoi (arg); UP (var) = _i; } +/* Mark &VAR as being a uparam, and set VAR. */ +#define UP_INT(var) { amarks_add (&uparams, &var); var = atoi (arg); } case 'a': UP_INT (maxcontig); break; case 'b': UP_INT (bsize); break; -- cgit v1.2.3 From cd41545494ae5aa662a40f2737daa1b7f96b3c2d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 14 Mar 2006 23:34:24 +0000 Subject: 2006-03-15 Alfred M. Szmidt * kalloc.c: #include . (init_hook, malloc_hook, free_hook): New functions. (__malloc_initialize_hook): New variable. (malloc, free): Functions removed. --- serverboot/ChangeLog | 7 +++++++ serverboot/kalloc.c | 23 ++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index e532d2a7..f0997fc5 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +2006-03-15 Alfred M. Szmidt + + * kalloc.c: #include . + (init_hook, malloc_hook, free_hook): New functions. + (__malloc_initialize_hook): New variable. + (malloc, free): Functions removed. + 2003-05-07 Ognyan Kulev * strfcns.c: #include instead of . diff --git a/serverboot/kalloc.c b/serverboot/kalloc.c index 80438738..28c0b55e 100644 --- a/serverboot/kalloc.c +++ b/serverboot/kalloc.c @@ -34,6 +34,14 @@ #include #include /* for spin locks */ +#include /* for malloc_hook/free_hook */ + +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; + #define DEBUG @@ -250,12 +258,21 @@ kfree( void *data, } } -void *malloc(vm_size_t size) +static void +init_hook (void) +{ + __malloc_hook = malloc_hook; + __free_hook = free_hook; +} + +static void * +malloc_hook (size_t size, const void *caller) { - return (void *)kalloc(size); + return (void *) kalloc ((vm_size_t) size); } -void free(void *addr) +static void +free_hook (void *ptr, const void *caller) { /* Just ignore harmless attempts at cleanliness. */ /* panic("free not implemented"); */ -- cgit v1.2.3 From c5e763f6236d32d950c1d2ea971411a5876b1732 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 3 Dec 2006 18:30:11 +0000 Subject: 2006-12-03 Thomas Schwinge * debian/Makefile: Remove file. * debian/README.Debian: Likewise. * debian/TODO: Likewise. * debian/changelog: Likewise. * debian/conffiles: Likewise. * debian/control: Likewise. * debian/copyright: Likewise. * debian/postinst: Likewise. * debian/prerm: Likewise. * debian/rc: Likewise. * debian/rules: Likewise. * debian/servers.boot: Likewise. * debian/shlibs: Likewise. * debian/shlibs.local: Likewise. * debian/update-rc.d: Likewise. --- debian/ChangeLog | 18 +++ debian/Makefile | 28 ---- debian/README.Debian | 7 - debian/TODO | 11 -- debian/changelog | 386 --------------------------------------------------- debian/conffiles | 7 - debian/control | 28 ---- debian/copyright | 29 ---- debian/postinst | 89 ------------ debian/prerm | 71 ---------- debian/rc | 137 ------------------ debian/rules | 199 -------------------------- debian/servers.boot | 22 --- debian/shlibs | 16 --- debian/shlibs.local | 15 -- debian/update-rc.d | 207 --------------------------- 16 files changed, 18 insertions(+), 1252 deletions(-) delete mode 100644 debian/Makefile delete mode 100644 debian/README.Debian delete mode 100644 debian/TODO delete mode 100644 debian/changelog delete mode 100644 debian/conffiles delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/postinst delete mode 100644 debian/prerm delete mode 100755 debian/rc delete mode 100755 debian/rules delete mode 100644 debian/servers.boot delete mode 100644 debian/shlibs delete mode 100644 debian/shlibs.local delete mode 100755 debian/update-rc.d diff --git a/debian/ChangeLog b/debian/ChangeLog index d8cb47c8..5027f923 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,3 +1,21 @@ +2006-12-03 Thomas Schwinge + + * debian/Makefile: Remove file. + * debian/README.Debian: Likewise. + * debian/TODO: Likewise. + * debian/changelog: Likewise. + * debian/conffiles: Likewise. + * debian/control: Likewise. + * debian/copyright: Likewise. + * debian/postinst: Likewise. + * debian/prerm: Likewise. + * debian/rc: Likewise. + * debian/rules: Likewise. + * debian/servers.boot: Likewise. + * debian/shlibs: Likewise. + * debian/shlibs.local: Likewise. + * debian/update-rc.d: Likewise. + 2002-11-18 Marcus Brinkmann * control (Uploader): Add Neal. diff --git a/debian/Makefile b/debian/Makefile deleted file mode 100644 index f94ee802..00000000 --- a/debian/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile for Debian Hurd packaging directory -# Copyright (C) 1999 Free Software Foundation, Inc. -# Gordon Matzigkeit , 1999-03-17 -# -# 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. - -dir := debian -makemode := misc - -# Just distribute the files we need. -DIST_FILES = README.Debian TODO changelog conffiles control copyright \ - rules servers.boot - -include ../Makeconf diff --git a/debian/README.Debian b/debian/README.Debian deleted file mode 100644 index 2e62dc8d..00000000 --- a/debian/README.Debian +++ /dev/null @@ -1,7 +0,0 @@ -GNU Hurd for Debian -=================== - -This is the Hurd release for Debian GNU/Hurd. -It contains essential system software and libraries. - -GNU Hurd Maintainers diff --git a/debian/TODO b/debian/TODO deleted file mode 100644 index ba3dc95e..00000000 --- a/debian/TODO +++ /dev/null @@ -1,11 +0,0 @@ -* daemons/rc - -* Split into multiple packages, so that we can provide virtual - packages that correspond closer to the existing Debian GNU/Linux - ones. But be careful that you don't use existing packagenames, or - bug reports will not be assigned correctly. - -* A postinstallation script which sets up translators correctly. - Better a script that manages translators, so changes by users are honored. - -* Split out pic libraries, build profiling libs (when they work). diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 6aac530e..00000000 --- a/debian/changelog +++ /dev/null @@ -1,386 +0,0 @@ -hurd (20021118-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual, with bug fixes from David Walter. - Change terminal type to mach-color. - - -- Marcus Brinkmann Tue, 18 Nov 2002 21:32:22 +0200 - -hurd (20021011-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual. - Build libpthread. - debian/control: Add libncursesw5-dev as build-dependency. - debian/shlibs: Add libpthread - debian/control: Add myself as an uploader. - - -- Neal H. Walfield Fri, 11 Oct 2002 21:42:21 -0400 - -hurd (20020918-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Tue, 18 Sep 2002 23:13:06 +0200 - -hurd (20020804-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Sun, 4 Aug 2002 20:46:28 +0200 - -hurd (20020523-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Thu, 23 May 2002 15:29:40 +0200 - -hurd (20020418-1) unstable; urgency=low - - * New snapshot from CVS. - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Thu, 18 Apr 2002 15:22:39 +0200 - -hurd (20011105-1) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual (well, the intention was there :). - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - - -- Marcus Brinkmann Mon, 5 Nov 2001 00:00:26 +0100 - -hurd (20011016-1) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - - -- Marcus Brinkmann Tue, 16 Oct 2001 19:43:21 +0200 - -hurd (20011013-1) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - * debian/rules: Change way how to find executables by Kevin Kreamer. - * debian/control: Add `file' to build dependencies by Kevin Kreamer. - - -- Marcus Brinkmann Sat, 13 Oct 2001 01:05:30 +0200 - -hurd (20010817-2) unstable; urgency=low - - * Include a copy of update-rc.d, moved from dpkg to init providing - package. - - -- Marcus Brinkmann Sun, 2 Sep 2001 19:40:00 +0200 - -hurd (20010817-1) unstable; urgency=low - - * New snapshot from CVS, closes: #105476, #39894. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - - -- Marcus Brinkmann Fri, 17 Aug 2001 22:16:01 +0200 - -hurd (20010718-1) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - - -- Marcus Brinkmann Thu, 18 Jul 2001 21:43:52 +0200 - -hurd (20010608) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - Compiled with -O2 rather than -O3. - - -- Marcus Brinkmann Fri, 8 Jun 2001 23:02:47 +0200 - -hurd (20010527) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Sat, 27 May 2001 01:34:21 +0200 - -hurd (20010426) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - storeio hack to prevent double activation. - - -- Marcus Brinkmann Fri, 27 Apr 2001 00:09:56 +0200 - -hurd (20010311) unstable; urgency=low - - * New snapshot from CVS. - * Additional patches: - kbd, mouse as usual. - Change terminal type to mach-color. - - -- Marcus Brinkmann Sun, 11 Mar 2001 22:45:21 +0100 - -hurd (20010111) unstable; urgency=low - - * New snapshot from CVS, containing lots of small bug fixes, and: - + Together with gnumach 1.2-9, you can access large stores with - storeinfo, storeread (because libstore uses the new interface in - gnumach, and off64_t internally). - + pfinet contains support for network ioctls. The corresponding - changes in the glibc library are not available in Debian yet, though. - * streamdev is renamed to streamio. - - -- Marcus Brinkmann Fri, 12 Jan 2001 00:06:41 +0100 - -hurd (20001204) unstable; urgency=low - - * New snapshot from CVS, with a couple of bug fixes: - pfinet: Don't leak references. - ext2fs, ufs: Avoid a dn_set_?time vs sync thread race. - Corretly deny too long filenames. - nfsd: Fix a couple of memory leaks. - - * Additional patchs: - libdiskfs: Don't crash when symlink target is the empty string. - streamdev, kbd, mouse: New translators for X and klog device. - - -- Marcus Brinkmann Mon, 4 Dec 2000 15:18:39 +0100 - -hurd (20001127) unstable; urgency=low - - * New snapshot from CVS, really fixes isofs now. - - -- Marcus Brinkmann Mon, 27 Nov 2000 21:07:03 +0100 - -hurd (20001126) unstable; urgency=low - - * New snapshot from CVS, closes: #68417, #69281, #68626 - * Fix in 20001030 closes: #72319 - * debian/control: Add build dependencies, closes: #75734 - - -- Marcus Brinkmann Sun, 26 Nov 2000 05:53:19 +0100 - -hurd (20001030) unstable; urgency=low - - * New snapshot from CVS. - * Still contains all the goodies, streadev, kbd, mouse. Now opening - kbd, mouse more than once doesn't crash them (thanks Erik Verbruggen - ) - * sutils/MAKEDEV.sh: kmsg is really klog. - - -- Marcus Brinkmann Tue, 30 Oct 2000 18:02:29 +0200 - -hurd (20000921) unstable; urgency=low - - * New snapshot from CVS - * Add streamdev by OKUJI Yoshinori - (source: ftp://alpha.gnu.org/contrib/okuji/hurd/streamdev-19990920.tar.gz) - * Add kbd and mouse by UCHIYAMA Yasushi . - * sutils/MAKEDEV.sh: Add kbd and kmsg. No sense to add mouse, as you need - to configure it (see /hurd/mouse --help). - - -- Marcus Brinkmann Sat, 23 Sep 2000 04:27:58 +0200 - -hurd (20000803) unstable; urgency=low - - * New snapshot from CVS. - * isofs: Patch to fix symlink handling. - - -- Marcus Brinkmann Thu, 3 Aug 2000 21:09:44 +0200 - -hurd (20000726) unstable; urgency=low - - * New snapshot from CVS. - * Fixes the infamous zero hole bug (actually both of them). - - -- Marcus Brinkmann Wed, 26 Jul 2000 02:24:06 +0200 - -hurd (20000703) unstable; urgency=low - - * New snapshot from CVS. - * exec/hashexec.c (check_hashbang: Fix off by one error in line 178. - Patch by Kalle Olavi Niemital. - - -- Marcus Brinkmann Mon, 3 Jul 2000 00:44:47 +0200 - -hurd (20000130) unstable; urgency=low - - * New snapshot from CVS. Closes: Bug#54282, Bug#40302, Bug#56076. - - -- Marcus Brinkmann Sun, 30 Jan 2000 14:55:39 +0100 - -hurd (19991209) unstable; urgency=low - - * New snapshot from CVS. - - -- Marcus Brinkmann Thu, 9 Dec 1999 23:43:23 +0100 - -hurd (19991022) unstable; urgency=low - - * New snapshot from CVS. - * libdiskfs/init-startup.c: Disable periodic syncing before shutting down. - This fixes the fs-unclean-on-reboot bug! - - -- Marcus Brinkmann Fri, 22 Oct 1999 21:32:02 +0200 - -hurd (19991004) unstable; urgency=high - - * New snapshot from CVS. - term: Realize bogus devices. - ext2fs: Important bug fixes! - - -- Marcus Brinkmann Sun, 3 Oct 1999 18:01:17 +0200 - -hurd (19990923) unstable; urgency=low - - * New snapshot from CVS. - MAKEDEV: pty created with mode 0666. - Implements pathconf for libdiskfs and libnetfs. - Various bug fixes. - * Development package now includes pic libraries. - - -- Marcus Brinkmann Sun, 19 Sep 1999 19:29:00 +0200 - -hurd (19990907) unstable; urgency=low - - * New snapshot from CVS. - * gzip /boot/serverboot to /boot/serverboot.gz - - -- Marcus Brinkmann Mon, 23 Aug 1999 15:12:10 +0200 - -hurd (19990725) unstable; urgency=low - - * New snapshot from CVS. - - -- Marcus Brinkmann Thu, 25 Jul 1999 16:16:03 +0200 - -hurd (19990714) unstable; urgency=low - - * New snapshot from CVS. - * debian/rules: etc/motd is in base-files, do not include it. - * Activate split-init. - - -- Marcus Brinkmann Wed, 14 Jul 1999 16:38:00 +0200 - -hurd (19990616) unstable; urgency=low - - * New snapshot from CVS. - * Now contains info and ps documentation. - - -- Marcus Brinkmann Thu, 17 Jun 1999 17:35:54 +0200 - -hurd (19990524) unstable; urgency=low - - * New snapshot from CVS. - - -- Marcus Brinkmann Mon, 24 May 1999 15:09:45 +0200 - -hurd (19990523) unstable; urgency=low - - * New snapshot from CVS, fixes: #38062, #37670, #37878, #37944. - - -- Marcus Brinkmann Mon, 24 May 1999 01:08:26 +0200 - -hurd (19990517fixed) unstable; urgency=low - - * debian/shlibs: corrected. - * exec/hashexec.c: Applied patch by Roland to make it work. - - -- Marcus Brinkmann Sun, 17 May 1999 00:25:11 +0200 - -hurd (19990517) unstable; urgency=low - - * New snapshot from CVS. - * Add shlibs file. - - -- Marcus Brinkmann Sun, 16 May 1999 15:28:09 +0200 - -hurd (19990425-1) unstable; urgency=low - - * Put shared library symlinks into the hurd-dev package. - * Clarify instructions in provided servers.boot. - * libfshelp/fetch-root.c: De-patched a change by tb which produced - strange errors. - - -- Marcus Brinkmann Thu, 29 Apr 1999 22:47:51 +0200 - -hurd (19990212-2) unstable; urgency=low - - * debian/control: Added Depends line for Hurd. - * Update docs to reflect new group maintainership. - * debian/copyright: Hurd libraries are *not* under the LGPL, so add a - clarifying note. - * Put static libraries and header files into /usr/lib and /usr/include - for people without the /usr symlink. - - -- Gordon Matzigkeit Wed, 17 Feb 1999 15:40:44 -0600 - -hurd (19990212-1) unstable; urgency=low - - * New upstream version from CVS. - * Deleted old libthreads... there's no going back now. - - -- Gordon Matzigkeit Fri, 12 Feb 1999 03:25:55 -0600 - -hurd (19981204-1) unstable; urgency=low - - * New upstream release, supposed to work with glibc 2.0.106. - * Commented out use of old libthreads. - - -- Marcus Brinkmann Sun, 20 Dec 1998 04:24:40 +0100 - -hurd (19980915-2) unstable; urgency=low - - * exec/hashexec.c: Applied patch by Thomas Bushnell to fix make. - - -- Marcus Brinkmann Fri, 6 Nov 1998 23:10:11 +0100 - -hurd (19980915-1) unstable; urgency=low - - * New upstream release. - * debian/rules: Strip all binaries. - * debian/TODO: New file. - - -- Marcus Brinkmann Thu, 8 Oct 1998 03:34:40 +0200 - -hurd (19980716-2) unstable; urgency=low - - * Reverted libthreads to provide threadsafe malloc, as we use older - version of glibc2 for now. - * Do not remove size 0 files in 'rules clean', because hurd depends on - them. - * Do not build profiling libraries. - - -- Marcus Brinkmann Tue, 4 Aug 1998 21:58:55 +0200 - -hurd (19980716-1) unstable; urgency=low - - * Initial Version. - - -- Marcus Brinkmann Tue, 4 Aug 1998 21:58:55 +0200 diff --git a/debian/conffiles b/debian/conffiles deleted file mode 100644 index 61edd051..00000000 --- a/debian/conffiles +++ /dev/null @@ -1,7 +0,0 @@ -/boot/servers.boot -/etc/ttys -/etc/login/.bash_login -/etc/login/.bashrc -/etc/login/.hushlogin -/etc/login/.profile -/etc/login/README diff --git a/debian/control b/debian/control deleted file mode 100644 index e02b70c5..00000000 --- a/debian/control +++ /dev/null @@ -1,28 +0,0 @@ -Source: hurd -Section: base -Priority: required -Maintainer: GNU Hurd Maintainers -Standards-Version: 3.5.5.0 -Build-Depends: file, mig (>= 1.3-2), texinfo, tetex-bin, autoconf, libncursesw5-dev -Uploaders: Marcus Brinkmann , Neal H. Walfield - -Package: hurd -Priority: required -Section: base -Essential: yes -Depends: ${hurd:Depends} -Provides: makedev, login, fakeroot -Replaces: makedev, login, fakeroot -Conflicts: makedev, login, fakeroot -Architecture: hurd-i386 -Description: The GNU Hurd - This is the GNU Hurd package. It contains essential system software and - libraries. - -Package: hurd-dev -Priority: standard -Section: devel -Architecture: hurd-i386 -Depends: hurd -Description: The GNU Hurd (development files) - This package includes the header files and the static libraries. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 51ed720a..00000000 --- a/debian/copyright +++ /dev/null @@ -1,29 +0,0 @@ -This package was debianized by Marcus Brinkmann -on Tue, 4 Aug 1998 21:52:45 +0200 - -It is currently maintained by its upstream authors, who can be reached -via . - -Sources are available from ftp://alpha.gnu.org/pub/hurd/src/ - -Copyright statement: - -Note that the libraries distributed with the GNU Hurd are placed under -the standard GNU General Public License (*not* the Library General -Public License). - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 dated June, 1991. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -On Debian systems, the complete text of the GNU General Public License -can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 05e30d3e..00000000 --- a/debian/postinst +++ /dev/null @@ -1,89 +0,0 @@ -#! /bin/sh -# postinst.skeleton -# Skeleton maintainer script showing all the possible cases. -# Written by Charles Briscoe-Smith, March-June 1998. Public Domain. - -# Abort if any command returns an error value -set -e - -# This script is called as the last step of the installation of the -# package. All the package's files are in place, dpkg has already done -# its automatic conffile handling, and all the packages we depend of -# are already fully installed and configured. - -# The following idempotent stuff doesn't generally need protecting -# against being run in the abort-* cases. - -# Install info files into the dir file. - -install-info --quiet --section "Hurd" "The Hurd" /usr/share/info/hurd.info.gz - -# Manage alternatives. - -update-alternatives --quiet \ - --install /libexec/runsystem runsystem /libexec/runsystem.gnu 20 - -# Take care that a "login" user exists. Useful for our login shell. - -if ! grep --quiet '^login:' /etc/passwd ; then - adduser --quiet --system --home /etc/login --gecos "Not logged in" --no-create-home login - chsh -s /bin/bash login -fi - -case "$1" in - configure) - # Configure this package. If the package must prompt the user for - # information, do it here. - - # There are three sub-cases: - if test "${2+set}" != set; then - # We're being installed by an ancient dpkg which doesn't remember - # which version was most recently configured, or even whether - # there is a most recently configured version. - : - - elif test -z "$2" -o "$2" = ""; then - # The package has not ever been configured on this system, or was - # purged since it was last configured. - : - - else - # Version $2 is the most recently configured version of this - # package. - : - - fi ;; - abort-upgrade) - # Back out of an attempt to upgrade this package FROM THIS VERSION - # to version $2. Undo the effects of "prerm upgrade $2". - : - - ;; - abort-remove) - if test "$2" != in-favour; then - echo "$0: undocumented call to \`postinst $*'" 1>&2 - exit 0 - fi - # Back out of an attempt to remove this package, which was due to - # a conflict with package $3 (version $4). Undo the effects of - # "prerm remove in-favour $3 $4". - : - - ;; - abort-deconfigure) - if test "$2" != in-favour -o "$5" != removing; then - echo "$0: undocumented call to \`postinst $*'" 1>&2 - exit 0 - fi - # Back out of an attempt to deconfigure this package, which was - # due to package $6 (version $7) which we depend on being removed - # to make way for package $3 (version $4). Undo the effects of - # "prerm deconfigure in-favour $3 $4 removing $6 $7". - : - - ;; - *) echo "$0: didn't understand being called with \`$1'" 1>&2 - exit 0;; -esac - -exit 0 diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index e6adae87..00000000 --- a/debian/prerm +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -# Abort if any command returns an error value -set -e - -# This script is called as the first step in removing the package from -# the system. This includes cases where the user explicitly asked for -# the package to be removed, upgrade, automatic removal due to conflicts, -# and deconfiguration due to temporary removal of a depended-on package. - -# Info files should be uninstalled from the dir file in any case. -install-info --quiet --remove hurd - -# Because we run this in almost all cases, we do it here instead below. - -if [ "$1" != "upgrade" ]; then - update-alternatives --remove runsystem /libexec/runsystem.gnu -fi - -case "$1" in - remove) - # This package about to be removed. - : - - # There are two sub-cases: - if test "${2+set}" = set; then - if test "$2" != in-favour; then - echo "$0: undocumented call to \`prerm $*'" 1>&2 - exit 0 - fi - # We are being removed because of a conflict with package $3 - # (version $4), which is now being installed. - : - - else - # The package is being removed in its own right. - : - - fi - - - ;; - - deconfigure) - if test "$2" != in-favour -o "$5" != removing; then - echo "$0: undocumented call to \`prerm $*'" 1>&2 - exit 0 - fi - # Package $6 (version $7) which we depend on is being removed due - # to a conflict with package $3 (version $4), and this package is - # being deconfigured until $6 can be reinstalled. - : - - ;; - upgrade) - # Prepare to upgrade FROM THIS VERSION of this package to version $2. - : - - ;; - failed-upgrade) - # Prepare to upgrade from version $2 of this package TO THIS VERSION. - # This is only used if the old version's prerm couldn't handle it, - # and returned non-zero. (Fix old prerm bugs here.) - : - - ;; - *) echo "$0: didn't understand being called with \`$1'" 1>&2 - exit 0;; -esac - -exit 0 diff --git a/debian/rc b/debian/rc deleted file mode 100755 index d56a5f3f..00000000 --- a/debian/rc +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin - -# Start the default pager. It will bail if there is already one running. -/hurd/mach-defpager - -# Set up swap space. This will complain if no default pager is functioning. -swapon -a - -# Check filesystems. -if [ -r /fastboot ] -then - # ... or don't. - rm -f /fastboot - echo Fast boot ... skipping disk checks -elif [ $1x = autobootx ] -then - echo Automatic boot in progress... - date - - /sbin/fsck --preen --writable - - case $? in - # Successful completion - 0) - ;; - # Filesystem modified (but ok now) - 1 | 2) - ;; - # Fsck couldn't fix it. - 4 | 8) - echo "Automatic boot failed... help!" - exit 1 - ;; - # Signal that really interrupted something - 20 | 130 | 131) - echo "Boot interrupted" - exit 1 - ;; - # Special `let fsck finish' interruption (SIGQUIT) - 12) - echo "Boot interrupted (filesystem checks complete)" - exit 1 - ;; - # Oh dear. - *) - echo "Unknown error during fsck (exit status $?)" - exit 1 - ;; - esac -fi - -echo -n cleaning up left over files... -rm -f /etc/nologin -rm -f /var/lock/LCK.* -if test -d /tmp; then - - # Forcibly remove all translators in the directory. - # It is then safe to attempt to remove files and descend directories. - # All parameters must begin with "./". - function remove_translators() { - local f - for f; do - settrans -pagfS "$f" - if [ -L "$f" ] || [ ! -d "$f" ]; then - rm "$f" - else - remove_translators "$f"/* "$f"/.[!.] "$f"/.??* - rmdir "$f" - fi - done - } - - (cd /tmp - shopt -s nullglob - for f in * .[!.] .??*; do - case "$f" in - 'lost+found'|'quotas') ;; - *) remove_translators "./$f" - esac - done) - - unset -f remove_translators # because it relies on nullglob - -fi - -if test -d /var/run; then - (cd /var/run && { - find . ! -type d ! -name utmp ! -name innd.pid \ - -exec rm -f -- {} \; - cp /dev/null utmp - if grep -q ^utmp: /etc/group - then - chmod 664 utmp - chgrp utmp utmp - fi; }) -fi - -echo done - -# This file must exist for e2fsck to work. XXX -touch /var/run/mtab - -#echo -n restoring pty permissions... -#chmod 666 /dev/tty[pqrs]* -#echo done - -#echo -n updating /etc/motd... -#echo GNU\'s Not Unix Version `uname --release` > /tmp/newmotd -#egrep -v 'GNU|Version' /etc/motd >> /tmp/newmotd -#mv /tmp/newmotd /etc/motd -#echo done - -chmod 664 /etc/motd - -( - trap ":" INT QUIT TSTP - - if [ -d /etc/rc.boot ] - then - for i in /etc/rc.boot/S* - do - [ ! -f $i ] && continue - $i start - done - fi - if [ -d /etc/rc2.d ] - then - for i in /etc/rc2.d/S* - do - [ ! -f $i ] && continue - $i start - done - fi -) - -date diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 94ec8fe3..00000000 --- a/debian/rules +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/make -f -############################ -*- Mode: Makefile -*- ########################### -## rules --- -## Author : Marcus Brinkmann -## Created On : Sat, 1 Aug 1998 21:33:31 +0200 -## Created On Node : localhost -## Last Modified By : Marcus Brinkmann -## Last Modified On : Thu, 23 Sep 1999 01:41:38 +0200 -## Last Machine Used: localhost -## Update Count : 2 -## Status : Unknown, Use with caution! -## HISTORY : -## Description : -## -############################################################################### - -# The name of the package (for example, `emacs'). -package := hurd - -DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) - -# Configuration variables (these should be pretty generic) -CC = cc -CFLAGS = -O2 -g -pipe -Wall -LDFLAGS = -s -PREFIX = /usr -BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/man -INFODIR = $(PREFIX)/share/info -DOCDIR = $(PREFIX)/share/doc/$(package) - -# Package specific stuff. The idea is to try to make the rules -# generic (gradually). - -FILES_TO_CLEAN = debian/files include/*.h -DIRS_TO_CLEAN = debian/tmp debian/$(package)-dev build -STAMPS_TO_CLEAN = stamp-build stamp-config - -install_file = install -o root -g root -m 644 -install_program = install -s -o root -g root -m 755 -install_script = install -o root -g root -m 755 -make_directory = install -d -o root -g root -m 755 - -define checkdir - test -f debian/rules -endef - -define checkroot - @test 0 = "`id -u`" || (echo need root priviledges; exit 1) -endef - -# Next is NOT a phony target. - -configure: configure.in - autoconf - -# The next IS a phony target. - -config: stamp-config -stamp-config: configure - $(checkdir) - -mkdir build - cd build && ../configure --disable-profile \ - --build=$(DEB_BUILD_GNU_TYPE) \ - --host=$(DEB_HOST_GNU_TYPE) --prefix= - touch stamp-config - -all build: config stamp-build -stamp-build: - $(checkdir) - cd build && $(MAKE) -# XXX-doc - cd build && $(MAKE) -C doc hurd.info - cd build && $(MAKE) -C doc hurd.ps - touch stamp-build - -clean: - $(checkdir) -# -cd build && make clean no_deps=t - -rm -f $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN) - -rm -rf $(DIRS_TO_CLEAN) -# XXX-doc - -rm -f doc/hurd.d doc/hurd.info* version.texi - for NAME in hurd/*.h; do \ - if [ -L $$NAME ] ; then \ - rm -f $$NAME ; \ - fi \ - done - -rm -f core `find . \( -name '*.o' -name '*.orig' -o -name '*.rej' -o -name '*~' \ - -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ - -o -name '.*.rej' -o -name '.SUMS' \) -print` - -binary: binary-indep binary-arch - -binary-indep: -# We have nothing to do here. - -binary-arch: build - $(checkdir) - $(checkroot) - -rm -rf debian/{tmp,$(package)-dev} - -# first the general install - $(make_directory) debian/tmp/boot - cd build && $(MAKE) install prefix=`pwd`/../debian/tmp no_prof=t -# kill the profiling libs - -rm -f debian/tmp/lib/*_p.a -# /etc/motd is in base-files! - -rm -f debian/tmp/etc/motd -# probably we'll make debug packages later, for now, strip'em - -strip --strip-unneeded debian/tmp/lib/lib*.so - -strip --strip-debug debian/tmp/lib/lib*.a - -strip --strip-all debian/tmp/bin/* - -strip --strip-all debian/tmp/sbin/* - -strip --strip-all debian/tmp/boot/* - -strip --strip-all debian/tmp/hurd/* - -strip --strip-all debian/tmp/libexec/* - chmod 0644 debian/tmp/lib/lib*.a - chmod 0755 $(addprefix debian/tmp/, \ - include include/hurd \ - lib hurd bin sbin \ - dev libexec etc etc/login) - -# now distribute the files -# first the source package - $(make_directory) debian/$(package)-dev/{DEBIAN,usr/{share/doc,bin,lib}} - ln -s $(package) debian/$(package)-dev$(DOCDIR)-dev - mv debian/tmp/include debian/$(package)-dev/usr/. - mv debian/tmp/lib/*.a debian/$(package)-dev/usr/lib/. - # Create development library links. - for file in `cd debian/tmp/lib && ls *.so.*`; do \ - linkname=`echo "$$file" | sed 's/\..*$$/.so/'`; \ - ln -sf $$file debian/$(package)-dev/usr/lib/$$linkname; \ - done - rm -f debian/tmp/lib/*.so - - dpkg-gencontrol -isp -p$(package)-dev -Pdebian/$(package)-dev - chown -R root.root debian/$(package)-dev - dpkg --build debian/$(package)-dev .. - -# now the shared libs and other stuff - $(make_directory) debian/tmp/DEBIAN - $(make_directory) debian/tmp$(DOCDIR) - $(make_directory) debian/tmp$(INFODIR) - - gzip -9fq debian/tmp/boot/serverboot - -# Only found in CVS, not the distribution. -# $(install_file) BUGS debian/tmp$(DOCDIR) -# $(install_file) TODO debian/tmp$(DOCDIR) - $(install_file) INSTALL debian/tmp$(DOCDIR) - $(install_file) NEWS debian/tmp$(DOCDIR) - $(install_file) README debian/tmp$(DOCDIR) - $(install_file) tasks debian/tmp$(DOCDIR) - $(install_file) ChangeLog debian/tmp$(DOCDIR)/changelog - $(install_file) debian/README.Debian debian/tmp$(DOCDIR) - $(install_file) debian/changelog debian/tmp$(DOCDIR)/changelog.Debian -# XXX-doc - $(install_file) build/doc/hurd.ps debian/tmp$(DOCDIR) - gzip -9frq debian/tmp$(DOCDIR)/. - $(install_file) debian/copyright debian/tmp$(DOCDIR) - -# XXX-doc - $(install_file) build/doc/hurd.info* debian/tmp$(INFODIR) - -gzip -9frq debian/tmp$(INFODIR) -# XXX Remove the vague attempt of the makefiles to install the docs. - rm -fR debian/tmp/info - - $(install_file) debian/servers.boot debian/tmp/boot/servers.boot - $(make_directory) debian/tmp/servers - -# libexec/runsystem is managed by update-alternatives - mv debian/tmp/libexec/runsystem debian/tmp/libexec/runsystem.gnu - -# We have our own rc, slightly modified. - cp debian/rc debian/tmp/libexec/rc - $(install_script) debian/update-rc.d debian/tmp/sbin - - $(install_file) debian/conffiles debian/tmp/DEBIAN/conffiles - $(install_file) debian/shlibs debian/tmp/DEBIAN/shlibs - $(install_script) debian/postinst debian/tmp/DEBIAN/postinst - $(install_script) debian/prerm debian/tmp/DEBIAN/prerm - - # Get list of dynamically linked executables - dpkg-shlibdeps -p$(package) \ - `file debian/tmp/bin/* \ - debian/tmp/hurd/* \ - debian/tmp/lib/* \ - debian/tmp/lib/hurd/console/* \ - debian/tmp/libexec/* \ - debian/tmp/sbin/* \ - | egrep '(executable.*dynamic)|(shared object)' \ - | cut -f 1 -d ':'` - dpkg-gencontrol -isp -p$(package) -Pdebian/tmp - chown -R root.root debian/tmp - dpkg --build debian/tmp .. - -.PHONY: build config clean binary-indep binary-arch binary diff --git a/debian/servers.boot b/debian/servers.boot deleted file mode 100644 index 2eb4da05..00000000 --- a/debian/servers.boot +++ /dev/null @@ -1,22 +0,0 @@ -# GNU Mach boot script for Debian GNU/Hurd. Each line specifies a -# file for serverboot to load (the first word), and actions to be done -# with it. - -# First, the bootstrap filesystem. It needs several ports as arguments, -# as well as the user flags from the boot loader. -/hurd/ext2fs.static --bootflags=${boot-args} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -Tdevice ${root-device} $(task-create) $(task-resume) - -# Now the exec server; to load the dynamically-linked exec server -# program, we have serverboot in fact load and run ld.so, which in -# turn loads and runs /hurd/exec. This task is created, and its task -# port saved in ${exec-task} to be passed to the fs above, but it is -# left suspended; the fs will resume the exec task once it is ready. -/lib/ld.so.1 /hurd/exec $(exec-task=task-create) - -# To swap to a Linux swap partition, use something like the following. -# You can also add swap partitions to /etc/fstab. -#/dev/hd0s2 $(add-linux-paging-file) - -# Don't make serverboot the default pager. The real default pager will -# we started early in /libexec/rc. -die $(serverboot) diff --git a/debian/shlibs b/debian/shlibs deleted file mode 100644 index 54a3f7c1..00000000 --- a/debian/shlibs +++ /dev/null @@ -1,16 +0,0 @@ -libshouldbeinlibc 0.3 hurd (>= 20020804-1) -libftpconn 0.3 hurd (>= 20020804-1) -libports 0.3 hurd (>= 20020804-1) -libthreads 0.3 hurd (>= 20020804-1) -libhurdbugaddr 0.3 hurd (>= 20020804-1) -libstore 0.3 hurd (>= 20020804-1) -libihash 0.3 hurd (>= 20020804-1) -libpipe 0.3 hurd (>= 20020804-1) -libtrivfs 0.3 hurd (>= 20020804-1) -libpager 0.3 hurd (>= 20020804-1) -libnetfs 0.3 hurd (>= 20020804-1) -libiohelp 0.3 hurd (>= 20020804-1) -libfshelp 0.3 hurd (>= 20020804-1) -libps 0.3 hurd (>= 20020804-1) -libdiskfs 0.3 hurd (>= 20020804-1) -libpthread 0.3 hurd (>= 20021011-1) diff --git a/debian/shlibs.local b/debian/shlibs.local deleted file mode 100644 index e518f87d..00000000 --- a/debian/shlibs.local +++ /dev/null @@ -1,15 +0,0 @@ -libshouldbeinlibc 0.3 -libftpconn 0.3 -libports 0.3 -libthreads 0.3 -libhurdbugaddr 0.3 -libstore 0.3 -libihash 0.3 -libpipe 0.3 -libtrivfs 0.3 -libpager 0.3 -libnetfs 0.3 -libiohelp 0.3 -libfshelp 0.3 -libps 0.3 -libdiskfs 0.3 diff --git a/debian/update-rc.d b/debian/update-rc.d deleted file mode 100755 index 83d12ffd..00000000 --- a/debian/update-rc.d +++ /dev/null @@ -1,207 +0,0 @@ -#! /usr/bin/perl -# -# update-rc.d Update the links in /etc/rc[0-9S].d/ -# -# Version: @(#)update-rc.d.pl 2.02 05-Mar-1998 miquels@cistron.nl -# - -$initd = "/etc/init.d"; -$etcd = "/etc/rc"; -$notreally = 0; - -# Print usage message and die. - -sub usage { - print STDERR "update-rc.d: error: @_\n" if ($#_ >= 0); - print STDERR < remove - update-rc.d [-n] defaults [NN | sNN kNN] - update-rc.d [-n] start|stop NN runlvl [runlvl] [...] . - -n: not really - -f: force -EOF - exit (1); -} - -# Check out options. - -while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) { - shift @ARGV; - if (/^-n$/) { $notreally++; next } - if (/^-f$/) { $force++; next } - if (/^-h|--help$/) { &usage; } - &usage("unknown option"); -} - -# Action. - -&usage() if ($#ARGV < 1); -$bn = shift @ARGV; -if ($ARGV[0] ne 'remove') { - if (! -f "$initd/$bn") { - print STDERR "update-rc.d: $initd/$bn: file does not exist\n"; - exit (1); - } -} elsif (-f "$initd/$bn") { - if (!$force) { - printf STDERR "update-rc.d: $initd/$bn exists during rc.d purge (use -f to force)\n"; - exit (1); - } else { - printf STDERR "update-rc.d: $initd/$bn exists during rc.d purge (continuing)\n"; - } -} - -$_ = $ARGV[0]; -if (/^remove$/) { &checklinks ("remove"); } -elsif (/^defaults$/) { &defaults; &makelinks } -elsif (/^(start|stop)$/) { &startstop; &makelinks; } -else { &usage; } - -exit (0); - -# Check if there are links in /etc/rc[0-9S].d/ -# Remove if the first argument is "remove" and the links -# point to $bn. - -sub is_link () { - my ($op, $fn, $bn) = @_; - if (! -l $fn) { - print STDERR "update-rc.d: warning: $fn is not a symbolic link\n"; - return 0; - } else { - $linkdst = readlink ($fn); - if (! defined $linkdst) { - die ("update-rc.d: error reading symbolic link: $!\n"); - } - if (($linkdst ne "../init.d/$bn") && ($linkdst ne "../init.d/$bn")) { - print STDERR "update-rc.d: warning: $fn is not a link to ../init.d/$bn\n"; - return 0; - } - } - return 1; -} - -sub checklinks { - my ($i, $found, $fn, $islnk); - - print " Removing any system startup links for $initd/$bn ...\n" - if ($_[0] eq 'remove'); - - $found = 0; - - foreach $i (0..9, 'S') { - unless (chdir ("$etcd$i.d")) { - next if ($i =~ m/^[789S]$/); - die("update-rc.d: chdir $etcd$i.d: $!\n"); - } - opendir(DIR, "."); - foreach $_ (readdir(DIR)) { - next unless (/^[SK]\d\d$bn$/); - $fn = "$etcd$i.d/$_"; - $found = 1; - $islnk = &is_link ($_[0], $fn, $bn); - next if ($_[0] ne 'remove'); - if (! $islnk) { - print " $fn is not a link to ../init.d/$bn; not removing\n"; - next; - } - print " $etcd$i.d/$_\n"; - next if ($notreally); - unlink ("$etcd$i.d/$_") || - die("update-rc.d: unlink: $!\n"); - } - closedir(DIR); - } - $found; -} - -# Process the arguments after the "defaults" keyword. - -sub defaults { - my ($start, $stop) = (20, 20); - - &usage ("defaults takes only one or two codenumbers") if ($#ARGV > 2); - $start = $stop = $ARGV[1] if ($#ARGV >= 1); - $stop = $ARGV[2] if ($#ARGV >= 2); - &usage ("codenumber must be a number between 0 and 99") - if ($start !~ /^\d\d?$/ || $stop !~ /^\d\d?$/); - - $start = sprintf("%02d", $start); - $stop = sprintf("%02d", $stop); - - $stoplinks[0] = $stoplinks[1] = $stoplinks[6] = "K$stop"; - $startlinks[2] = $startlinks[3] = - $startlinks[4] = $startlinks[5] = "S$start"; - - 1; -} - -# Process the arguments after the start or stop keyword. - -sub startstop { - - my($letter, $NN, $level); - - while ($#ARGV >= 0) { - if ($ARGV[0] eq 'start') { $letter = 'S'; } - elsif ($ARGV[0] eq 'stop') { $letter = 'K' } - else { - &usage("expected start|stop"); - } - - if ($ARGV[1] !~ /^\d\d?$/) { - &usage("expected NN after $ARGV[0]"); - } - $NN = sprintf("%02d", $ARGV[1]); - - shift @ARGV; shift @ARGV; - $level = shift @ARGV; - do { - if ($level !~ m/^[0-9S]$/) { - &usage( - "expected runlevel [0-9S] (did you forget \".\" ?)"); - } - if (! -d "$etcd$level.d") { - print STDERR - "update-rc.d: $etcd$level.d: no such directory\n"; - exit(1); - } - $level = 99 if ($level eq 'S'); - $startlinks[$level] = "$letter$NN" if ($letter eq 'S'); - $stoplinks[$level] = "$letter$NN" if ($letter eq 'K'); - } while (($level = shift @ARGV) ne '.'); - &usage("action with list of runlevels not terminated by \`.'") - if ($level ne '.'); - } - 1; -} - -# Create the links. - -sub makelinks { - my($t, $i); - my @links; - - if (&checklinks) { - print " System startup links for $initd/$bn already exist.\n"; - exit (0); - } - print " Adding system startup for $initd/$bn ...\n"; - - # nice unreadable perl mess :) - - for($t = 0; $t < 2; $t++) { - @links = $t ? @startlinks : @stoplinks; - for($i = 0; $i <= $#links; $i++) { - $lvl = $i; - $lvl = 'S' if ($i == 99); - next if ($links[$i] eq ''); - print " $etcd$lvl.d/$links[$i]$bn -> ../init.d/$bn\n"; - next if ($notreally); - symlink("../init.d/$bn", "$etcd$lvl.d/$links[$i]$bn") - || die("update-rc.d: symlink: $!\n"); - } - } - - 1; -} -- cgit v1.2.3 From c56020fcdd85586a9c4f10819d96521a4d4b2f1c Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 3 Dec 2006 18:34:36 +0000 Subject: Savannah tag. --- debian/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/ChangeLog b/debian/ChangeLog index 5027f923..739a8b04 100644 --- a/debian/ChangeLog +++ b/debian/ChangeLog @@ -1,5 +1,6 @@ 2006-12-03 Thomas Schwinge + [bug #17121 --- ``GNU Hurd debian dir''] * debian/Makefile: Remove file. * debian/README.Debian: Likewise. * debian/TODO: Likewise. -- cgit v1.2.3 From 1efd7dac9f72b51fe02b036c5401f9dd185de324 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 3 Dec 2006 18:36:46 +0000 Subject: 2006-12-03 Thomas Schwinge [bug #17121 --- ``GNU Hurd debian dir''] * debian/ChangeLog: Remove file. * Makefile (other-subdirs): Remove `debian'. --- debian/ChangeLog | 238 ------------------------------------------------------- 1 file changed, 238 deletions(-) delete mode 100644 debian/ChangeLog diff --git a/debian/ChangeLog b/debian/ChangeLog deleted file mode 100644 index 739a8b04..00000000 --- a/debian/ChangeLog +++ /dev/null @@ -1,238 +0,0 @@ -2006-12-03 Thomas Schwinge - - [bug #17121 --- ``GNU Hurd debian dir''] - * debian/Makefile: Remove file. - * debian/README.Debian: Likewise. - * debian/TODO: Likewise. - * debian/changelog: Likewise. - * debian/conffiles: Likewise. - * debian/control: Likewise. - * debian/copyright: Likewise. - * debian/postinst: Likewise. - * debian/prerm: Likewise. - * debian/rc: Likewise. - * debian/rules: Likewise. - * debian/servers.boot: Likewise. - * debian/shlibs: Likewise. - * debian/shlibs.local: Likewise. - * debian/update-rc.d: Likewise. - -2002-11-18 Marcus Brinkmann - - * control (Uploader): Add Neal. - * shlibs: Add pthreads. - * rules: Add debian/tmp/lib/hurd/console/* to search path for - shared objects. - * changelog: Add Neal's last release and my upcoming. - -2002-09-29 Marcus Brinkmann - - * control (Build-Depends): Add libncursesw5-dev. - * changelog: Add a note about this here. - -2002-09-17 Marcus Brinkmann - - * changelog: Update for new Debian package. - -2002-08-04 Marcus Brinkmann - - * control (Uploaders): New field, suggested by Jeff Bailey. - (Build-Depends): Add version requirement for mig. - * shlibs: Update version to 0.3, add version restriction. - * shlibs.local: Likewise. - * changelog: Update for next upload. - -2002-08-03 Jeff Bailey - - * rules: Symlinks should point to relative location, not absolute. - -2002-05-23 Marcus Brinkmann - - * control (Provides, Replaces, Conflicts): Add fakeroot. - * changelog: Update for Debian package. - -2002-05-13 Marcus Brinkmann - - * rules (INFODIR): Move to /share. - * postinst: Likewise. - Submitted by Guillem Jover , Closes: #146797. - -2002-01-28 Marcus Brinkmann - - * copyright: Remove Linuxism. - -2001-12-29 Marcus Brinkmann - - * rules (configure): Don't call aclocal. - * control (Build-Depends): We don't need automake. - -2001-12-29 Marcus Brinkmann - - * control (Build-Depends): Add automake and autoconf to build - dependencies. Reported by Jordi Mallach. - -2001-11-05 Marcus Brinkmann - - * debian/changelog: Update for new Debian package. - -2001-10-16 Marcus Brinkmann - - * debian/changelog: Update for new Debian package. - -2001-10-13 Marcus Brinkmann - - * debian/rules: New dpkg-shlibdeps is more strict and complains - about statically linked files, so a new filter is necessary. - * debian/control: Add `file' to build dependencies. - By Kevin Kreamer . - - * debian/changelog: Update for new release. - -2001-10-01 Marcus Brinkmann - - * changelog: Update to current version. - * update-rc.d: New file moved from dpkg to here. - * rules: Install update-rc.d. - -2001-08-17 Marcus Brinkmann - - * changelog: Update to current version. - -2001-07-18 Marcus Brinkmann - - * copyright: Refer to new directory. - * rules: Move documentation to share directory. - Add -isp to dpkg-gencontrol invocation. - Remove crufty hurd.info. - * control: Bump up standards version. - -2001-07-18 Marcus Brinkmann - - * rc: Do not excempt random-seed when cleaning up /var/run. State - data should be in /var/lib (FHS) or /var/state. - * changelog: Update to current version. - * debian/servers.boot: Add die $(serverboot). - -2001-06-17 Marcus Brinkmann - - * changelog: Update to current version. - -2001-06-15 Marcus Brinkmann - - * rc: Merge in recent changes from daemons/rc.sh. - -2001-06-15 Marcus Brinkmann - - * rc: Be more selective with what to clean from /var/run. - Patch by Moritz Schulte . - -2001-04-29 Marcus Brinkmann - - * changelog: Update to reflect Debian upgrades. - -2001-01-09 Marcus Brinkmann - - * changelog: Update to reflect Debian upgrade. - - * rules: Use --disable-profile wih configure instead no_prof=t - with make. - -2000-11-27 Marcus Brinkmann - - * changelog: Update to reflect Debian upgrade. - * rc: New file. - * rules: Install rc. - * control: Add Build-Depends. - -2000-07-04 Marcus Brinkmann - - * changelog: Update to reflect Debian uploads. - * rules: Use install_script to install scripts. - Don't check for shared libraries in scripts. - -2000-01-30 Marcus Brinkmann - - * changelog: Update to reflect Debian uploads. - -1999-10-09 Marcus Brinkmann - - * rules (BUILDARCH): Renamed to DEB_BUILD_GNU_TYPE. - (HOSTARCH): Renamed to DEB_HOST_GNU_TYPE. - (INFODIR): New variable. - (STAMPS_TO_CLEAN): Add stamp-config. - (configure): Depend on configure.in. - (config, stamp-config): New targets. - (stamp-build): Build info documentation. - (clean): Do not clean up build directory, it will be removed. - Clean documentation directory. - (binary-arch): Remove etc/motd. - Expand bash {,} syntax. - Gzip serverboot. - Install additional documentation formats. - Rename libexec/runsystem to libexec/runsystem.gnu. - Install postinst, prerm - (.PHONY): Add config. - - * postinst, prerm: New Files. - * shlibs,shlibs.local: Remove libmom. - * changelog: Update to reflect Debian uploads. - -1999-06-01 Marcus Brinkmann - - * TODO: Remove entry about shared library dependencies (see below). - Remove entry about suid-manager. We don't need to register binaries - which must be suid to operate. - - * shlibs: New file. This makes Debian packages which use Hurd - libraries dependant on the Hurd package. - * rules: Add shlibs to the Hurd package. - - * changelog: Update to reflect the Debian releases done. - - * servers.boot: Remove obsolete $(default-pager) tag. - - * control: Add Replaces, Conflicts login, as done with makedev. - - * shlibs.local: New file. This is a work around needed for cross - compilation, so dpkg-shlibdeps does not make the Hurd package - dependant on itself. - -1999-05-29 Roland McGrath - - * rules (binary-arch): Don't remove root and etc dirs. - - * conffiles: Add /etc/ttys. - -1999-04-28 Roland McGrath - - * rules (binary-arch): Add etc, etc/login subdirs to chmod cmd. - Use $(addprefix) fn to avoid repetition. - - * conffiles: Add /etc/login files .bash_login, .bashrc, .hushlogin, - .profile and README. - -Wed Apr 28 02:44:13 1999 Thomas Bushnell, BSG - - * TODO: New item. - All of these because Marcus says so. - -1999-04-25 Roland McGrath - - * control (Depends): Change shlibs to hurd cause Marcus says so. - -1999-04-18 Roland McGrath - - * rules (binary-arch): Fix $ -> $$ and \\ -> \. - From Marcus Brinkmann. - -1999-04-15 Roland McGrath - - * control (Provides): Add login. - (Replaces, Conflicts): New frobs, listing makedev. - -1999-03-17 Gordon Matzigkeit - - * servers.boot: Clarify the default-pager description, and - add a default `$(default-pager)' line. - - * Makefile: New file. -- cgit v1.2.3 From 85ff4c004a5c287ba3411d1d1270cc4304bfbb0c Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 6 Jun 2007 15:32:33 +0000 Subject: 2007-06-06 Thomas Schwinge * default_pager.c (default_pager_object_create, default_pager_info) (default_pager_objects, default_pager_object_pages) (default_pager_object_set_size, default_pager_paging_file): Rename to `S_default_pager_object_create', `S_default_pager_info', `S_default_pager_objects', `S_default_pager_object_pages', `S_default_pager_object_set_size' and `S_default_pager_paging_file'. --- serverboot/ChangeLog | 9 +++++++++ serverboot/default_pager.c | 45 ++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index f0997fc5..8dc836cc 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,12 @@ +2007-06-06 Thomas Schwinge + + * default_pager.c (default_pager_object_create, default_pager_info) + (default_pager_objects, default_pager_object_pages) + (default_pager_object_set_size, default_pager_paging_file): Rename to + `S_default_pager_object_create', `S_default_pager_info', + `S_default_pager_objects', `S_default_pager_object_pages', + `S_default_pager_object_set_size' and `S_default_pager_paging_file'. + 2006-03-15 Alfred M. Szmidt * kalloc.c: #include . diff --git a/serverboot/default_pager.c b/serverboot/default_pager.c index e495ee95..c40f7181 100644 --- a/serverboot/default_pager.c +++ b/serverboot/default_pager.c @@ -3303,10 +3303,10 @@ default_pager() /* * Create an external object. */ -kern_return_t default_pager_object_create(pager, mem_obj, size) - mach_port_t pager; - mach_port_t *mem_obj; - vm_size_t size; +kern_return_t +S_default_pager_object_create (mach_port_t pager, + mach_port_t *mem_obj, + vm_size_t size) { default_pager_t ds; mach_port_t port; @@ -3347,9 +3347,9 @@ rename_it: return (KERN_SUCCESS); } -kern_return_t default_pager_info(pager, infop) - mach_port_t pager; - default_pager_info_t *infop; +kern_return_t +S_default_pager_info (mach_port_t pager, + default_pager_info_t *infop) { vm_size_t total, free; @@ -3366,12 +3366,12 @@ kern_return_t default_pager_info(pager, infop) return KERN_SUCCESS; } -kern_return_t default_pager_objects(pager, objectsp, ocountp, portsp, pcountp) - mach_port_t pager; - default_pager_object_array_t *objectsp; - natural_t *ocountp; - mach_port_array_t *portsp; - natural_t *pcountp; +kern_return_t +S_default_pager_objects (mach_port_t pager, + default_pager_object_array_t *objectsp, + natural_t *ocountp, + mach_port_array_t *portsp, + natural_t *pcountp) { vm_offset_t oaddr; /* memory for objects */ vm_size_t osize; /* current size */ @@ -3602,11 +3602,10 @@ not_this_one: kern_return_t -default_pager_object_pages(pager, object, pagesp, countp) - mach_port_t pager; - mach_port_t object; - default_pager_page_array_t *pagesp; - natural_t *countp; +S_default_pager_object_pages (mach_port_t pager, + mach_port_t object, + default_pager_page_array_t *pagesp, + natural_t *countp) { vm_offset_t addr; /* memory for page offsets */ vm_size_t size; /* current memory size */ @@ -3708,10 +3707,10 @@ default_pager_object_pages(pager, object, pagesp, countp) kern_return_t -default_pager_object_set_size(mach_port_t pager, - mach_port_seqno_t seqno, - mach_port_t reply_to, - vm_size_t limit) +S_default_pager_object_set_size (mach_port_t pager, + mach_port_seqno_t seqno, + mach_port_t reply_to, + vm_size_t limit) { kern_return_t kr; default_pager_t ds; @@ -3765,7 +3764,7 @@ extern mach_port_t bootstrap_master_device_port; extern mach_port_t bootstrap_master_host_port; kern_return_t -default_pager_paging_file(pager, mdport, file_name, add) +S_default_pager_paging_file (pager, mdport, file_name, add) mach_port_t pager; mach_port_t mdport; default_pager_filename_t file_name; -- cgit v1.2.3 From 8c1ea85c28a7a8f0f1dd963ad22fce4bcc97f9bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 20 Aug 2007 15:51:49 +0000 Subject: [doc/ChangeLog] 2007-08-16 Samuel Thibault * hurd.texi: Document diskfs_set_node_atime. [ext2fs/ChangeLog] 2007-08-16 Samuel Thibault * dir.c (diskfs_lookup_hard, diskfs_dirempty): Call diskfs_set_node_atime instead of setting dp->dn_set_atime. [fatfs/ChangeLog] 2007-08-16 Samuel Thibault * dir.c (diskfs_lookup_hard, diskfs_dirempty): Call diskfs_set_node_atime instead of setting dp->dn_set_atime. [libdiskfs/ChangeLog] 2007-08-16 Samuel Thibault * diskfs.h (diskfs_set_node_atime): New declaration. * node-times.c (diskfs_set_node_atime): New function. [ufs/ChangeLog] 2007-08-16 Samuel Thibault * dir.c (diskfs_lookup_hard, diskfs_dirempty): Call diskfs_set_node_atime instead of setting dp->dn_set_atime. * inode.c (read_symlink_hook): Likewise. --- ufs/ChangeLog | 6 ++++++ ufs/dir.c | 15 +++++---------- ufs/inode.c | 3 +-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index aa30e784..c7f01b7a 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,9 @@ +2007-08-16 Samuel Thibault + + * dir.c (diskfs_lookup_hard, diskfs_dirempty): Call + diskfs_set_node_atime instead of setting dp->dn_set_atime. + * inode.c (read_symlink_hook): Likewise. + 2006-03-15 Thomas Schwinge * dir.h (DIRECT_NAMELEN): Don't use ?: as a lvalue. diff --git a/ufs/dir.c b/ufs/dir.c index 83b30e72..7d9b0f55 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -162,8 +162,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, inum = 0; - if (!diskfs_check_readonly ()) - dp->dn_set_atime = 1; + diskfs_set_node_atime (dp); /* Start the lookup at DP->dn->dir_idx. */ idx = dp->dn->dir_idx; @@ -200,8 +199,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, } } - if (!diskfs_check_readonly ()) - dp->dn_set_atime = 1; + diskfs_set_node_atime (dp); if (diskfs_synchronous) diskfs_node_update (dp, 1); @@ -752,8 +750,7 @@ diskfs_dirempty(struct node *dp, mach_port_deallocate (mach_task_self (), memobj); assert (!err); - if (!diskfs_check_readonly ()) - dp->dn_set_atime = 1; + diskfs_set_node_atime (dp); for (curoff = buf; curoff < buf + dp->dn_stat.st_size; @@ -768,15 +765,13 @@ diskfs_dirempty(struct node *dp, && entry->d_name[1] != '\0'))) { munmap ((caddr_t) buf, dp->dn_stat.st_size); - if (!diskfs_check_readonly ()) - dp->dn_set_atime = 1; + diskfs_set_node_atime (dp); if (diskfs_synchronous) diskfs_node_update (dp, 1); return 0; } } - if (!diskfs_check_readonly ()) - dp->dn_set_atime = 1; + diskfs_set_node_atime (dp); if (diskfs_synchronous) diskfs_node_update (dp, 1); munmap ((caddr_t) buf, dp->dn_stat.st_size); diff --git a/ufs/inode.c b/ufs/inode.c index a8bb661f..228429b1 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -431,8 +431,7 @@ read_symlink_hook (struct node *np, bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); - if (! diskfs_check_readonly ()) - np->dn_set_atime = 1; + diskfs_set_node_atime (dp); diskfs_end_catch_exception (); return 0; -- cgit v1.2.3 From 21401a666fa450990a18ffce8f09e1fbc782e081 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 20 Aug 2007 15:53:31 +0000 Subject: compilation fix --- ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufs/inode.c b/ufs/inode.c index 228429b1..221a78f7 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -431,7 +431,7 @@ read_symlink_hook (struct node *np, bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size); - diskfs_set_node_atime (dp); + diskfs_set_node_atime (np); diskfs_end_catch_exception (); return 0; -- cgit v1.2.3 From 52ea733b99cb7de4794b0a8b3fa19dec57ec0ee9 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 5 Oct 2007 10:00:44 +0000 Subject: Update copyright years. --- ufs/dir.c | 4 +++- ufs/inode.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ufs/dir.c b/ufs/dir.c index 7d9b0f55..7a8cfa55 100644 --- a/ufs/dir.c +++ b/ufs/dir.c @@ -1,5 +1,7 @@ /* Directory management routines - Copyright (C) 1994,95,96,97,98,99,2000,02 Free Software Foundation, Inc. + + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2007 + 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 diff --git a/ufs/inode.c b/ufs/inode.c index 221a78f7..8223fe7f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -1,5 +1,7 @@ /* Inode management routines - Copyright (C) 1994,95,96,97,98,2000,01,02 Free Software Foundation, Inc. + + Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2007 + 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 -- cgit v1.2.3 From 22a7dbba5dff91de264d292ad8869448a00959e2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 7 Nov 2007 13:07:52 +0000 Subject: 2007-11-07 Thomas Schwinge * config.make.in (gnu89-inline-CFLAGS): New variable. * Makeconf (CFLAGS): Evaluate that one instead of hard-coding. Suggested by Olaf Buddenhagen, * configure.in (libc_cv_gnu89_inline): Fill depending on a compile-time test, as per glibc HEAD, 2007-11-07. --- configure.in | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 74fc9d13..a7bc4807 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION([$Id: configure.in,v 1.36 2005/04/07 20:48:40 ams Exp $]) +AC_REVISION([$Id: configure.in,v 1.37 2007/11/07 13:07:52 tschwinge Exp $]) AC_PREREQ(2.54) dnl Minimum Autoconf version required. AC_INIT AC_CONFIG_SRCDIR([hurd/hurd_types.h]) dnl File to look for in srcdir. @@ -156,6 +156,33 @@ AC_SUBST(VERSIONING) # Check if libc contains getgrouplist and/or uselocale. AC_CHECK_FUNCS(getgrouplist uselocale) + +# From glibc HEAD, 2007-11-07. +AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD]) +then + libc_cv_gnu89_inline=yes +else + libc_cv_gnu89_inline=no +fi +rm -f conftest*]) +if test $libc_cv_gnu89_inline = yes; then + libc_cv_gnu89_inline=-fgnu89-inline +else + libc_cv_gnu89_inline= +fi +AC_SUBST(libc_cv_gnu89_inline) + + AC_ARG_WITH(parted, dnl [ --without-parted don't try to use GNU Parted libraries], , with_parted=yes) -- cgit v1.2.3 From 9ff2c2069962fba25698630c49ab5dd72b5e5b62 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 13 Nov 2007 22:52:31 +0000 Subject: 2007-11-13 Thomas Schwinge * configure: Regenerate. --- configure | 3815 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 2230 insertions(+), 1585 deletions(-) diff --git a/configure b/configure index e335a198..36e16d75 100755 --- a/configure +++ b/configure @@ -1,26 +1,55 @@ #! /bin/sh -# From configure.in Id: configure.in,v 1.35 2003/02/15 23:57:50 roland Exp . +# From configure.in Id: configure.in,v 1.37 2007/11/07 13:07:52 tschwinge Exp . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59. +# Generated by GNU Autoconf 2.61. # -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -30,8 +59,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -45,18 +109,19 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -64,157 +129,388 @@ fi # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` +# CDPATH. +$as_unset CDPATH -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no fi + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in + case $as_dir in /*) - if ("$as_dir/$as_base" -c ' + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || + chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -223,7 +519,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -232,39 +549,27 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH +exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -exec 6>&1 - # # Initializations. # ac_default_prefix=/usr/local +ac_clean_files= ac_config_libobj_dir=. +LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= @@ -274,8 +579,88 @@ PACKAGE_BUGREPORT= ac_unique_file="hurd/hurd_types.h" ac_default_prefix= -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os asm_syntax enable_profile enable_static_progs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LD ac_ct_LD OBJCOPY ac_ct_OBJCOPY AR ac_ct_AR RANLIB ac_ct_RANLIB MIG ac_ct_MIG LIBCRYPT VERSIONING boot_store_types NCURSESW_INCLUDE LIBNCURSESW LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +asm_syntax +enable_profile +enable_static_progs +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +AWK +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +LD +OBJCOPY +AR +RANLIB +MIG +LIBCRYPT +VERSIONING +libc_cv_gnu89_inline +boot_store_types +NCURSESW_INCLUDE +LIBNCURSESW +LIBOBJS +LTLIBOBJS' ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS' + # Initialize some variables set by options. ac_init_help= @@ -302,34 +687,48 @@ x_libraries=NONE # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' ac_prev= +ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option ac_prev= continue fi - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -351,33 +750,45 @@ do --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -404,6 +815,12 @@ do -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -428,13 +845,16 @@ do | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -499,6 +919,16 @@ do | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -551,24 +981,20 @@ do -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. @@ -599,8 +1025,7 @@ Try \`$0 --help' for more information." >&2 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" + eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) @@ -620,27 +1045,19 @@ if test -n "$ac_prev"; then { (exit 1); exit 1; }; } fi -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir do - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -667,71 +1084,77 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS - + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + # # Report the --help message. # @@ -759,9 +1182,6 @@ Configuration: -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] -_ACEOF - - cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] @@ -779,15 +1199,22 @@ Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --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] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -831,125 +1258,94 @@ Some influential environment variables: CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF +ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue + test -d "$ac_dir" || continue ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } done fi -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit 0 + exit fi -exec 5>config.log -cat >&5 <<_ACEOF +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 -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF +exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -968,7 +1364,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -982,6 +1378,7 @@ do test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done +IFS=$as_save_IFS } >&5 @@ -1003,7 +1400,6 @@ _ACEOF ac_configure_args= ac_configure_args0= ac_configure_args1= -ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1014,7 +1410,7 @@ do -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in @@ -1036,9 +1432,7 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done @@ -1049,8 +1443,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1063,20 +1457,34 @@ trap 'exit_status=$? _ASBOX echo # The following way of writing the cache mishandles newlines in values, -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} + esac | + sort +) echo cat <<\_ASBOX @@ -1087,22 +1495,28 @@ _ASBOX echo for ac_var in $ac_subst_vars do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## +## ------------------- ## +## File substitutions. ## +## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1114,26 +1528,24 @@ _ASBOX ## ----------- ## _ASBOX echo - sed "/^$/d" confdefs.h | sort + cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status - ' 0 +' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h # Predefined preprocessor variables. @@ -1164,14 +1576,17 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" fi -for ac_site_file in $CONFIG_SITE; do +shift +for ac_site_file +do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} @@ -1187,8 +1602,8 @@ if test -r "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; esac fi else @@ -1200,12 +1615,11 @@ fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 @@ -1230,8 +1644,7 @@ echo "$as_me: current value: $ac_new_val" >&2;} # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1248,12 +1661,6 @@ echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start ov { (exit 1); exit 1; }; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - @@ -1270,87 +1677,127 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break - elif test -f $ac_dir/install.sh; then + elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break - elif test -f $ac_dir/shtool; then + elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + # Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } +fi fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac case "$host_os" in @@ -1413,18 +1860,18 @@ test -r "$srcdir/libthreads/$asm_syntax/cthreads.h" || { echo "$as_me: WARNING: unsupported CPU type $host_cpu" >&2;} } -# Check whether --enable-profile or --disable-profile was given. +# Check whether --enable-profile was given. if test "${enable_profile+set}" = set; then - enableval="$enable_profile" + enableval=$enable_profile; +fi -fi; -# Check whether --enable-static-progs or --disable-static-progs was given. +# Check whether --enable-static-progs was given. if test "${enable_static_progs+set}" = set; then - enableval="$enable_static_progs" + enableval=$enable_static_progs; +fi -fi; case "$enable_static_progs" in 'no') enable_static_progs= ;; # we got --disable-static '') enable_static_progs='ext2fs,ufs' ;; @@ -1446,8 +1893,8 @@ enable_static_progs=`echo "$enable_static_progs" | sed 's/[, ][, ]*/ /g'` # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -1469,7 +1916,7 @@ case $as_dir/ in # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -1488,21 +1935,22 @@ case $as_dir/ in ;; esac done +IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is - # removed, or if the path is relative. + # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -1516,8 +1964,8 @@ for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1530,25 +1978,27 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6 + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$AWK" && break done @@ -1561,8 +2011,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1575,32 +2025,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1613,36 +2065,51 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1655,74 +2122,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1736,7 +2163,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -1747,6 +2174,7 @@ do fi done done +IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -1764,22 +2192,23 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1792,36 +2221,38 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1834,29 +2265,45 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$ac_ct_CC" && break done - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi fi fi @@ -1869,21 +2316,35 @@ See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 +echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } @@ -1908,47 +2369,77 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. break;; * ) break;; esac done +test "$ac_cv_exeext" = no && ac_cv_exeext= + else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -1960,19 +2451,21 @@ See \`config.log' for more details." >&2;} fi ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -1991,22 +2484,27 @@ See \`config.log' for more details." >&2;} fi fi fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then @@ -2017,9 +2515,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext break;; * ) break;; esac @@ -2033,14 +2530,14 @@ See \`config.log' for more details." >&2;} fi rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2060,14 +2557,20 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac @@ -2085,12 +2588,12 @@ fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2113,49 +2616,49 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2171,37 +2674,118 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_prog_cc_g=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2217,12 +2801,12 @@ else CFLAGS= fi fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2256,12 +2840,17 @@ static char *f (char * (*g) (char **, int), char **p, ...) /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ + that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2276,201 +2865,57 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext CC=$ac_save_CC fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2487,8 +2932,8 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. set dummy ${ac_tool_prefix}ld; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2501,32 +2946,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LD="${ac_tool_prefix}ld" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi LD=$ac_cv_prog_LD if test -n "$LD"; then - echo "$as_me:$LINENO: result: $LD" >&5 -echo "${ECHO_T}$LD" >&6 + { echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_LD"; then ac_ct_LD=$LD # Extract the first word of "ld", so it can be a program name with args. set dummy ld; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2539,26 +2986,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LD="ld" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_LD=$ac_cv_prog_ac_ct_LD if test -n "$ac_ct_LD"; then - echo "$as_me:$LINENO: result: $ac_ct_LD" >&5 -echo "${ECHO_T}$ac_ct_LD" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_LD" >&5 +echo "${ECHO_T}$ac_ct_LD" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - LD=$ac_ct_LD + if test "x$ac_ct_LD" = x; then + LD="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + LD=$ac_ct_LD + fi else LD="$ac_cv_prog_LD" fi @@ -2566,8 +3028,8 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. set dummy ${ac_tool_prefix}objcopy; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_OBJCOPY+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2580,32 +3042,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJCOPY="${ac_tool_prefix}objcopy" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi OBJCOPY=$ac_cv_prog_OBJCOPY if test -n "$OBJCOPY"; then - echo "$as_me:$LINENO: result: $OBJCOPY" >&5 -echo "${ECHO_T}$OBJCOPY" >&6 + { echo "$as_me:$LINENO: result: $OBJCOPY" >&5 +echo "${ECHO_T}$OBJCOPY" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_OBJCOPY"; then ac_ct_OBJCOPY=$OBJCOPY # Extract the first word of "objcopy", so it can be a program name with args. set dummy objcopy; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2618,26 +3082,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJCOPY="objcopy" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY if test -n "$ac_ct_OBJCOPY"; then - echo "$as_me:$LINENO: result: $ac_ct_OBJCOPY" >&5 -echo "${ECHO_T}$ac_ct_OBJCOPY" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_OBJCOPY" >&5 +echo "${ECHO_T}$ac_ct_OBJCOPY" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - OBJCOPY=$ac_ct_OBJCOPY + if test "x$ac_ct_OBJCOPY" = x; then + OBJCOPY="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + OBJCOPY=$ac_ct_OBJCOPY + fi else OBJCOPY="$ac_cv_prog_OBJCOPY" fi @@ -2645,8 +3124,8 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2659,32 +3138,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - echo "$as_me:$LINENO: result: $AR" >&5 -echo "${ECHO_T}$AR" >&6 + { echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2697,26 +3178,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 -echo "${ECHO_T}$ac_ct_AR" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - AR=$ac_ct_AR + if test "x$ac_ct_AR" = x; then + AR="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi else AR="$ac_cv_prog_AR" fi @@ -2724,8 +3220,8 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2738,32 +3234,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - echo "$as_me:$LINENO: result: $RANLIB" >&5 -echo "${ECHO_T}$RANLIB" >&6 + { echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2776,26 +3274,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -echo "${ECHO_T}$ac_ct_RANLIB" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - RANLIB=$ac_ct_RANLIB + if test "x$ac_ct_RANLIB" = x; then + RANLIB="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi else RANLIB="$ac_cv_prog_RANLIB" fi @@ -2803,8 +3316,8 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args. set dummy ${ac_tool_prefix}mig; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_MIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2817,32 +3330,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MIG="${ac_tool_prefix}mig" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi MIG=$ac_cv_prog_MIG if test -n "$MIG"; then - echo "$as_me:$LINENO: result: $MIG" >&5 -echo "${ECHO_T}$MIG" >&6 + { echo "$as_me:$LINENO: result: $MIG" >&5 +echo "${ECHO_T}$MIG" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_MIG"; then ac_ct_MIG=$MIG # Extract the first word of "mig", so it can be a program name with args. set dummy mig; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_MIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2855,26 +3370,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MIG="mig" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_MIG=$ac_cv_prog_ac_ct_MIG if test -n "$ac_ct_MIG"; then - echo "$as_me:$LINENO: result: $ac_ct_MIG" >&5 -echo "${ECHO_T}$ac_ct_MIG" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_MIG" >&5 +echo "${ECHO_T}$ac_ct_MIG" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - MIG=$ac_ct_MIG + if test "x$ac_ct_MIG" = x; then + MIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + MIG=$ac_ct_MIG + fi else MIG="$ac_cv_prog_MIG" fi @@ -2898,8 +3428,8 @@ fi # See if there's a separate libcrypt (many systems put crypt there). -echo "$as_me:$LINENO: checking for crypt in -lcrypt" >&5 -echo $ECHO_N "checking for crypt in -lcrypt... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for crypt in -lcrypt" >&5 +echo $ECHO_N "checking for crypt in -lcrypt... $ECHO_C" >&6; } if test "${ac_cv_lib_crypt_crypt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2912,55 +3442,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* 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 -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char crypt (); int main () { -crypt (); +return crypt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_crypt_crypt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_crypt_crypt=no + ac_cv_lib_crypt_crypt=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_crypt_crypt" >&5 -echo "${ECHO_T}$ac_cv_lib_crypt_crypt" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_crypt_crypt" >&5 +echo "${ECHO_T}$ac_cv_lib_crypt_crypt" >&6; } if test $ac_cv_lib_crypt_crypt = yes; then LIBCRYPT=-lcrypt fi @@ -2968,8 +3496,8 @@ fi # See if mig groks `retcode'. -echo "$as_me:$LINENO: checking whether $MIG supports the retcode keyword" >&5 -echo $ECHO_N "checking whether $MIG supports the retcode keyword... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $MIG supports the retcode keyword" >&5 +echo $ECHO_N "checking whether $MIG supports the retcode keyword... $ECHO_C" >&6; } if test "${hurd_cv_mig_retcode+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2995,8 +3523,8 @@ else fi rm -f conftest* fi -echo "$as_me:$LINENO: result: $hurd_cv_mig_retcode" >&5 -echo "${ECHO_T}$hurd_cv_mig_retcode" >&6 +{ echo "$as_me:$LINENO: result: $hurd_cv_mig_retcode" >&5 +echo "${ECHO_T}$hurd_cv_mig_retcode" >&6; } if test $hurd_cv_mig_retcode = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MIG_RETCODE 1 @@ -3005,8 +3533,8 @@ _ACEOF fi # See if --version-script is available. -echo "$as_me:$LINENO: checking for ld --version-script" >&5 -echo $ECHO_N "checking for ld --version-script... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for ld --version-script" >&5 +echo $ECHO_N "checking for ld --version-script... $ECHO_C" >&6; } if test "${hurd_cv_ld_version_script_option+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3044,12 +3572,12 @@ else fi rm -f conftest* fi -echo "$as_me:$LINENO: result: $hurd_cv_ld_version_script_option" >&5 -echo "${ECHO_T}$hurd_cv_ld_version_script_option" >&6 +{ echo "$as_me:$LINENO: result: $hurd_cv_ld_version_script_option" >&5 +echo "${ECHO_T}$hurd_cv_ld_version_script_option" >&6; } # See if libc was built with --enable-libio. -echo "$as_me:$LINENO: checking for libio" >&5 -echo $ECHO_N "checking for libio... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for libio" >&5 +echo $ECHO_N "checking for libio... $ECHO_C" >&6; } if test "${hurd_cv_libio+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3072,37 +3600,34 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then hurd_cv_libio=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -hurd_cv_libio=no + hurd_cv_libio=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $hurd_cv_libio" >&5 -echo "${ECHO_T}$hurd_cv_libio" >&6 +{ echo "$as_me:$LINENO: result: $hurd_cv_libio" >&5 +echo "${ECHO_T}$hurd_cv_libio" >&6; } # The versions of the symbols in libthreads have to match those in # libc.so. Since the symbols in a libc that includes libio will be @@ -3122,9 +3647,9 @@ fi for ac_func in getgrouplist uselocale do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -3150,67 +3675,60 @@ cat >>conftest.$ac_ext <<_ACEOF #undef $ac_func -/* Override any gcc2 internal prototype to avoid an error. */ +/* 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 -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +#if defined __stub_$ac_func || defined __stub___$ac_func choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != $ac_func; +return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" + eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 @@ -3221,27 +3739,66 @@ done -# Check whether --with-parted or --without-parted was given. -if test "${with_parted+set}" = set; then - withval="$with_parted" +# From glibc HEAD, 2007-11-07. +{ echo "$as_me:$LINENO: checking for -fgnu89-inline" >&5 +echo $ECHO_N "checking for -fgnu89-inline... $ECHO_C" >&6; } +if test "${libc_cv_gnu89_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } +then + libc_cv_gnu89_inline=yes +else + libc_cv_gnu89_inline=no +fi +rm -f conftest* +fi +{ echo "$as_me:$LINENO: result: $libc_cv_gnu89_inline" >&5 +echo "${ECHO_T}$libc_cv_gnu89_inline" >&6; } +if test $libc_cv_gnu89_inline = yes; then + libc_cv_gnu89_inline=-fgnu89-inline +else + libc_cv_gnu89_inline= +fi + + + +# Check whether --with-parted was given. +if test "${with_parted+set}" = set; then + withval=$with_parted; else with_parted=yes -fi; +fi -# Check whether --enable-boot-store-types or --disable-boot-store-types was given. -if test "${enable_boot_store_types+set}" = set; then - enableval="$enable_boot_store_types" -fi; if test -z "$enable_boot_store_types"; then +# Check whether --enable-boot-store-types was given. +if test "${enable_boot_store_types+set}" = set; then + enableval=$enable_boot_store_types; +fi +if test -z "$enable_boot_store_types"; then boot_store_types='device remap gunzip bunzip2' # Check for Parted's static store module. if test "x$with_parted" != xno; then save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -static" - echo "$as_me:$LINENO: checking for store_part_open in -lstore_part" >&5 -echo $ECHO_N "checking for store_part_open in -lstore_part... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for store_part_open in -lstore_part" >&5 +echo $ECHO_N "checking for store_part_open in -lstore_part... $ECHO_C" >&6; } if test "${ac_cv_lib_store_part_store_part_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3254,55 +3811,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* 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 -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char store_part_open (); int main () { -store_part_open (); +return store_part_open (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_store_part_store_part_open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_store_part_store_part_open=no + ac_cv_lib_store_part_store_part_open=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_store_part_store_part_open" >&5 -echo "${ECHO_T}$ac_cv_lib_store_part_store_part_open" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_store_part_store_part_open" >&5 +echo "${ECHO_T}$ac_cv_lib_store_part_store_part_open" >&6; } if test $ac_cv_lib_store_part_store_part_open = yes; then boot_store_types="$boot_store_types part" fi @@ -3315,23 +3870,23 @@ echo "$as_me: WARNING: you probably wanted --disable-static-progs" >&2;} else boot_store_types="$enable_boot_store_types" fi -echo "$as_me:$LINENO: checking boot store types" >&5 -echo $ECHO_N "checking boot store types... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $boot_store_types" >&5 -echo "${ECHO_T}$boot_store_types" >&6 +{ echo "$as_me:$LINENO: checking boot store types" >&5 +echo $ECHO_N "checking boot store types... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $boot_store_types" >&5 +echo "${ECHO_T}$boot_store_types" >&6; } # Check for ncursesw, which is needed for the console-curses client. - # Check whether --enable-ncursesw or --disable-ncursesw was given. + # Check whether --enable-ncursesw was given. if test "${enable_ncursesw+set}" = set; then - enableval="$enable_ncursesw" - + enableval=$enable_ncursesw; else enable_ncursesw=yes -fi; +fi + if test "$enable_ncursesw" = yes; then - echo "$as_me:$LINENO: checking for initscr in -lncursesw" >&5 -echo $ECHO_N "checking for initscr in -lncursesw... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for initscr in -lncursesw" >&5 +echo $ECHO_N "checking for initscr in -lncursesw... $ECHO_C" >&6; } if test "${ac_cv_lib_ncursesw_initscr+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3344,79 +3899,77 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* 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 -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char initscr (); int main () { -initscr (); +return initscr (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_ncursesw_initscr=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_ncursesw_initscr=no + ac_cv_lib_ncursesw_initscr=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 -echo "${ECHO_T}$ac_cv_lib_ncursesw_initscr" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_ncursesw_initscr" >&6; } if test $ac_cv_lib_ncursesw_initscr = yes; then LIBNCURSESW="-lncursesw" fi if test "$LIBNCURSESW"; then -# Check whether --with-ncursesw-include-dir or --without-ncursesw-include-dir was given. +# Check whether --with-ncursesw-include-dir was given. if test "${with_ncursesw_include_dir+set}" = set; then - withval="$with_ncursesw_include_dir" - -fi; if test "${with_ncursesw_include_dir+set}" = set; then - echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 -echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6 + withval=$with_ncursesw_include_dir; +fi + if test "${with_ncursesw_include_dir+set}" = set; then + { echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 +echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6; } case "$with_ncursesw_include_dir" in no|none) hurd_cv_includedir_ncursesw=none;; *) hurd_cv_includedir_ncursesw="$with_ncursesw_include_dir";; esac - echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 -echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6 + { echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 +echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6; } else - echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 -echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for ncursesw include dir" >&5 +echo $ECHO_N "checking for ncursesw include dir... $ECHO_C" >&6; } if test "${hurd_cv_includedir_ncursesw+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3429,8 +3982,8 @@ else || hurd_cv_includedir_ncursesw=none done fi -echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 -echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6 +{ echo "$as_me:$LINENO: result: $hurd_cv_includedir_ncursesw" >&5 +echo "${ECHO_T}$hurd_cv_includedir_ncursesw" >&6; } fi if test "$hurd_cv_includedir_ncursesw" = none; then NCURSESW_INCLUDE="" @@ -3454,7 +4007,7 @@ else echo ${file}:build.mk.in; done`" fi - ac_config_files="$ac_config_files config.make ${makefiles}" +ac_config_files="$ac_config_files config.make ${makefiles}" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3474,39 +4027,58 @@ _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} | + esac | + sort +) | sed ' + /^ac_cv_env_/b end t clear - : clear + :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - echo "not updating unwritable cache $cache_file" + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -3515,63 +4087,48 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, +# take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF +ac_script=' t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -3602,17 +4159,45 @@ cat >>$CONFIG_STATUS <<\_ACEOF ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -3622,8 +4207,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -3637,18 +4257,19 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -3656,159 +4277,120 @@ fi # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` +# CDPATH. +$as_unset CDPATH -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -3817,7 +4399,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -3826,31 +4429,14 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - exec 6>&1 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +# Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - +# values after options handling. +ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3858,30 +4444,18 @@ generated by GNU Autoconf 2.59. Invocation command line was CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi +config_files="$ac_config_files" -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF - ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -3889,7 +4463,7 @@ current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -3900,19 +4474,21 @@ Configuration files: $config_files Report bugs to ." -_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -3923,60 +4499,42 @@ while test $# != 0 do case $1 in --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - -*) + *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; esac case $ac_option in # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" ;; + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; esac shift @@ -3992,29 +4550,43 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 - - - +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. for ac_config_target in $ac_config_targets do - case "$ac_config_target" in - # Handling of arguments. - "config.make" ) CONFIG_FILES="$CONFIG_FILES config.make" ;; - "${makefiles}" ) CONFIG_FILES="$CONFIG_FILES ${makefiles}" ;; + case $ac_config_target in + "config.make") CONFIG_FILES="$CONFIG_FILES config.make" ;; + "${makefiles}") CONFIG_FILES="$CONFIG_FILES ${makefiles}" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done + # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -4024,324 +4596,386 @@ if $ac_need_defaults; then fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. $debug || { - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } - # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - # -# CONFIG_FILES section. +# Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@build@,$build,;t t -s,@build_cpu@,$build_cpu,;t t -s,@build_vendor@,$build_vendor,;t t -s,@build_os@,$build_os,;t t -s,@host@,$host,;t t -s,@host_cpu@,$host_cpu,;t t -s,@host_vendor@,$host_vendor,;t t -s,@host_os@,$host_os,;t t -s,@asm_syntax@,$asm_syntax,;t t -s,@enable_profile@,$enable_profile,;t t -s,@enable_static_progs@,$enable_static_progs,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@AWK@,$AWK,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@LD@,$LD,;t t -s,@ac_ct_LD@,$ac_ct_LD,;t t -s,@OBJCOPY@,$OBJCOPY,;t t -s,@ac_ct_OBJCOPY@,$ac_ct_OBJCOPY,;t t -s,@AR@,$AR,;t t -s,@ac_ct_AR@,$ac_ct_AR,;t t -s,@RANLIB@,$RANLIB,;t t -s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t -s,@MIG@,$MIG,;t t -s,@ac_ct_MIG@,$ac_ct_MIG,;t t -s,@LIBCRYPT@,$LIBCRYPT,;t t -s,@VERSIONING@,$VERSIONING,;t t -s,@boot_store_types@,$boot_store_types,;t t -s,@NCURSESW_INCLUDE@,$NCURSESW_INCLUDE,;t t -s,@LIBNCURSESW@,$LIBNCURSESW,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF +if test -n "$CONFIG_FILES"; then _ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +asm_syntax!$asm_syntax$ac_delim +enable_profile!$enable_profile$ac_delim +enable_static_progs!$enable_static_progs$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +AWK!$AWK$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +LD!$LD$ac_delim +OBJCOPY!$OBJCOPY$ac_delim +AR!$AR$ac_delim +RANLIB!$RANLIB$ac_delim +MIG!$MIG$ac_delim +LIBCRYPT!$LIBCRYPT$ac_delim +VERSIONING!$VERSIONING$ac_delim +libc_cv_gnu89_inline!$libc_cv_gnu89_inline$ac_delim +boot_store_types!$boot_store_types$ac_delim +NCURSESW_INCLUDE!$NCURSESW_INCLUDE$ac_delim +LIBNCURSESW!$LIBNCURSESW$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 72; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi -fi # test -n "$CONFIG_FILES" +done +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } - ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + case $ac_mode in + :F) + # + # CONFIG_FILE + # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac +_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub @@ -4349,29 +4983,40 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF + + esac + +done # for ac_tag + { (exit 0); exit 0; } _ACEOF -- cgit v1.2.3 From ac6532774d82f0256e6821f3120e7983e4ed5cb6 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 13 Nov 2007 23:32:45 +0000 Subject: 2007-11-13 Thomas Schwinge * inode.c (read_disknode, write_node): Adapt to ``struct stat'' changes. --- ufs/ChangeLog | 5 +++++ ufs/inode.c | 36 ++++++++++++------------------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/ufs/ChangeLog b/ufs/ChangeLog index c7f01b7a..14fb86bd 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,8 @@ +2007-11-13 Thomas Schwinge + + * inode.c (read_disknode, write_node): Adapt to ``struct stat'' + changes. + 2007-08-16 Samuel Thibault * dir.c (diskfs_lookup_hard, diskfs_dirempty): Call diff --git a/ufs/inode.c b/ufs/inode.c index 8223fe7f..1a8a7098 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -233,18 +233,12 @@ read_disknode (struct node *np) | (di->di_trans ? S_IPTRANS : 0)); st->st_nlink = read_disk_entry (di->di_nlink); st->st_size = read_disk_entry (di->di_size); -#ifdef notyet - st->st_atimespec = di->di_atime; - st->st_mtimespec = di->di_mtime; - st->st_ctimespec = di->di_ctime; -#else - st->st_atime = read_disk_entry (di->di_atime.tv_sec); - st->st_atime_usec = read_disk_entry (di->di_atime.tv_nsec) / 1000; - st->st_mtime = read_disk_entry (di->di_mtime.tv_sec); - st->st_mtime_usec = read_disk_entry (di->di_mtime.tv_nsec) / 1000; - st->st_ctime = read_disk_entry (di->di_ctime.tv_sec); - st->st_ctime_usec = read_disk_entry (di->di_ctime.tv_nsec) / 1000; -#endif + st->st_atim.tv_sec = read_disk_entry (di->di_atime.tv_sec); + st->st_atim.tv_nsec = read_disk_entry (di->di_atime.tv_nsec); + st->st_mtim.tv_sec = read_disk_entry (di->di_mtime.tv_sec); + st->st_mtim.tv_nsec = read_disk_entry (di->di_mtime.tv_nsec); + st->st_ctim.tv_sec = read_disk_entry (di->di_ctime.tv_sec); + st->st_ctim.tv_nsec = read_disk_entry (di->di_ctime.tv_nsec); st->st_blksize = sblock->fs_bsize; st->st_blocks = read_disk_entry (di->di_blocks); st->st_flags = read_disk_entry (di->di_flags); @@ -359,18 +353,12 @@ write_node (struct node *np) write_disk_entry (di->di_nlink, st->st_nlink); write_disk_entry (di->di_size, st->st_size); -#ifdef notyet - di->di_atime = st->st_atimespec; - di->di_mtime = st->st_mtimespec; - di->di_ctime = st->st_ctimespec; -#else - write_disk_entry (di->di_atime.tv_sec, st->st_atime); - write_disk_entry (di->di_atime.tv_nsec, st->st_atime_usec * 1000); - write_disk_entry (di->di_mtime.tv_sec, st->st_mtime); - write_disk_entry (di->di_mtime.tv_nsec, st->st_mtime_usec * 1000); - write_disk_entry (di->di_ctime.tv_sec, st->st_ctime); - write_disk_entry (di->di_ctime.tv_nsec, st->st_ctime_usec * 1000); -#endif + write_disk_entry (di->di_atime.tv_sec, st->st_atim.tv_sec); + write_disk_entry (di->di_atime.tv_nsec, st->st_atim.tv_nsec); + write_disk_entry (di->di_mtime.tv_sec, st->st_mtim.tv_sec); + write_disk_entry (di->di_mtime.tv_nsec, st->st_mtim.tv_nsec); + write_disk_entry (di->di_ctime.tv_sec, st->st_ctim.tv_sec); + write_disk_entry (di->di_ctime.tv_nsec, st->st_ctim.tv_nsec); write_disk_entry (di->di_blocks, st->st_blocks); write_disk_entry (di->di_flags, st->st_flags); -- cgit v1.2.3