summaryrefslogtreecommitdiffstats
path: root/sbin/tunefs/tunefs.c
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/tunefs/tunefs.c
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/tunefs/tunefs.c')
-rw-r--r--sbin/tunefs/tunefs.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index b40c8cb..e272446 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -53,8 +53,9 @@ static const char rcsid[] =
#include <sys/disklabel.h>
#include <sys/stat.h>
-#include <ufs/ffs/fs.h>
#include <ufs/ufs/ufsmount.h>
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
#include <err.h>
#include <fcntl.h>
@@ -77,8 +78,8 @@ union {
int fi;
long dev_bsize = 1;
-void bwrite(daddr_t, const char *, int);
-int bread(daddr_t, char *, int);
+void bwrite(ufs2_daddr_t, const char *, int);
+int bread(ufs2_daddr_t, char *, int);
void getsb(struct fs *, const char *);
void putsb(struct fs *, const char *, int);
void usage(void);
@@ -93,9 +94,9 @@ main(argc, argv)
const char *name;
struct stat st;
int Aflag = 0, active = 0;
- int aflag = 0, dflag = 0, eflag = 0, fflag = 0, mflag = 0;
+ int aflag = 0, eflag = 0, fflag = 0, mflag = 0;
int nflag = 0, oflag = 0, pflag = 0, sflag = 0;
- int avalue = 0, dvalue = 0, evalue = 0, fvalue = 0;
+ int avalue = 0, evalue = 0, fvalue = 0;
int mvalue = 0, ovalue = 0, svalue = 0;
char *nvalue = NULL;
struct fstab *fs;
@@ -108,7 +109,7 @@ main(argc, argv)
if (argc < 3)
usage();
found_arg = 0; /* at least one arg is required */
- while ((ch = getopt(argc, argv, "Aa:d:e:f:m:n:o:ps:")) != -1)
+ while ((ch = getopt(argc, argv, "Aa:e:f:m:n:o:ps:")) != -1)
switch (ch) {
case 'A':
found_arg = 1;
@@ -122,12 +123,6 @@ main(argc, argv)
errx(10, "%s must be >= 1 (was %s)", name, optarg);
aflag = 1;
break;
- case 'd':
- found_arg = 1;
- name = "rotational delay between contiguous blocks";
- dvalue = atoi(optarg);
- dflag = 1;
- break;
case 'e':
found_arg = 1;
name = "maximum blocks per file in a cylinder group";
@@ -237,17 +232,6 @@ again:
sblock.fs_maxcontig = avalue;
}
}
- if (dflag) {
- name = "rotational delay between contiguous blocks";
- if (sblock.fs_rotdelay == dvalue) {
- warnx("%s remains unchanged as %dms", name, dvalue);
- }
- else {
- warnx("%s changes from %dms to %dms",
- name, sblock.fs_rotdelay, dvalue);
- sblock.fs_rotdelay = dvalue;
- }
- }
if (eflag) {
name = "maximum blocks per file in a cylinder group";
if (sblock.fs_maxbpg == evalue) {
@@ -358,20 +342,36 @@ usage()
exit(2);
}
+/*
+ * Possible superblock locations ordered from most to least likely.
+ */
+static int sblock_try[] = SBLOCKSEARCH;
+static ufs2_daddr_t sblockloc;
+
void
getsb(fs, file)
struct fs *fs;
const char *file;
{
+ int i;
fi = open(file, O_RDONLY);
if (fi < 0)
err(3, "cannot open %s", file);
- if (bread((daddr_t)SBOFF, (char *)fs, SBSIZE))
- err(4, "%s: bad super block", file);
- if (fs->fs_magic != FS_MAGIC)
- errx(5, "%s: bad magic number", file);
+ for (i = 0; sblock_try[i] != -1; i++) {
+ if (bread(sblock_try[i], (char *)fs, SBLOCKSIZE))
+ err(4, "%s: bad super block", file);
+ 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)
+ err(5, "Cannot find filesystem superblock");
dev_bsize = fs->fs_fsize / fsbtodb(fs, 1);
+ sblockloc = sblock_try[i] / dev_bsize;
}
void
@@ -392,11 +392,11 @@ putsb(fs, file, all)
close(i);
if (fi < 0)
err(3, "cannot open %s", file);
- bwrite((daddr_t)SBOFF / dev_bsize, (const char *)fs, SBSIZE);
+ bwrite(sblockloc, (const char *)fs, SBLOCKSIZE);
if (all)
for (i = 0; i < fs->fs_ncg; i++)
bwrite(fsbtodb(fs, cgsblock(fs, i)),
- (const char *)fs, SBSIZE);
+ (const char *)fs, SBLOCKSIZE);
close(fi);
}
@@ -407,8 +407,6 @@ printfs()
(sblock.fs_flags & FS_DOSOFTDEP)? "enabled" : "disabled");
warnx("maximum contiguous block count: (-a) %d",
sblock.fs_maxcontig);
- warnx("rotational delay between contiguous blocks: (-d) %d ms",
- sblock.fs_rotdelay);
warnx("maximum blocks per file in a cylinder group: (-e) %d",
sblock.fs_maxbpg);
warnx("average file size: (-f) %d",
@@ -429,7 +427,7 @@ printfs()
void
bwrite(blk, buf, size)
- daddr_t blk;
+ ufs2_daddr_t blk;
const char *buf;
int size;
{
@@ -442,7 +440,7 @@ bwrite(blk, buf, size)
int
bread(bno, buf, cnt)
- daddr_t bno;
+ ufs2_daddr_t bno;
char *buf;
int cnt;
{
OpenPOWER on IntegriCloud