summaryrefslogtreecommitdiffstats
path: root/sbin/badsect
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
committermckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
commit88d85c15ef183c06524d6ca695f62c0c0672b00c (patch)
treef1364dbfb9835934a3879b5904f7ff9a1495744c /sbin/badsect
parenteacb69b0197a8553d5004aa99532cabad8778e36 (diff)
downloadFreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.zip
FreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.tar.gz
This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit block pointers. It also adds a file-creation time field, an ability to use jumbo blocks per inode to allow extent like pointer density, and space for extended attributes (up to twice the filesystem block size worth of attributes, e.g., on a 16K filesystem, there is space for 32K of attributes). UFS2 fully supports and runs existing UFS1 filesystems. New filesystems built using newfs can be built in either UFS1 or UFS2 format using the -O option. In this commit UFS1 is the default format, so if you want to build UFS2 format filesystems, you must specify -O 2. This default will be changed to UFS2 when UFS2 proves itself to be stable. In this commit the boot code for reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c) as there is insufficient space in the boot block. Once the size of the boot block is increased, this code can be defined. Things to note: the definition of SBSIZE has changed to SBLOCKSIZE. The header file <ufs/ufs/dinode.h> must be included before <ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and ufs_lbn_t. Still TODO: Verify that the first level bootstraps work for all the architectures. Convert the utility ffsinfo to understand UFS2 and test growfs. Add support for the extended attribute storage. Update soft updates to ensure integrity of extended attribute storage. Switch the current extended attribute interfaces to use the extended attribute storage. Add the extent like functionality (framework is there, but is currently never used). Sponsored by: DARPA & NAI Labs. Reviewed by: Poul-Henning Kamp <phk@freebsd.org>
Diffstat (limited to 'sbin/badsect')
-rw-r--r--sbin/badsect/badsect.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c
index 6094db2..94f9023 100644
--- a/sbin/badsect/badsect.c
+++ b/sbin/badsect/badsect.c
@@ -59,8 +59,8 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <sys/disklabel.h>
-#include <ufs/ffs/fs.h>
#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
#include <err.h>
#include <dirent.h>
@@ -73,7 +73,7 @@ static const char rcsid[] =
union {
struct fs fs;
- char fsx[SBSIZE];
+ char fsx[SBLOCKSIZE];
} ufs;
#define sblock ufs.fs
union {
@@ -91,6 +91,11 @@ char buf[MAXBSIZE];
void rdfs(daddr_t, int, char *);
int chkuse(daddr_t, int);
+/*
+ * Possible superblock locations ordered from most to least likely.
+ */
+static int sblock_try[] = SBLOCKSEARCH;
+
static void
usage(void)
{
@@ -108,6 +113,7 @@ main(int argc, char *argv[])
DIR *dirp;
char name[2 * MAXPATHLEN];
char *name_dir_end;
+ int i;
if (argc < 3)
usage();
@@ -134,7 +140,19 @@ main(int argc, char *argv[])
if ((fsi = open(name, O_RDONLY)) < 0)
err(6, "%s", name);
fs = &sblock;
- rdfs(SBOFF, SBSIZE, (char *)fs);
+ for (i = 0; sblock_try[i] != -1; i++) {
+ rdfs(sblock_try[i] / dev_bsize, SBLOCKSIZE, (char *)fs);
+ if ((fs->fs_magic == FS_UFS1_MAGIC ||
+ (fs->fs_magic == FS_UFS2_MAGIC &&
+ fs->fs_sblockloc == numfrags(fs, sblock_try[i]))) &&
+ fs->fs_bsize <= MAXBSIZE &&
+ fs->fs_bsize >= sizeof(struct fs))
+ break;
+ }
+ if (sblock_try[i] == -1) {
+ printf("Cannot find filesystem\n");
+ exit(7);
+ }
dev_bsize = fs->fs_fsize / fsbtodb(fs, 1);
for (argc -= 2, argv += 2; argc > 0; argc--, argv++) {
number = atol(*argv);
OpenPOWER on IntegriCloud