* Note that kernels up to at least 2.3.39 don't support cramfs holes,
* which is why this is turned off by default.
*/
-static int opt_edition = 0;
+static unsigned int opt_edition = 0;
static int opt_errors = 0;
static int opt_holes = 0;
static int opt_pad = 0;
case 'h':
usage(MKFS_EX_OK);
case 'b':
- {
- long long tmp = strtoll_or_err(optarg,
- _("failed to parse blocksize argument"));
-
- if (tmp <= 0 || UINT_MAX < tmp)
- errx(MKFS_EX_USAGE, _("invalid block size"));
- blksize = tmp;
+ blksize = strtou32_or_err(optarg, _("invalid blocksize argument"));
break;
- }
case 'E':
opt_errors = 1;
break;
case 'e':
- opt_edition = strtoll_or_err(optarg, _("edition number argument failed"));
+ opt_edition = strtou32_or_err(optarg, _("edition number argument failed"));
break;
case 'N':
if (strcmp(optarg, "big") == 0)
* What to do? Let us allow the user to specify the pagesize explicitly.
*
*/
-static long user_pagesize;
-static int pagesize;
+static unsigned int user_pagesize;
+static unsigned int pagesize;
static unsigned long *signature_page = NULL;
static void
init_signature_page(void)
{
- int kernel_pagesize = pagesize = getpagesize();
+ unsigned int kernel_pagesize = pagesize = getpagesize();
if (user_pagesize) {
- if ((user_pagesize & (user_pagesize - 1)) ||
- user_pagesize < (long) sizeof(struct swap_header_v1_2) + 10)
+ if (!is_power_of_2(user_pagesize) ||
+ user_pagesize < sizeof(struct swap_header_v1_2) + 10)
errx(EXIT_FAILURE,
- _("Bad user-specified page size %lu"),
+ _("Bad user-specified page size %u"),
user_pagesize);
pagesize = user_pagesize;
}
unsigned long long sz;
off_t offset;
int force = 0;
- long version = 1;
+ int version = 1;
char *block_count = 0;
char *opt_label = NULL;
unsigned char *uuid = NULL;
force=1;
break;
case 'p':
- user_pagesize = strtol_or_err(optarg, _("parse page size failed"));
+ user_pagesize = strtou32_or_err(optarg, _("parse page size failed"));
break;
case 'L':
opt_label = optarg;
break;
case 'v':
- version = strtol_or_err(optarg, _("parse version number failed"));
+ version = strtos32_or_err(optarg, _("parse version number failed"));
break;
case 'U':
#ifdef HAVE_LIBUUID
#endif
break;
case 'V':
- printf(_("%s from %s\n"), program_invocation_short_name,
- PACKAGE_STRING);
+ printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'h':
usage(stdout);
if (version != 1)
errx(EXIT_FAILURE,
- _("does not support swapspace version %lu."),
- version);
+ _("does not support swapspace version %d."), version);
#ifdef HAVE_LIBUUID
if(opt_uuid) {
}
if (block_count) {
/* this silly user specified the number of blocks explicitly */
- long long blks;
-
- blks = strtoll_or_err(block_count, "parse block count failed");
- if (blks < 0)
- usage(stderr);
-
+ uint64_t blks = strtou64_or_err(block_count,
+ _("invalid block count argument"));
PAGES = blks / (pagesize / 1024);
}
sz = get_size(device_name);