1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* 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);
}
/* 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;
}
|