mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 01:55:19 +01:00
o bdeficize expand_number_int() function;
o revert most of the recent changes (int -> int64_t conversion) by using this functon for parsing all options.
This commit is contained in:
parent
ef47c93f6c
commit
e0999e592b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=204919
@ -191,8 +191,8 @@ restart:
|
||||
exit(17);
|
||||
}
|
||||
if (sblock.fs_fsize < sectorsize) {
|
||||
printf("increasing fragment size from %d to sector size (%jd)\n",
|
||||
sblock.fs_fsize, (intmax_t)sectorsize);
|
||||
printf("increasing fragment size from %d to sector size (%d)\n",
|
||||
sblock.fs_fsize, sectorsize);
|
||||
sblock.fs_fsize = sectorsize;
|
||||
}
|
||||
if (sblock.fs_bsize > MAXBSIZE) {
|
||||
@ -337,8 +337,8 @@ restart:
|
||||
} else if (density < minfragsperinode * fsize) {
|
||||
origdensity = density;
|
||||
density = minfragsperinode * fsize;
|
||||
fprintf(stderr, "density increased from %d to %jd\n",
|
||||
origdensity, (intmax_t)density);
|
||||
fprintf(stderr, "density increased from %d to %d\n",
|
||||
origdensity, density);
|
||||
}
|
||||
origdensity = density;
|
||||
for (;;) {
|
||||
@ -346,9 +346,8 @@ restart:
|
||||
if (fragsperinode < minfragsperinode) {
|
||||
bsize <<= 1;
|
||||
fsize <<= 1;
|
||||
printf("Block size too small for a file system %s %jd\n",
|
||||
"of this size. Increasing blocksize to",
|
||||
(intmax_t)bsize);
|
||||
printf("Block size too small for a file system %s %d\n",
|
||||
"of this size. Increasing blocksize to", bsize);
|
||||
goto restart;
|
||||
}
|
||||
minfpg = fragsperinode * INOPB(&sblock);
|
||||
@ -372,8 +371,7 @@ restart:
|
||||
density -= sblock.fs_fsize;
|
||||
}
|
||||
if (density != origdensity)
|
||||
printf("density reduced from %d to %jd\n", origdensity,
|
||||
(intmax_t)density);
|
||||
printf("density reduced from %d to %d\n", origdensity, density);
|
||||
/*
|
||||
* Start packing more blocks into the cylinder group until
|
||||
* it cannot grow any larger, the number of cylinder groups
|
||||
|
@ -94,17 +94,17 @@ int nflag; /* do not create .snap directory */
|
||||
intmax_t fssize; /* file system size */
|
||||
int sectorsize; /* bytes/sector */
|
||||
int realsectorsize; /* bytes/sector in hardware */
|
||||
int64_t fsize = 0; /* fragment size */
|
||||
int64_t bsize = 0; /* block size */
|
||||
int64_t maxbsize = 0; /* maximum clustering */
|
||||
int64_t maxblkspercg = MAXBLKSPERCG; /* maximum blocks per cylinder group */
|
||||
int fsize = 0; /* fragment size */
|
||||
int bsize = 0; /* block size */
|
||||
int maxbsize = 0; /* maximum clustering */
|
||||
int maxblkspercg = MAXBLKSPERCG; /* maximum blocks per cylinder group */
|
||||
int minfree = MINFREE; /* free space threshold */
|
||||
int opt = DEFAULTOPT; /* optimization preference (space or time) */
|
||||
int64_t density; /* number of bytes per inode */
|
||||
int64_t maxcontig = 0; /* max contiguous blocks to allocate */
|
||||
int64_t maxbpg; /* maximum blocks per file in a cyl group */
|
||||
int64_t avgfilesize = AVFILESIZ;/* expected average file size */
|
||||
int64_t avgfilesperdir = AFPDIR;/* expected number of files per directory */
|
||||
int density; /* number of bytes per inode */
|
||||
int maxcontig = 0; /* max contiguous blocks to allocate */
|
||||
int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
int avgfilesize = AVFILESIZ;/* expected average file size */
|
||||
int avgfilesperdir = AFPDIR;/* expected number of files per directory */
|
||||
u_char *volumelabel = NULL; /* volume label for filesystem */
|
||||
struct uufsd disk; /* libufs disk structure */
|
||||
|
||||
@ -186,13 +186,13 @@ main(int argc, char *argv[])
|
||||
Xflag++;
|
||||
break;
|
||||
case 'a':
|
||||
rval = expand_number(optarg, &maxcontig);
|
||||
rval = expand_number_int(optarg, &maxcontig);
|
||||
if (rval < 0 || maxcontig <= 0)
|
||||
errx(1, "%s: bad maximum contiguous blocks",
|
||||
optarg);
|
||||
break;
|
||||
case 'b':
|
||||
rval = expand_number(optarg, &bsize);
|
||||
rval = expand_number_int(optarg, &bsize);
|
||||
if (rval < 0)
|
||||
errx(1, "%s: bad block size",
|
||||
optarg);
|
||||
@ -204,39 +204,39 @@ main(int argc, char *argv[])
|
||||
optarg, MAXBSIZE);
|
||||
break;
|
||||
case 'c':
|
||||
rval = expand_number(optarg, &maxblkspercg);
|
||||
rval = expand_number_int(optarg, &maxblkspercg);
|
||||
if (rval < 0 || maxblkspercg <= 0)
|
||||
errx(1, "%s: bad blocks per cylinder group",
|
||||
optarg);
|
||||
break;
|
||||
case 'd':
|
||||
rval = expand_number(optarg, &maxbsize);
|
||||
rval = expand_number_int(optarg, &maxbsize);
|
||||
if (rval < 0 || maxbsize < MINBSIZE)
|
||||
errx(1, "%s: bad extent block size", optarg);
|
||||
break;
|
||||
case 'e':
|
||||
rval = expand_number(optarg, &maxbpg);
|
||||
rval = expand_number_int(optarg, &maxbpg);
|
||||
if (rval < 0 || maxbpg <= 0)
|
||||
errx(1, "%s: bad blocks per file in a cylinder group",
|
||||
optarg);
|
||||
break;
|
||||
case 'f':
|
||||
rval = expand_number(optarg, &fsize);
|
||||
rval = expand_number_int(optarg, &fsize);
|
||||
if (rval < 0 || fsize <= 0)
|
||||
errx(1, "%s: bad fragment size", optarg);
|
||||
break;
|
||||
case 'g':
|
||||
rval = expand_number(optarg, &avgfilesize);
|
||||
rval = expand_number_int(optarg, &avgfilesize);
|
||||
if (rval < 0 || avgfilesize <= 0)
|
||||
errx(1, "%s: bad average file size", optarg);
|
||||
break;
|
||||
case 'h':
|
||||
rval = expand_number(optarg, &avgfilesperdir);
|
||||
rval = expand_number_int(optarg, &avgfilesperdir);
|
||||
if (rval < 0 || avgfilesperdir <= 0)
|
||||
errx(1, "%s: bad average files per dir", optarg);
|
||||
break;
|
||||
case 'i':
|
||||
rval = expand_number(optarg, &density);
|
||||
rval = expand_number_int(optarg, &density);
|
||||
if (rval < 0 || density <= 0)
|
||||
errx(1, "%s: bad bytes per inode", optarg);
|
||||
break;
|
||||
@ -505,9 +505,9 @@ expand_number_int(const char *buf, int *num)
|
||||
int rval;
|
||||
|
||||
rval = expand_number(buf, &num64);
|
||||
if (rval != 0)
|
||||
if (rval < 0)
|
||||
return (rval);
|
||||
if (num64 > INT_MAX) {
|
||||
if (num64 > INT_MAX || num64 < INT_MIN) {
|
||||
errno = ERANGE;
|
||||
return (-1);
|
||||
}
|
||||
|
@ -88,17 +88,17 @@ extern int nflag; /* do not create .snap directory */
|
||||
extern intmax_t fssize; /* file system size */
|
||||
extern int sectorsize; /* bytes/sector */
|
||||
extern int realsectorsize; /* bytes/sector in hardware*/
|
||||
extern int64_t fsize; /* fragment size */
|
||||
extern int64_t bsize; /* block size */
|
||||
extern int64_t maxbsize; /* maximum clustering */
|
||||
extern int64_t maxblkspercg; /* maximum blocks per cylinder group */
|
||||
extern int fsize; /* fragment size */
|
||||
extern int bsize; /* block size */
|
||||
extern int maxbsize; /* maximum clustering */
|
||||
extern int maxblkspercg; /* maximum blocks per cylinder group */
|
||||
extern int minfree; /* free space threshold */
|
||||
extern int opt; /* optimization preference (space or time) */
|
||||
extern int64_t density; /* number of bytes per inode */
|
||||
extern int64_t maxcontig; /* max contiguous blocks to allocate */
|
||||
extern int64_t maxbpg; /* maximum blocks per file in a cyl group */
|
||||
extern int64_t avgfilesize; /* expected average file size */
|
||||
extern int64_t avgfilesperdir; /* expected number of files per directory */
|
||||
extern int density; /* number of bytes per inode */
|
||||
extern int maxcontig; /* max contiguous blocks to allocate */
|
||||
extern int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
extern int avgfilesize; /* expected average file size */
|
||||
extern int avgfilesperdir; /* expected number of files per directory */
|
||||
extern u_char *volumelabel; /* volume label for filesystem */
|
||||
extern struct uufsd disk; /* libufs disk structure */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user