diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2005-01-03 18:59:04 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2005-01-03 18:59:04 +0000 |
commit | 7bb84191e67aba9f11f9b4883ba52478cd0be4e7 (patch) | |
tree | b4bd214eb2c1030d88e87ceb50d9dfc656edd0ac /sbin/ffsinfo | |
parent | 93f4f5a5605b2749b26c9138dcf215177d5ce174 (diff) |
The ffsinfo utility uses atol() to parse numeric values out of optarg
strings. This isn't necessarily a bug, but it can be slightly inconvenient,
because atol() doesn't know how to parse hexadecimal or octal numbers and at
least one of the options of ffsinfo(8) would be easier to use if it did.
Changing atol() -> strtol() allows one to use hex masks for -l MASK, i.e.:
orion:/a/freebsd/src/sbin/ffsinfo# ./ffsinfo -l 0x3ff /
PR: 73110
Submitted by: keramida
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=139647
Diffstat (limited to 'sbin/ffsinfo')
-rw-r--r-- | sbin/ffsinfo/ffsinfo.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c index 3e3a8c246557..e556be82c7e2 100644 --- a/sbin/ffsinfo/ffsinfo.c +++ b/sbin/ffsinfo/ffsinfo.c @@ -63,6 +63,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> +#include <errno.h> #include <fcntl.h> #include <libufs.h> #include <paths.h> @@ -148,19 +149,25 @@ main(int argc, char **argv) while ((ch=getopt(argc, argv, "g:i:l:o:")) != -1) { switch(ch) { case 'g': - cfg_cg=atol(optarg); + cfg_cg=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_cg < -1) { usage(); } break; case 'i': - cfg_in=atol(optarg); + cfg_in=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_in < 0) { usage(); } break; case 'l': - cfg_lv=atol(optarg); + cfg_lv=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_lv < 0x1||cfg_lv > 0x3ff) { usage(); } |