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 (limited to '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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(+) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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 (limited to 'ufs/hyper.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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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 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(-) (limited to 'ufs/hyper.c') 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