extern int Nflag; /* run mkfs without writing file system */
extern int Oflag; /* format as an 4.3BSD file system */
extern int Uflag; /* enable soft updates for file system */
-extern int fssize; /* file system size */
+extern u_long fssize; /* file system size */
extern int ntracks; /* # tracks/cylinder */
extern int nsectors; /* # sectors/track */
extern int nphyssectors; /* # sectors/track including spares */
l1 = fssize * sectorsize;
if (l1 > BUFSIZ)
l1 = BUFSIZ;
- for (l = 0; l < (u_long)fssize * (u_long)sectorsize; l += l1) {
+ for (l = 0; l < fssize * (u_long)sectorsize; l += l1) {
w = write(fd, buf, l1);
if (w < 0 || (u_long)w != l1)
err(12, "%s", filename);
#ifndef STANDALONE
get_memleft();
#endif
- if ((u_long)fssize * (u_long)sectorsize >
- (memleft - 131072))
+ if (fssize * (u_long)sectorsize > (memleft - 131072))
fssize = (memleft - 131072) / sectorsize;
if ((membase = malloc(fssize * sectorsize)) == NULL)
errx(13, "malloc failed");
* Validate the given file system size.
* Verify that its last block can actually be accessed.
*/
- if (fssize <= 0)
- printf("preposterous size %d\n", fssize), exit(13);
+ if (fssize == 0)
+ printf("preposterous size %lu\n", fssize), exit(13);
wtfs(fssize - (realsectorsize / DEV_BSIZE), realsectorsize,
(char *)&sblock);
/*
*/
sblock.fs_size = fssize = dbtofsb(&sblock, fssize);
sblock.fs_ncyl = fssize * NSPF(&sblock) / sblock.fs_spc;
- if (fssize * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) {
+ if ((long)fssize * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) {
sblock.fs_ncyl++;
emitwarn = 1;
}
emitwarn = 0;
}
if (emitwarn && !mfs) {
- printf("Warning: %d sector(s) in last cylinder unallocated\n",
+ printf("Warning: %lu sector(s) in last cylinder unallocated\n",
sblock.fs_spc -
(fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1)
* sblock.fs_spc));
int Oflag; /* format as an 4.3BSD file system */
int Cflag; /* copy underlying filesystem (mfs only) */
int Uflag; /* enable soft updates for file system */
-int fssize; /* file system size */
+u_long fssize; /* file system size */
int ntracks = NTRACKS; /* # tracks/cylinder */
int nsectors = NSECTORS; /* # sectors/track */
int nphyssectors; /* # sectors/track including spares */
fatal("%s: bad revolutions/minute", optarg);
break;
case 's':
- if ((fssize = atoi(optarg)) <= 0)
+ /*
+ * Unsigned long but limit to long. On 32 bit a
+ * tad under 2G, on 64 bit the upper bound is more
+ * swap space then operand size.
+ *
+ * NOTE: fssize is converted from 512 byte sectors
+ * to filesystem block-sized sectors by mkfs XXX.
+ */
+ fssize = strtoul(optarg, NULL, 10);
+ if (fssize == 0 || fssize > LONG_MAX)
fatal("%s: bad file system size", optarg);
break;
case 't':
havelabel:
if (fssize == 0)
fssize = geom.d_media_blocks;
- if ((uint32_t)fssize > geom.d_media_blocks && !mfs) {
+ if ((u_long)fssize > geom.d_media_blocks && !mfs) {
fatal("%s: maximum file system size is %lld blocks",
argv[0], geom.d_media_blocks);
}
/*
* NOTE: Newfs no longer accesses or attempts to update the
* filesystem disklabel.
+ *
+ * NOTE: fssize is converted from 512 byte sectors
+ * to filesystem block-sized sectors by mkfs XXX.
*/
if (!Nflag)
close(fso);
else
args.export.ex_flags = 0;
args.base = membase;
- args.size = fssize * sectorsize;
+ args.size = fssize * fsize;
error = getvfsbyname("mfs", &vfc);
if (error && vfsisloadable("mfs")) {
mfsintr(__unused int signo)
{
if (filename)
- munmap(membase, fssize * sectorsize);
+ munmap(membase, fssize * fsize);
#if 0
remove(mfsdevname);
#endif