svn commit: r304438 - head/sbin/fsck_ffs
Kirk McKusick
mckusick at FreeBSD.org
Fri Aug 19 00:03:43 UTC 2016
Author: mckusick
Date: Fri Aug 19 00:03:41 2016
New Revision: 304438
URL: https://svnweb.freebsd.org/changeset/base/304438
Log:
Fsck_ufs was using an int rather than a ufs2_daddr_t to store the
alternate superblock location when given in the -b option. When int
is 32-bits, block numbers larger than 2^32 would get truncated. This
commit changes the storage fpr the alternate superblock location
to a ufs2_daddr_t.
Submitted by: Dmitry Sivachenko <trtrmitya at gmail.com>
Modified:
head/sbin/fsck_ffs/fsck.h
head/sbin/fsck_ffs/globs.c
head/sbin/fsck_ffs/main.c
head/sbin/fsck_ffs/setup.c
Modified: head/sbin/fsck_ffs/fsck.h
==============================================================================
--- head/sbin/fsck_ffs/fsck.h Thu Aug 18 22:59:10 2016 (r304437)
+++ head/sbin/fsck_ffs/fsck.h Fri Aug 19 00:03:41 2016 (r304438)
@@ -305,7 +305,7 @@ extern u_int real_dev_bsize; /* actual
extern char nflag; /* assume a no response */
extern char yflag; /* assume a yes response */
extern int bkgrdflag; /* use a snapshot to run on an active system */
-extern int bflag; /* location of alternate super block */
+extern ufs2_daddr_t bflag; /* location of alternate super block */
extern int debug; /* output debugging info */
extern int Eflag; /* delete empty data blocks */
extern int Zflag; /* zero empty data blocks */
Modified: head/sbin/fsck_ffs/globs.c
==============================================================================
--- head/sbin/fsck_ffs/globs.c Thu Aug 18 22:59:10 2016 (r304437)
+++ head/sbin/fsck_ffs/globs.c Fri Aug 19 00:03:41 2016 (r304438)
@@ -77,7 +77,7 @@ u_int real_dev_bsize; /* actual disk se
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bkgrdflag; /* use a snapshot to run on an active system */
-int bflag; /* location of alternate super block */
+ufs2_daddr_t bflag; /* location of alternate super block */
int debug; /* output debugging info */
int Eflag; /* delete empty data blocks */
int Zflag; /* zero empty data blocks */
Modified: head/sbin/fsck_ffs/main.c
==============================================================================
--- head/sbin/fsck_ffs/main.c Thu Aug 18 22:59:10 2016 (r304437)
+++ head/sbin/fsck_ffs/main.c Fri Aug 19 00:03:41 2016 (r304438)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fstab.h>
#include <grp.h>
+#include <inttypes.h>
#include <mntopts.h>
#include <paths.h>
#include <stdint.h>
@@ -68,7 +69,7 @@ __FBSDID("$FreeBSD$");
int restarts;
static void usage(void) __dead2;
-static int argtoi(int flag, const char *req, const char *str, int base);
+static intmax_t argtoimax(int flag, const char *req, const char *str, int base);
static int checkfilesys(char *filesys);
static int chkdoreload(struct statfs *mntp);
static struct statfs *getmntpt(const char *);
@@ -88,8 +89,8 @@ main(int argc, char *argv[])
switch (ch) {
case 'b':
skipclean = 0;
- bflag = argtoi('b', "number", optarg, 10);
- printf("Alternate super block location: %d\n", bflag);
+ bflag = argtoimax('b', "number", optarg, 10);
+ printf("Alternate super block location: %jd\n", bflag);
break;
case 'B':
@@ -98,7 +99,8 @@ main(int argc, char *argv[])
case 'c':
skipclean = 0;
- cvtlevel = argtoi('c', "conversion level", optarg, 10);
+ cvtlevel = argtoimax('c', "conversion level", optarg,
+ 10);
if (cvtlevel < 3)
errx(EEXIT, "cannot do level %d conversion",
cvtlevel);
@@ -121,7 +123,7 @@ main(int argc, char *argv[])
break;
case 'm':
- lfmode = argtoi('m', "mode", optarg, 8);
+ lfmode = argtoimax('m', "mode", optarg, 8);
if (lfmode &~ 07777)
errx(EEXIT, "bad mode to -m: %o", lfmode);
printf("** lost+found creation mode %o\n", lfmode);
@@ -203,13 +205,13 @@ main(int argc, char *argv[])
exit(ret);
}
-static int
-argtoi(int flag, const char *req, const char *str, int base)
+static intmax_t
+argtoimax(int flag, const char *req, const char *str, int base)
{
char *cp;
- int ret;
+ intmax_t ret;
- ret = (int)strtol(str, &cp, base);
+ ret = strtoimax(str, &cp, base);
if (cp == str || *cp)
errx(EEXIT, "-%c flag requires a %s", flag, req);
return (ret);
Modified: head/sbin/fsck_ffs/setup.c
==============================================================================
--- head/sbin/fsck_ffs/setup.c Thu Aug 18 22:59:10 2016 (r304437)
+++ head/sbin/fsck_ffs/setup.c Fri Aug 19 00:03:41 2016 (r304438)
@@ -196,7 +196,7 @@ setup(char *dev)
bflag = 0;
return(0);
}
- pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
+ pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag);
bflag = 0;
}
if (skipclean && ckclean && sblock.fs_clean) {
@@ -329,7 +329,7 @@ readsb(int listerr)
}
if (sblock.fs_magic != FS_UFS1_MAGIC &&
sblock.fs_magic != FS_UFS2_MAGIC) {
- fprintf(stderr, "%d is not a file system superblock\n",
+ fprintf(stderr, "%jd is not a file system superblock\n",
bflag);
return (0);
}
More information about the svn-src-head
mailing list