#define XFS_NOMULTIDISK_AGLOG 2 /* 4 AGs */
#define XFS_MULTIDISK_AGCOUNT (1 << XFS_MULTIDISK_AGLOG)
-extern long long cvtnum(unsigned int blksize, unsigned int sectsize,
- const char *str);
-
/* proto.c */
extern char *setup_proto (char *fname);
extern void parse_proto (xfs_mount_t *mp, struct fsxattr *fsx, char **pp);
long long
cvtnum(
- size_t blocksize,
- size_t sectorsize,
- char *s)
+ size_t blksize,
+ size_t sectsize,
+ const char *s)
{
long long i;
char *sp;
c = tolower(*sp);
switch (c) {
case 'b':
- return i * blocksize;
+ if (!blksize)
+ return -1LL;
+ return i * blksize;
case 's':
- return i * sectorsize;
+ if (!sectsize)
+ return -1LL;
+ return i * sectsize;
case 'k':
return KILOBYTES(i);
case 'm':
extern uint32_t cvt_u32(char *s, int base);
extern uint16_t cvt_u16(char *s, int base);
-extern long long cvtnum(size_t blocksize, size_t sectorsize, char *s);
+extern long long cvtnum(size_t blocksize, size_t sectorsize, const char *s);
extern void cvtstr(double value, char *str, size_t sz);
extern unsigned long cvttime(char *s);
#include "libxfs.h"
#include <sys/stat.h>
-#include "xfs_multidisk.h"
+#include "libfrog/convert.h"
/*
* Prototypes for internal functions.
#include "libxcmd.h"
#include "libfrog/fsgeom.h"
#include "libfrog/topology.h"
+#include "libfrog/convert.h"
#define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog)))
#define GIGABYTES(count, blog) ((uint64_t)(count) << (30 - (blog)))
usage();
}
-long long
-cvtnum(
- unsigned int blksize,
- unsigned int sectsize,
- const char *s)
-{
- long long i;
- char *sp;
- int c;
-
- i = strtoll(s, &sp, 0);
- if (i == 0 && sp == s)
- return -1LL;
- if (*sp == '\0')
- return i;
-
- if (sp[1] != '\0')
- return -1LL;
-
- if (*sp == 'b') {
- if (!blksize) {
- fprintf(stderr,
-_("Blocksize must be provided prior to using 'b' suffix.\n"));
- usage();
- } else {
- return i * blksize;
- }
- }
- if (*sp == 's') {
- if (!sectsize) {
- fprintf(stderr,
-_("Sectorsize must be specified prior to using 's' suffix.\n"));
- usage();
- } else {
- return i * sectsize;
- }
- }
-
- c = tolower(*sp);
- switch (c) {
- case 'e':
- i *= 1024LL;
- /* fall through */
- case 'p':
- i *= 1024LL;
- /* fall through */
- case 't':
- i *= 1024LL;
- /* fall through */
- case 'g':
- i *= 1024LL;
- /* fall through */
- case 'm':
- i *= 1024LL;
- /* fall through */
- case 'k':
- return i * 1024LL;
- default:
- break;
- }
- return -1LL;
-}
-
static void
check_device_type(
const char *name,
* convert it ourselves to guarantee there is no trailing garbage in the
* number.
*/
- if (sp->convert)
+ if (sp->convert) {
c = cvtnum(blocksize, sectorsize, str);
- else {
+ if (c == -1LL) {
+ illegal_option(str, opts, index,
+ _("Not a valid value or illegal suffix"));
+ }
+ } else {
char *str_end;
c = strtoll(str, &str_end, 0);