diff options
author | sobomax <sobomax@FreeBSD.org> | 2010-03-09 10:31:03 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2010-03-09 10:31:03 +0000 |
commit | 1b7c7ca0d50397cfc767a9889922470f33759106 (patch) | |
tree | 25316d3a27e5940073b23bff467e2b6eae3b9d3d /sbin | |
parent | 03f7b71a7adf7744c15affe072483f8858c231c5 (diff) | |
download | FreeBSD-src-1b7c7ca0d50397cfc767a9889922470f33759106.zip FreeBSD-src-1b7c7ca0d50397cfc767a9889922470f33759106.tar.gz |
Change secrorsize back to int, since that's the data type expected by the
ioctl(DIOCGSECTORSIZE). It creates issues on some architectures.
MFC after: 1 week
Reported by: Jayachandran C.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/newfs/newfs.c | 22 | ||||
-rw-r--r-- | sbin/newfs/newfs.h | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 1dc326c..9f6a4d7 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -92,7 +92,7 @@ int Jflag; /* enable gjournal for file system */ int lflag; /* enable multilabel for file system */ int nflag; /* do not create .snap directory */ intmax_t fssize; /* file system size */ -int64_t sectorsize; /* bytes/sector */ +int sectorsize; /* bytes/sector */ int realsectorsize; /* bytes/sector in hardware */ int64_t fsize = 0; /* fragment size */ int64_t bsize = 0; /* block size */ @@ -119,6 +119,7 @@ static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t); static struct disklabel *getdisklabel(char *s); static void rewritelabel(char *s, struct disklabel *lp); static void usage(void); +static int expand_number_int(const char *buf, int *num); ufs2_daddr_t part_ofs; /* partition offset in blocks, used with files */ @@ -171,7 +172,7 @@ main(int argc, char *argv[]) Rflag = 1; break; case 'S': - rval = expand_number(optarg, §orsize); + rval = expand_number_int(optarg, §orsize); if (rval < 0 || sectorsize <= 0) errx(1, "%s: bad sector size", optarg); break; @@ -496,3 +497,20 @@ usage() fprintf(stderr, "\t-s file system size (sectors)\n"); exit(1); } + +static int +expand_number_int(const char *buf, int *num) +{ + int64_t num64; + int rval; + + rval = expand_number(buf, &num64); + if (rval != 0) + return (rval); + if (num64 > INT_MAX) { + errno = ERANGE; + return (-1); + } + *num = (int)num64; + return (0); +} diff --git a/sbin/newfs/newfs.h b/sbin/newfs/newfs.h index 579d109..d957e26 100644 --- a/sbin/newfs/newfs.h +++ b/sbin/newfs/newfs.h @@ -86,7 +86,7 @@ extern int Jflag; /* enable gjournal for file system */ extern int lflag; /* enable multilabel MAC for file system */ extern int nflag; /* do not create .snap directory */ extern intmax_t fssize; /* file system size */ -extern int64_t sectorsize; /* bytes/sector */ +extern int sectorsize; /* bytes/sector */ extern int realsectorsize; /* bytes/sector in hardware*/ extern int64_t fsize; /* fragment size */ extern int64_t bsize; /* block size */ |