The check for EROFS was wrong. For example, if you try to mount a filesystem
[oweals/busybox.git] / libbb / xgetlarg.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Copyright (C) 2003-2004 Erik Andersen <andersen@codepoet.org>
4  */
5
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <getopt.h>
10 #include <errno.h>
11 #include <assert.h>
12 #include <ctype.h>
13
14 #include "busybox.h"
15
16 extern long bb_xgetlarg(const char *arg, int base, long lower, long upper)
17 {
18         long result;
19         char *endptr;
20         int errno_save = errno;
21
22         assert(arg!=NULL);
23
24         /* Don't allow leading whitespace.
25          * Wrap isspace in () to make sure we call the 
26          * function rather than the macro. */
27         if ((isspace)(*arg)) {
28                 bb_show_usage();
29         }
30
31         errno = 0;
32         result = strtol(arg, &endptr, base);
33         if (errno != 0 || *endptr!='\0' || endptr==arg || result < lower || result > upper)
34                 bb_show_usage();
35         errno = errno_save;
36         return result;
37 }