ufsread.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 2002 McAfee, Inc.
* All rights reserved.
*
* This software was developed for the FreeBSD Project by Marshall
* Kirk McKusick and McAfee Research,, the Security Research Division of
* part of the DARPA CHATS research program
*
* 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
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
/*-
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
*
* Redistribution and use in source and binary forms are freely
* permitted provided that the above copyright notice and this
* paragraph and the following disclaimer are duplicated in all
* such forms.
*
* This software is provided "AS IS" and without any express or
* implied warranties, including, without limitation, the implied
* warranties of merchantability and fitness for a particular
* purpose.
*/
__FBSDID("$FreeBSD$");
#ifdef UFS_SMALL_CGBASE
/* XXX: Revert to old (broken for over 1.5Tb filesystems) version of cgbase
support both UFS1 and UFS2. */
#endif
/*
* We use 4k `virtual' blocks for filesystem data, whatever the actual
* filesystem block size. FFS blocks are always a multiple of 4k.
*/
#define VBLKSHIFT 12
/* Buffers that must not span a 64k boundary. */
struct dmadat {
};
#ifndef UFS2_ONLY
static struct ufs1_dinode dp1;
#endif
#ifndef UFS1_ONLY
static struct ufs2_dinode dp2;
#endif
{
struct direct *d;
char *s;
ssize_t n;
fs_off = 0;
d = (void *)s;
if (ls)
return inode_type(*ino);
}
s += d->d_reclen;
}
if (n != -1 && ls)
printf("\n");
return 0;
}
static ufs_ino_t
{
const char *s;
ssize_t n;
for (;;) {
if (*path == '/')
path++;
if (!*path)
break;
for (s = path; *s && *s != '/'; s++);
return 0;
name[n] = 0;
return (0);
}
break;
path = s;
}
}
/*
* Possible superblock locations ordered from most to least likely.
*/
static int sblock_try[] = SBLOCKSEARCH;
#if defined(UFS2_ONLY)
#else
#endif
static uint8_t
{
char *blkbuf;
void *indbuf;
size_t n;
if (!inode)
return (0);
return (-1);
n = INO_TO_VBO(n, inode);
#if defined(UFS1_ONLY)
sizeof(struct ufs1_dinode));
sizeof(struct ufs2_dinode));
#else
sizeof(struct ufs1_dinode));
else
sizeof(struct ufs2_dinode));
#endif
fs_off = 0;
}
}
static ssize_t
{
char *blkbuf;
void *indbuf;
char *s;
u_int u;
/* Basic parameter validation. */
return (-1);
/*
* Force probe if inode is zero to ensure we have a valid fs, otherwise
* when probing multiple paritions, reads from subsequent parititions
* will incorrectly succeed.
*/
inomap = 0;
dsk_meta = 0;
for (n = 0; sblock_try[n] != -1; n++) {
SBLOCKSIZE / DEV_BSIZE))
return -1;
if ((
#if defined(UFS1_ONLY)
#else
#endif
) &&
break;
}
if (sblock_try[n] == -1) {
return -1;
}
dsk_meta++;
} else
if (!inode)
return 0;
return -1;
n = INO_TO_VBO(n, inode);
#if defined(UFS1_ONLY)
sizeof(dp1));
sizeof(dp2));
#else
sizeof(dp1));
else
sizeof(dp2));
#endif
fs_off = 0;
}
s = buf;
if (nbyte > n)
nbyte = n;
while (nb) {
n = INDIRPERVBLK(&fs);
return -1;
}
#if defined(UFS1_ONLY)
sizeof(ufs1_daddr_t));
sizeof(ufs2_daddr_t));
#else
sizeof(ufs1_daddr_t));
} else
sizeof(ufs2_daddr_t));
#endif
} else
return -1;
if (n > VBLKSIZE)
n = VBLKSIZE;
return -1;
}
n -= vboff;
if (n > nb)
n = nb;
s += n;
fs_off += n;
nb -= n;
}
return nbyte;
}
static ssize_t
{
}