MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_getopt_size

Function vfs_getopt_size

freebsd/kern/vfs_mount.c:2048–2087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2046}
2047
2048int
2049vfs_getopt_size(struct vfsoptlist *opts, const char *name, off_t *value)
2050{
2051 char *opt_value, *vtp;
2052 quad_t iv;
2053 int error, opt_len;
2054
2055 error = vfs_getopt(opts, name, (void **)&opt_value, &opt_len);
2056 if (error != 0)
2057 return (error);
2058 if (opt_len == 0 || opt_value == NULL)
2059 return (EINVAL);
2060 if (opt_value[0] == '\0' || opt_value[opt_len - 1] != '\0')
2061 return (EINVAL);
2062 iv = strtoq(opt_value, &vtp, 0);
2063 if (vtp == opt_value || (vtp[0] != '\0' && vtp[1] != '\0'))
2064 return (EINVAL);
2065 if (iv < 0)
2066 return (EINVAL);
2067 switch (vtp[0]) {
2068 case 't': case 'T':
2069 iv *= 1024;
2070 /* FALLTHROUGH */
2071 case 'g': case 'G':
2072 iv *= 1024;
2073 /* FALLTHROUGH */
2074 case 'm': case 'M':
2075 iv *= 1024;
2076 /* FALLTHROUGH */
2077 case 'k': case 'K':
2078 iv *= 1024;
2079 case '\0':
2080 break;
2081 default:
2082 return (EINVAL);
2083 }
2084 *value = iv;
2085
2086 return (0);
2087}
2088
2089char *
2090vfs_getopts(struct vfsoptlist *opts, const char *name, int *error)

Callers

nothing calls this directly

Calls 2

vfs_getoptFunction · 0.85
strtoqFunction · 0.85

Tested by

no test coverage detected