2003-08-07 15:25:11 +04:00
|
|
|
/* $NetBSD: misc.c,v 1.7 2003/08/07 11:25:20 agc Exp $ */
|
1995-03-18 17:54:19 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 15:25:11 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-06-08 22:57:30 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
#ifndef lint
|
1995-03-18 17:54:19 +03:00
|
|
|
#if 0
|
1998-03-01 05:20:01 +03:00
|
|
|
static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95";
|
1995-03-18 17:54:19 +03:00
|
|
|
#else
|
2003-08-07 15:25:11 +04:00
|
|
|
__RCSID("$NetBSD: misc.c,v 1.7 2003/08/07 11:25:20 agc Exp $");
|
1995-03-18 17:54:19 +03:00
|
|
|
#endif
|
1994-06-08 22:57:30 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
1994-09-23 06:18:30 +04:00
|
|
|
|
|
|
|
#include <err.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
1994-09-23 06:18:30 +04:00
|
|
|
#include <stdlib.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#include <string.h>
|
1994-09-23 06:18:30 +04:00
|
|
|
#include <unistd.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#include "extern.h"
|
|
|
|
|
|
|
|
void
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
get(int fd, off_t off, void *p, size_t len)
|
1994-06-08 22:57:30 +04:00
|
|
|
{
|
|
|
|
int rbytes;
|
|
|
|
|
|
|
|
if (lseek(fd, off, SEEK_SET) < 0)
|
1994-09-23 06:18:30 +04:00
|
|
|
err(1, "%s", special);
|
1994-06-08 22:57:30 +04:00
|
|
|
if ((rbytes = read(fd, p, len)) < 0)
|
1994-09-23 06:18:30 +04:00
|
|
|
err(1, "%s", special);
|
1994-06-08 22:57:30 +04:00
|
|
|
if (rbytes != len)
|
1998-03-03 10:35:50 +03:00
|
|
|
errx(1, "%s: short read (%d, not %lu)", special, rbytes,
|
|
|
|
(u_long)len);
|
1994-06-08 22:57:30 +04:00
|
|
|
}
|