aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/Makefile10
-rw-r--r--sbin/fsck_ffs/dir.c8
-rw-r--r--sbin/fsck_ffs/ea.c1
-rw-r--r--sbin/fsck_ffs/fsck.h24
-rw-r--r--sbin/fsck_ffs/fsck_ffs.85
-rw-r--r--sbin/fsck_ffs/fsutil.c20
-rw-r--r--sbin/fsck_ffs/globs.c14
-rw-r--r--sbin/fsck_ffs/inode.c39
-rw-r--r--sbin/fsck_ffs/main.c21
-rw-r--r--sbin/fsck_ffs/pass1.c6
-rw-r--r--sbin/fsck_ffs/pass1b.c6
-rw-r--r--sbin/fsck_ffs/pass2.c6
-rw-r--r--sbin/fsck_ffs/pass3.c6
-rw-r--r--sbin/fsck_ffs/pass4.c6
-rw-r--r--sbin/fsck_ffs/pass5.c7
-rw-r--r--sbin/fsck_ffs/setup.c27
-rw-r--r--sbin/fsck_ffs/suj.c4
-rw-r--r--sbin/fsck_ffs/utilities.c6
18 files changed, 73 insertions, 143 deletions
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
index de8913c1ecb3..c6676007db2a 100644
--- a/sbin/fsck_ffs/Makefile
+++ b/sbin/fsck_ffs/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 4/27/95
-
PACKAGE=ufs
PROG= fsck_ffs
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
@@ -7,12 +5,12 @@ LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
MAN= fsck_ffs.8
MLINKS= fsck_ffs.8 fsck_ufs.8 fsck_ffs.8 fsck_4.2bsd.8
SRCS= dir.c ea.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \
- pass4.c pass5.c setup.c suj.c utilities.c gjournal.c getmntopts.c \
+ pass4.c pass5.c setup.c suj.c utilities.c gjournal.c \
globs.c
-LIBADD= ufs
+LIBADD= ufs util
WARNS?= 2
-CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/mount
+CFLAGS+= -I${.CURDIR}
-.PATH: ${SRCTOP}/sys/ufs/ffs ${.CURDIR:H}/mount
+.PATH: ${SRCTOP}/sys/ufs/ffs
.include <bsd.prog.mk>
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 0551ba4521c3..3eb0b63c0988 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -258,7 +252,7 @@ fsck_readdir(struct inodesc *idesc)
dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
/*
* Only need to check current entry if it is the first in the
- * the block, as later entries will have been checked in the
+ * block, as later entries will have been checked in the
* previous call to this function.
*/
if (idesc->id_loc % DIRBLKSIZ != 0 || dircheck(idesc, bp, dp) != 0) {
diff --git a/sbin/fsck_ffs/ea.c b/sbin/fsck_ffs/ea.c
index 8e5e8ebe8aa0..f6ebc5c072fc 100644
--- a/sbin/fsck_ffs/ea.c
+++ b/sbin/fsck_ffs/ea.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stdint.h>
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 1864ea19f4ca..aaf02850f29a 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -57,8 +57,6 @@
* 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.
- *
- * @(#)fsck.h 8.4 (Berkeley) 5/9/95
*/
#ifndef _FSCK_H_
@@ -67,6 +65,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <libufs.h>
#include <sys/queue.h>
@@ -76,10 +75,6 @@
#define INOBUFSIZE 64*1024 /* size of buffer to read inodes in pass1 */
#define ZEROBUFSIZE (dev_bsize * 128) /* size of zero buffer used by -Z */
-union dinode {
- struct ufs1_dinode dp1;
- struct ufs2_dinode dp2;
-};
#define DIP(dp, field) \
((sblock.fs_magic == FS_UFS1_MAGIC) ? \
(dp)->dp1.field : (dp)->dp2.field)
@@ -158,7 +153,7 @@ struct bufarea {
int b_flags; /* B_ flags below */
int b_type; /* BT_ type below */
int b_refcnt; /* ref count of users */
- int b_index; /* for BT_LEVEL, ptr index */
+ uint64_t b_index; /* for BT_LEVEL, ptr index */
/* for BT_INODES, first inum */
union {
char *b_buf; /* buffer space */
@@ -376,7 +371,6 @@ extern long secsize; /* actual disk sector size */
extern char skipclean; /* skip clean file systems if preening */
extern int snapcnt; /* number of active snapshots */
extern struct inode snaplist[FSMAXSNAP + 1]; /* list of active snapshots */
-extern char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
extern int sujrecovery; /* 1 => doing check using the journal */
extern int surrender; /* Give up if reads fail */
extern char usedsoftdep; /* just fix soft dependency inconsistencies */
@@ -425,6 +419,20 @@ Malloc(size_t size)
break;
return (retval);
}
+/*
+ * Allocate a block of memory to be used as an I/O buffer.
+ * Ensure that the buffer is aligned to the I/O subsystem requirements.
+ */
+static inline void*
+Balloc(size_t size)
+{
+ void *retval;
+
+ while ((retval = aligned_alloc(LIBUFS_BUFALIGN, size)) == NULL)
+ if (flushentry() == 0)
+ break;
+ return (retval);
+}
/*
* Wrapper for calloc() that flushes the cylinder group cache to try
diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8
index f100686e70e8..8df5e684b963 100644
--- a/sbin/fsck_ffs/fsck_ffs.8
+++ b/sbin/fsck_ffs/fsck_ffs.8
@@ -26,9 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
-.\"
-.Dd May 3, 2019
+.Dd November 17, 2023
.Dt FSCK_FFS 8
.Os
.Sh NAME
@@ -423,6 +421,7 @@ are fully enumerated and explained in Appendix A of
.%T "Fsck \- The UNIX File System Check Program"
.Re
.Sh SEE ALSO
+.Xr ffs 4 ,
.Xr fs 5 ,
.Xr fstab 5 ,
.Xr fsck 8 ,
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 5cf17e22fe80..2acf825b159f 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -58,7 +52,6 @@ static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
-#include <libufs.h>
#include "fsck.h"
@@ -189,7 +182,7 @@ bufinit(void)
initbarea(&failedbuf, BT_UNKNOWN);
failedbuf.b_errs = -1;
failedbuf.b_un.b_buf = NULL;
- if ((cgblk.b_un.b_buf = Malloc((unsigned int)sblock.fs_bsize)) == NULL)
+ if ((cgblk.b_un.b_buf = Balloc((unsigned int)sblock.fs_bsize)) == NULL)
errx(EEXIT, "Initial malloc(%d) failed", sblock.fs_bsize);
initbarea(&cgblk, BT_CYLGRP);
numbufs = cachelookups = cachereads = 0;
@@ -211,7 +204,7 @@ allocbuf(const char *failreason)
char *bufp;
bp = (struct bufarea *)Malloc(sizeof(struct bufarea));
- bufp = Malloc((unsigned int)sblock.fs_bsize);
+ bufp = Balloc((unsigned int)sblock.fs_bsize);
if (bp == NULL || bufp == NULL) {
errx(EEXIT, "%s", failreason);
/* NOTREACHED */
@@ -241,7 +234,7 @@ cglookup(int cg)
if ((unsigned) cg >= sblock.fs_ncg)
errx(EEXIT, "cglookup: out of range cylinder group %d", cg);
if (cgbufs == NULL) {
- cgbufs = calloc(sblock.fs_ncg, sizeof(struct bufarea));
+ cgbufs = Calloc(sblock.fs_ncg, sizeof(struct bufarea));
if (cgbufs == NULL)
errx(EEXIT, "Cannot allocate cylinder group buffers");
}
@@ -250,7 +243,7 @@ cglookup(int cg)
return (cgbp);
cgp = NULL;
if (flushtries == 0)
- cgp = Malloc((unsigned int)sblock.fs_cgsize);
+ cgp = Balloc((unsigned int)sblock.fs_cgsize);
if (cgp == NULL) {
if (sujrecovery)
errx(EEXIT,"Ran out of memory during journal recovery");
@@ -616,7 +609,6 @@ ckfini(int markclean)
int ofsmodified, cnt, cg;
if (bkgrdflag) {
- unlink(snapname);
if ((!(sblock.fs_flags & FS_UNCLEAN)) != markclean) {
cmd.value = FS_UNCLEAN;
cmd.size = markclean ? -1 : 1;
@@ -967,7 +959,7 @@ blzero(int fd, ufs2_daddr_t blk, long size)
if (fd < 0)
return;
if (zero == NULL) {
- zero = calloc(ZEROBUFSIZE, 1);
+ zero = Balloc(ZEROBUFSIZE);
if (zero == NULL)
errx(EEXIT, "cannot allocate buffer pool");
}
@@ -1025,7 +1017,6 @@ check_cgmagic(int cg, struct bufarea *cgbp)
CHK(cgp->cg_ndblk, >, sblock.fs_fpg, "%jd");
if (sblock.fs_magic == FS_UFS1_MAGIC) {
CHK(cgp->cg_old_niblk, !=, sblock.fs_ipg, "%jd");
- CHK(cgp->cg_old_ncyl, >, sblock.fs_old_cpg, "%jd");
} else if (sblock.fs_magic == FS_UFS2_MAGIC) {
CHK(cgp->cg_niblk, !=, sblock.fs_ipg, "%jd");
CHK(cgp->cg_initediblk, >, sblock.fs_ipg, "%jd");
@@ -1042,7 +1033,6 @@ check_cgmagic(int cg, struct bufarea *cgbp)
} else if (sblock.fs_magic == FS_UFS1_MAGIC) {
CHK(cgp->cg_niblk, !=, 0, "%jd");
CHK(cgp->cg_initediblk, !=, 0, "%jd");
- CHK(cgp->cg_old_ncyl, !=, sblock.fs_old_cpg, "%jd");
CHK(cgp->cg_old_niblk, !=, sblock.fs_ipg, "%jd");
CHK(cgp->cg_old_btotoff, !=, start, "%jd");
CHK(cgp->cg_old_boff, !=, cgp->cg_old_btotoff +
diff --git a/sbin/fsck_ffs/globs.c b/sbin/fsck_ffs/globs.c
index 038fc3475742..1f04311e2e5c 100644
--- a/sbin/fsck_ffs/globs.c
+++ b/sbin/fsck_ffs/globs.c
@@ -29,18 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -71,7 +59,6 @@ int freefiles[MIBSIZE]; /* MIB cmd to free a set of files */
int freedirs[MIBSIZE]; /* MIB cmd to free a set of directories */
int freeblks[MIBSIZE]; /* MIB cmd to free a set of data blocks */
struct fsck_cmd cmd; /* sysctl file system update commands */
-char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
@@ -144,7 +131,6 @@ fsckinit(void)
bzero(freedirs, sizeof(int) * MIBSIZE);
bzero(freeblks, sizeof(int) * MIBSIZE);
bzero(&cmd, sizeof(struct fsck_cmd));
- bzero(snapname, sizeof(char) * BUFSIZ);
cdevname = NULL;
dev_bsize = 0;
secsize = 0;
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 3db8a5e5c23d..b30e3aa5068b 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/stdint.h>
@@ -48,11 +42,11 @@ static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
#include <pwd.h>
#include <string.h>
#include <time.h>
-#include <libufs.h>
#include "fsck.h"
struct bufarea *icachebp; /* inode cache buffer */
+static time_t now; /* current time of day */
static int iblock(struct inodesc *, off_t isize, int type);
static ufs2_daddr_t indir_blkatoff(ufs2_daddr_t, ino_t, ufs_lbn_t, ufs_lbn_t,
@@ -436,6 +430,7 @@ void
ginode(ino_t inumber, struct inode *ip)
{
ufs2_daddr_t iblk;
+ union dinodep dpp;
struct ufs2_dinode *dp;
if (inumber < UFS_ROOTINO || inumber >= maxino)
@@ -473,11 +468,14 @@ ginode(ino_t inumber, struct inode *ip)
if (sblock.fs_magic == FS_UFS1_MAGIC) {
ip->i_dp = (union dinode *)
&ip->i_bp->b_un.b_dinode1[inumber - ip->i_bp->b_index];
+ dpp.dp1 = (struct ufs1_dinode *)ip->i_dp;
+ if (ffs_oldfscompat_inode_read(&sblock, dpp, now))
+ inodirty(ip);
return;
}
ip->i_dp = (union dinode *)
&ip->i_bp->b_un.b_dinode2[inumber - ip->i_bp->b_index];
- dp = (struct ufs2_dinode *)ip->i_dp;
+ dpp.dp2 = dp = (struct ufs2_dinode *)ip->i_dp;
/* Do not check hash of inodes being created */
if (dp->di_mode != 0 && ffs_verify_dinode_ckhash(&sblock, dp)) {
pwarn("INODE CHECK-HASH FAILED");
@@ -489,6 +487,8 @@ ginode(ino_t inumber, struct inode *ip)
inodirty(ip);
}
}
+ if (ffs_oldfscompat_inode_read(&sblock, dpp, now))
+ inodirty(ip);
}
/*
@@ -527,6 +527,7 @@ getnextinode(ino_t inumber, int rebuiltcg)
mode_t mode;
ufs2_daddr_t ndb, blk;
union dinode *dp;
+ union dinodep dpp;
struct inode ip;
static caddr_t nextinop;
@@ -557,10 +558,13 @@ getnextinode(ino_t inumber, int rebuiltcg)
nextinop = inobuf.b_un.b_buf;
}
dp = (union dinode *)nextinop;
- if (sblock.fs_magic == FS_UFS1_MAGIC)
+ if (sblock.fs_magic == FS_UFS1_MAGIC) {
nextinop += sizeof(struct ufs1_dinode);
- else
+ dpp.dp1 = (struct ufs1_dinode *)dp;
+ } else {
nextinop += sizeof(struct ufs2_dinode);
+ dpp.dp2 = (struct ufs2_dinode *)dp;
+ }
if ((ckhashadd & CK_INODE) != 0) {
ffs_update_dinode_ckhash(&sblock, (struct ufs2_dinode *)dp);
dirty(&inobuf);
@@ -579,6 +583,8 @@ getnextinode(ino_t inumber, int rebuiltcg)
dirty(&inobuf);
}
}
+ if (ffs_oldfscompat_inode_read(&sblock, dpp, now))
+ dirty(&inobuf);
if (rebuiltcg && (char *)dp == inobuf.b_un.b_buf) {
/*
* Try to determine if we have reached the end of the
@@ -632,8 +638,19 @@ getnextinode(ino_t inumber, int rebuiltcg)
void
setinodebuf(int cg, ino_t inosused)
{
+ struct timespec time;
ino_t inum;
+ /*
+ * Get the current value of the present time.
+ * This will happen before each cylinder group is scanned.
+ * If for some reason getting the time fails, we will use
+ * the last time that the superblock was updated.
+ */
+ if (clock_gettime(CLOCK_REALTIME_FAST, &time) == 0)
+ now = time.tv_sec;
+ else
+ now = sblock.fs_time;
inum = cg * sblock.fs_ipg;
lastvalidinum = inum + inosused - 1;
nextinum = inum;
@@ -646,7 +663,7 @@ setinodebuf(int cg, ino_t inosused)
inobufsize = blkroundup(&sblock,
MAX(INOBUFSIZE, sblock.fs_bsize));
initbarea(&inobuf, BT_INODES);
- if ((inobuf.b_un.b_buf = Malloc((unsigned)inobufsize)) == NULL)
+ if ((inobuf.b_un.b_buf = Balloc((unsigned)inobufsize)) == NULL)
errx(EEXIT, "cannot allocate space for inode buffer");
}
fullcnt = inobufsize / ((sblock.fs_magic == FS_UFS1_MAGIC) ?
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 58e184f3581f..aabab489573e 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -29,18 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#define _WANT_P_OSREL
#include <sys/param.h>
#include <sys/file.h>
@@ -59,7 +47,6 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#include <fstab.h>
#include <grp.h>
#include <inttypes.h>
-#include <libufs.h>
#include <mntopts.h>
#include <paths.h>
#include <stdint.h>
@@ -68,7 +55,8 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#include "fsck.h"
-static int restarts;
+static int restarts;
+static char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
static void usage(void) __dead2;
static intmax_t argtoimax(int flag, const char *req, const char *str, int base);
@@ -664,8 +652,7 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
"SUPPORT\n");
}
/* Find or create the snapshot directory */
- snprintf(snapname, sizeof snapname, "%s/.snap",
- mntp->f_mntonname);
+ snprintf(snapname, sizeof snapname, "%s/.snap", mntp->f_mntonname);
if (stat(snapname, &snapdir) < 0) {
if (errno != ENOENT) {
pwarn("CANNOT FIND SNAPSHOT DIRECTORY %s: %s, CANNOT "
@@ -713,6 +700,8 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
"BACKGROUND\n", snapname, strerror(errno));
return (0);
}
+ /* Immediately unlink snapshot so that it will be deleted when closed */
+ unlink(snapname);
free(sblock.fs_csp);
free(sblock.fs_si);
if (readsb() == 0) {
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index bed9d547f637..f4f97a38097b 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index c1af6158f92c..3fb9cab89078 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 977ee1b1c61e..1755a1295a9e 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
index 9a01bb02ccc8..853f5d62382f 100644
--- a/sbin/fsck_ffs/pass3.c
+++ b/sbin/fsck_ffs/pass3.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index b4cf59bc97dc..a261051c432a 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass4.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 58de6791903f..528a6956c4a1 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -45,7 +39,6 @@ static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
#include <inttypes.h>
#include <limits.h>
#include <string.h>
-#include <libufs.h>
#include "fsck.h"
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 49e89f9221b0..f10f02d159c3 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/stat.h>
@@ -52,7 +46,6 @@ static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#include <limits.h>
#include <stdint.h>
#include <string.h>
-#include <libufs.h>
#include "fsck.h"
@@ -214,7 +207,7 @@ setup(char *dev)
sbdirty();
}
if (snapcnt > 0 && copybuf == NULL) {
- copybuf = Malloc(sblock.fs_bsize);
+ copybuf = Balloc(sblock.fs_bsize);
if (copybuf == NULL)
errx(EEXIT, "cannot allocate space for snapshot "
"copy buffer");
@@ -299,6 +292,8 @@ checksnapinfo(struct inode *snapip)
size = fragroundup(fs,
DIP(snapip->i_dp, di_size) - lblktosize(fs, lbn));
bp = getdatablk(idesc.id_parent, size, BT_DATA);
+ if (bp->b_errs != 0)
+ return (0);
snapblklist = (daddr_t *)bp->b_un.b_buf;
/*
* snapblklist[0] is the size of the list
@@ -378,14 +373,14 @@ openfilesys(char *dev)
if ((statb.st_mode & S_IFMT) != S_IFCHR &&
(statb.st_mode & S_IFMT) != S_IFBLK) {
if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) {
- pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n");
- exit(EEXIT);
+ pwarn("BACKGROUND FSCK LACKS A SNAPSHOT\n");
+ return (0);
}
if (bkgrdflag != 0) {
cursnapshot = statb.st_ino;
} else {
- pfatal("%s IS NOT A DISK DEVICE\n", dev);
- if (reply("CONTINUE") == 0)
+ pwarn("%s IS NOT A DISK DEVICE\n", dev);
+ if (preen || reply("CONTINUE") == 0)
return (0);
}
}
@@ -499,7 +494,7 @@ sblock_init(void)
fsmodified = 0;
lfdir = 0;
initbarea(&sblk, BT_SUPERBLK);
- sblk.b_un.b_buf = Malloc(SBLOCKSIZE);
+ sblk.b_un.b_buf = Balloc(SBLOCKSIZE);
if (sblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
dev_bsize = secsize = DEV_BSIZE;
@@ -528,7 +523,7 @@ calcsb(char *dev, int devfd, struct fs *fs)
*/
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1)
return (0);
- fsrbuf = Malloc(secsize);
+ fsrbuf = Balloc(secsize);
if (fsrbuf == NULL)
errx(EEXIT, "calcsb: cannot allocate recovery buffer");
if (blread(devfd, fsrbuf,
@@ -571,7 +566,7 @@ chkrecovery(int devfd)
rdsize = sblock.fs_fsize;
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1 ||
rdsize % secsize != 0 ||
- (fsrbuf = Malloc(rdsize)) == NULL ||
+ (fsrbuf = Balloc(rdsize)) == NULL ||
blread(devfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
rdsize) != 0) {
free(fsrbuf);
@@ -610,7 +605,7 @@ saverecovery(int readfd, int writefd)
if (sblock.fs_magic != FS_UFS2_MAGIC ||
ioctl(readfd, DIOCGSECTORSIZE, &secsize) == -1 ||
rdsize % secsize != 0 ||
- (fsrbuf = Malloc(rdsize)) == NULL ||
+ (fsrbuf = Balloc(rdsize)) == NULL ||
blread(readfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
rdsize) != 0) {
printf("RECOVERY DATA COULD NOT BE CREATED\n");
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index c66b605bd69d..73be60c5e5b4 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/disklabel.h>
@@ -47,7 +46,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
-#include <libufs.h>
#include <string.h>
#include <strings.h>
#include <sysexits.h>
@@ -2274,7 +2272,7 @@ suj_add_block(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
static void
suj_read(void)
{
- uint8_t block[1 * 1024 * 1024];
+ uint8_t block[1 * 1024 * 1024] __aligned(LIBUFS_BUFALIGN);
struct suj_seg *seg;
struct jsegrec *recn;
struct jsegrec *rec;
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index 45bbcc9d6612..56655089b9d6 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>