summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/fsutil.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/fsck_ffs/fsutil.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/fsck_ffs/fsutil.c')
-rw-r--r--sbin/fsck_ffs/fsutil.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index bf6c7fe..18e5eed 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
+#include <sys/disklabel.h>
#include <sys/stat.h>
#include <sys/disklabel.h>
@@ -63,9 +64,9 @@ static const char rcsid[] =
long diskreads, totalreads; /* Disk cache statistics */
int
-ftypeok(struct dinode *dp)
+ftypeok(union dinode *dp)
{
- switch (dp->di_mode & IFMT) {
+ switch (DIP(dp, di_mode) & IFMT) {
case IFDIR:
case IFREG:
@@ -78,7 +79,7 @@ ftypeok(struct dinode *dp)
default:
if (debug)
- printf("bad file type 0%o\n", dp->di_mode);
+ printf("bad file type 0%o\n", DIP(dp, di_mode));
return (0);
}
}
@@ -181,7 +182,7 @@ bufinit(void)
* Manage a cache of directory blocks.
*/
struct bufarea *
-getdatablk(ufs_daddr_t blkno, long size)
+getdatablk(ufs2_daddr_t blkno, long size)
{
struct bufarea *bp;
@@ -207,9 +208,9 @@ foundit:
}
void
-getblk(struct bufarea *bp, ufs_daddr_t blk, long size)
+getblk(struct bufarea *bp, ufs2_daddr_t blk, long size)
{
- ufs_daddr_t dblk;
+ ufs2_daddr_t dblk;
totalreads++;
dblk = fsbtodb(&sblock, blk);
@@ -251,7 +252,7 @@ flush(int fd, struct bufarea *bp)
}
void
-rwerror(char *mesg, ufs_daddr_t blk)
+rwerror(char *mesg, ufs2_daddr_t blk)
{
if (bkgrdcheck)
@@ -293,9 +294,10 @@ ckfini(int markclean)
return;
}
flush(fswritefd, &sblk);
- if (havesb && sblk.b_bno != SBOFF / dev_bsize && cursnapshot == 0 &&
+ if (havesb && cursnapshot == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
+ sblk.b_bno != fsbtodb(&sblock, sblock.fs_sblockloc) &&
!preen && reply("UPDATE STANDARD SUPERBLOCK")) {
- sblk.b_bno = SBOFF / dev_bsize;
+ sblk.b_bno = fsbtodb(&sblock, sblock.fs_sblockloc);
sbdirty();
flush(fswritefd, &sblk);
}
@@ -336,7 +338,7 @@ ckfini(int markclean)
}
int
-bread(int fd, char *buf, ufs_daddr_t blk, long size)
+bread(int fd, char *buf, ufs2_daddr_t blk, long size)
{
char *cp;
int i, errs;
@@ -373,7 +375,7 @@ bread(int fd, char *buf, ufs_daddr_t blk, long size)
}
void
-bwrite(int fd, char *buf, ufs_daddr_t blk, long size)
+bwrite(int fd, char *buf, ufs2_daddr_t blk, long size)
{
int i;
char *cp;
@@ -406,7 +408,7 @@ bwrite(int fd, char *buf, ufs_daddr_t blk, long size)
/*
* allocate a data block with the specified number of fragments
*/
-ufs_daddr_t
+ufs2_daddr_t
allocblk(long frags)
{
int i, j, k, cg, baseblk;
@@ -450,7 +452,7 @@ allocblk(long frags)
* Free a previously allocated block
*/
void
-freeblk(ufs_daddr_t blkno, long frags)
+freeblk(ufs2_daddr_t blkno, long frags)
{
struct inodesc idesc;
OpenPOWER on IntegriCloud