summaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/dir.c4
-rw-r--r--sbin/fsck_ffs/extern.h8
-rw-r--r--sbin/fsck_ffs/fsck.h10
-rw-r--r--sbin/fsck_ffs/inode.c4
-rw-r--r--sbin/fsck_ffs/pass1.c20
-rw-r--r--sbin/fsck_ffs/pass2.c10
-rw-r--r--sbin/fsck_ffs/pass5.c12
-rw-r--r--sbin/fsck_ffs/setup.c14
-rw-r--r--sbin/fsck_ffs/utilities.c11
9 files changed, 47 insertions, 46 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 835242ff7bf..d0c4fe4f903 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.29 2013/06/11 16:42:04 deraadt Exp $ */
+/* $OpenBSD: dir.c,v 1.30 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */
/*
@@ -552,7 +552,7 @@ bad:
/*
* allocate a new directory
*/
-int
+ino_t
allocdir(ino_t parent, ino_t request, int mode)
{
ino_t ino;
diff --git a/sbin/fsck_ffs/extern.h b/sbin/fsck_ffs/extern.h
index f03a7aeb77f..ba92e804097 100644
--- a/sbin/fsck_ffs/extern.h
+++ b/sbin/fsck_ffs/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.12 2013/06/11 16:42:04 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.13 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: extern.h,v 1.6 1996/09/27 22:45:12 christos Exp $ */
/*
@@ -26,8 +26,8 @@
*/
void adjust(struct inodesc *, short);
-int allocblk(long);
-int allocdir(ino_t, ino_t, int);
+daddr_t allocblk(int);
+ino_t allocdir(ino_t, ino_t, int);
void blkerror(ino_t, char *, daddr_t);
int bread(int, char *, daddr_t, long);
void bufinit(void);
@@ -47,7 +47,7 @@ void fileerror(ino_t, ino_t, char *);
int findino(struct inodesc *);
int findname(struct inodesc *);
void flush(int, struct bufarea *);
-void freeblk(daddr_t, long);
+void freeblk(daddr_t, int);
void freeino(ino_t);
void freeinodebuf(void);
int ftypeok(union dinode *);
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index a2f82b8e0fb..7491474b39b 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsck.h,v 1.29 2014/05/09 13:19:34 krw Exp $ */
+/* $OpenBSD: fsck.h,v 1.30 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */
/*
@@ -161,16 +161,16 @@ enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE};
struct inodesc {
daddr_t id_blkno; /* current block number being examined */
quad_t id_filesize; /* for DATA nodes, the size of the directory */
+ u_int64_t id_entryno; /* for DATA nodes, current entry number */
+ ino_t id_number; /* inode number described */
+ ino_t id_parent; /* for DATA nodes, their parent */
int (*id_func) /* function to be applied to blocks of inode */
(struct inodesc *);
struct direct *id_dirp; /* for DATA nodes, ptr to current entry */
char *id_name; /* for DATA nodes, name to find or enter */
- ino_t id_number; /* inode number described */
- ino_t id_parent; /* for DATA nodes, their parent */
- enum fixstate id_fix; /* policy on fixing errors */
int id_numfrags; /* number of frags contained in block */
int id_loc; /* for DATA nodes, current location in dir */
- int id_entryno; /* for DATA nodes, current entry number */
+ enum fixstate id_fix; /* policy on fixing errors */
char id_type; /* type of descriptor, DATA or ADDR */
};
/* file types */
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 2d5b6943de6..83cbb9f36f1 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.c,v 1.42 2014/05/21 18:53:05 krw Exp $ */
+/* $OpenBSD: inode.c,v 1.43 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */
/*
@@ -602,7 +602,7 @@ allocino(ino_t request, int type)
MAX(2 * inostathead[cg].il_numalloced, 10));
info = calloc(newalloced, sizeof(struct inostat));
if (info == NULL) {
- pwarn("cannot alloc %lu bytes to extend inoinfo\n",
+ pwarn("cannot alloc %zu bytes to extend inoinfo\n",
sizeof(struct inostat) * newalloced);
return 0;
}
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 5fff60cc922..e3767ca5170 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.c,v 1.38 2013/06/11 16:42:04 deraadt Exp $ */
+/* $OpenBSD: pass1.c,v 1.39 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -139,8 +139,7 @@ pass1(void)
info = calloc((unsigned)inosused, sizeof(struct inostat));
inospace = (unsigned)inosused * sizeof(struct inostat);
if (info == NULL)
- errexit("cannot alloc %u bytes for inoinfo",
- (unsigned)(sizeof(struct inostat) * inosused));
+ errexit("cannot alloc %zu bytes for inoinfo", inospace);
inostathead[c].il_stat = info;
/*
* Scan the allocated inodes.
@@ -175,6 +174,7 @@ pass1(void)
if (ninosused != inosused) {
struct inostat *ninfo;
size_t ninospace = ninosused * sizeof(*ninfo);
+
if (ninospace / sizeof(*info) != ninosused) {
pfatal("too many inodes %llu\n",
(unsigned long long)ninosused);
@@ -282,8 +282,8 @@ checkinode(ino_t inumber, struct inodesc *idesc)
for (j = ndb; j < NDADDR; j++)
if (DIP(dp, di_db[j]) != 0) {
if (debug)
- printf("bad direct addr: %ld\n",
- (long)DIP(dp, di_db[j]));
+ printf("bad direct addr: %lld\n",
+ (long long)DIP(dp, di_db[j]));
goto unknown;
}
for (j = 0, ndb -= NDADDR; ndb > 0; j++)
@@ -291,8 +291,8 @@ checkinode(ino_t inumber, struct inodesc *idesc)
for (; j < NIADDR; j++)
if (DIP(dp, di_ib[j]) != 0) {
if (debug)
- printf("bad indirect addr: %ld\n",
- (long)DIP(dp, di_ib[j]));
+ printf("bad indirect addr: %lld\n",
+ (long long)DIP(dp, di_ib[j]));
goto unknown;
}
if (ftypeok(dp) == 0)
@@ -327,9 +327,9 @@ checkinode(ino_t inumber, struct inodesc *idesc)
(void)ckinode(dp, idesc);
idesc->id_entryno *= btodb(sblock.fs_fsize);
if (DIP(dp, di_blocks) != idesc->id_entryno) {
- pwarn("INCORRECT BLOCK COUNT I=%llu (%ld should be %d)",
- (unsigned long long)inumber, (long)DIP(dp, di_blocks),
- idesc->id_entryno);
+ pwarn("INCORRECT BLOCK COUNT I=%llu (%lld should be %lld)",
+ (unsigned long long)inumber, (long long)DIP(dp, di_blocks),
+ (long long)idesc->id_entryno);
if (preen)
printf(" (CORRECTED)\n");
else if (reply("CORRECT") == 0)
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 8cfe1078be8..dc86f6bc37f 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass2.c,v 1.34 2013/06/11 16:42:04 deraadt Exp $ */
+/* $OpenBSD: pass2.c,v 1.35 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -162,12 +162,12 @@ pass2(void)
getpathname(pathbuf, sizeof pathbuf,
inp->i_number, inp->i_number);
if (usedsoftdep)
- pfatal("%s %s: LENGTH %ld NOT MULTIPLE of %d",
- "DIRECTORY", pathbuf, (long)inp->i_isize,
+ pfatal("%s %s: LENGTH %zu NOT MULTIPLE of %d",
+ "DIRECTORY", pathbuf, inp->i_isize,
DIRBLKSIZ);
else
- pwarn("%s %s: LENGTH %ld NOT MULTIPLE OF %d",
- "DIRECTORY", pathbuf, (long)inp->i_isize,
+ pwarn("%s %s: LENGTH %zu NOT MULTIPLE OF %d",
+ "DIRECTORY", pathbuf, inp->i_isize,
DIRBLKSIZ);
if (preen)
printf(" (ADJUSTED)\n");
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 5f98be13441..052753651f2 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass5.c,v 1.45 2014/07/08 17:19:24 deraadt Exp $ */
+/* $OpenBSD: pass5.c,v 1.46 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */
/*
@@ -336,8 +336,8 @@ pass5(void)
continue;
if (cg_inosused(cg)[i] & (1 << k))
continue;
- pwarn("ALLOCATED INODE %ld MARKED FREE\n",
- c * fs->fs_ipg + i * 8 + k);
+ pwarn("ALLOCATED INODE %lld MARKED FREE\n",
+ ((long long)c * fs->fs_ipg + i * 8) + k);
}
}
for (i = 0; i < blkmapsize; i++) {
@@ -347,10 +347,10 @@ pass5(void)
for (k = 0; k < NBBY; k++) {
if ((j & (1 << k)) == 0)
continue;
- if (cg_inosused(cg)[i] & (1 << k))
+ if (cg_blksfree(newcg)[i] & (1 << k))
continue;
- pwarn("ALLOCATED FRAG %ld MARKED FREE\n",
- c * fs->fs_fpg + i * 8 + k);
+ pwarn("ALLOCATED FRAG %lld MARKED FREE\n",
+ ((long long)c * fs->fs_fpg + i * 8) + k);
}
}
}
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 6c5304ee532..68290caaa5c 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setup.c,v 1.54 2014/05/29 12:02:50 krw Exp $ */
+/* $OpenBSD: setup.c,v 1.55 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */
/*
@@ -75,7 +75,8 @@ static const int altsbtry[] = { 32, 64, 128, 144, 160, 192, 256 };
int
setup(char *dev)
{
- long cg, size, asked, i, j, bmapsize;
+ long cg, size, asked, i, j;
+ size_t bmapsize;
struct disklabel *lp;
off_t sizepb;
struct stat statb;
@@ -382,17 +383,16 @@ found:
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
- blockmap = calloc((unsigned)bmapsize, sizeof(char));
+ blockmap = calloc(bmapsize, sizeof(char));
if (blockmap == NULL) {
- printf("cannot alloc %u bytes for blockmap\n",
- (unsigned)bmapsize);
+ printf("cannot alloc %zu bytes for blockmap\n", bmapsize);
goto badsblabel;
}
inostathead = calloc((unsigned)(sblock.fs_ncg),
sizeof(struct inostatlist));
if (inostathead == NULL) {
- printf("cannot alloc %u bytes for inostathead\n",
- (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
+ printf("cannot alloc %zu bytes for inostathead\n",
+ (unsigned)sblock.fs_ncg * sizeof(struct inostatlist));
goto badsblabel;
}
numdirs = MAX(sblock.fs_cstotal.cs_ndir, 128);
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index a1d292684d8..1a83fdc9893 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.46 2014/05/24 14:54:49 krw Exp $ */
+/* $OpenBSD: utilities.c,v 1.47 2014/09/06 04:05:40 guenther Exp $ */
/* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */
/*
@@ -395,10 +395,11 @@ bwrite(int fd, char *buf, daddr_t blk, long size)
/*
* allocate a data block with the specified number of fragments
*/
-int
-allocblk(long frags)
+daddr_t
+allocblk(int frags)
{
- int i, j, k, cg, baseblk;
+ daddr_t i, baseblk;
+ int j, k, cg;
struct cg *cgp = &cgrp;
if (frags <= 0 || frags > sblock.fs_frag)
@@ -439,7 +440,7 @@ allocblk(long frags)
* Free a previously allocated block
*/
void
-freeblk(daddr_t blkno, long frags)
+freeblk(daddr_t blkno, int frags)
{
struct inodesc idesc;