2 * Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/ctype.h>
36 #include <sys/malloc.h>
37 #include <sys/systm.h>
47 #include "bhnd_nvram_private.h"
49 #include "bhnd_nvram_datavar.h"
51 #include "bhnd_nvram_data_tlvreg.h"
54 * CFE TLV NVRAM data class.
56 * The CFE-defined TLV NVRAM format is used on the WGT634U.
59 struct bhnd_nvram_tlv {
60 struct bhnd_nvram_data nv; /**< common instance state */
61 struct bhnd_nvram_io *data; /**< backing buffer */
62 size_t count; /**< variable count */
65 BHND_NVRAM_DATA_CLASS_DEFN(tlv, "WGT634U", BHND_NVRAM_DATA_CAP_DEVPATHS,
66 sizeof(struct bhnd_nvram_tlv))
68 /** Minimal TLV_ENV record header */
69 struct bhnd_nvram_tlv_env_hdr {
74 /** Minimal TLV_ENV record */
75 struct bhnd_nvram_tlv_env {
76 struct bhnd_nvram_tlv_env_hdr hdr;
81 /* Return the length in bytes of an TLV_ENV's envp data */
82 #define NVRAM_TLV_ENVP_DATA_LEN(_env) \
83 (((_env)->hdr.size < sizeof((_env)->flags)) ? 0 : \
84 ((_env)->hdr.size - sizeof((_env)->flags)))
86 /* Maximum supported length of the envp data field, in bytes */
87 #define NVRAM_TLV_ENVP_DATA_MAX_LEN \
88 (UINT8_MAX - sizeof(uint8_t) /* flags */)
91 static int bhnd_nvram_tlv_parse_size(
92 struct bhnd_nvram_io *io,
95 static int bhnd_nvram_tlv_next_record(
96 struct bhnd_nvram_io *io,
97 size_t *next, size_t *offset,
100 static struct bhnd_nvram_tlv_env *bhnd_nvram_tlv_next_env(
101 struct bhnd_nvram_tlv *tlv,
102 size_t *next, void **cookiep);
104 static struct bhnd_nvram_tlv_env *bhnd_nvram_tlv_get_env(
105 struct bhnd_nvram_tlv *tlv,
108 static void *bhnd_nvram_tlv_to_cookie(
109 struct bhnd_nvram_tlv *tlv,
111 static size_t bhnd_nvram_tlv_to_offset(
112 struct bhnd_nvram_tlv *tlv,
116 bhnd_nvram_tlv_probe(struct bhnd_nvram_io *io)
118 struct bhnd_nvram_tlv_env ident;
122 nbytes = bhnd_nvram_io_getsize(io);
124 /* Handle what might be an empty TLV image */
125 if (nbytes < sizeof(ident)) {
128 /* Fetch just the first tag */
129 error = bhnd_nvram_io_read(io, 0x0, &tag, sizeof(tag));
133 /* This *could* be an empty TLV image, but all we're
134 * testing for here is a single 0x0 byte followed by EOF */
135 if (tag == NVRAM_TLV_TYPE_END)
136 return (BHND_NVRAM_DATA_PROBE_MAYBE);
141 /* Otherwise, look at the initial header for a valid TLV ENV tag,
142 * plus one byte of the entry data */
143 error = bhnd_nvram_io_read(io, 0x0, &ident,
144 sizeof(ident) + sizeof(ident.envp[0]));
148 /* First entry should be a variable record (which we statically
149 * assert as being defined to use a single byte size field) */
150 if (ident.hdr.tag != NVRAM_TLV_TYPE_ENV)
153 _Static_assert(NVRAM_TLV_TYPE_ENV & NVRAM_TLV_TF_U8_LEN,
154 "TYPE_ENV is not a U8-sized field");
156 /* The entry must be at least 3 characters ('x=\0') in length */
157 if (ident.hdr.size < 3)
160 /* The first character should be a valid key char (alpha) */
161 if (!bhnd_nv_isalpha(ident.envp[0]))
164 return (BHND_NVRAM_DATA_PROBE_DEFAULT);
168 bhnd_nvram_tlv_getvar_direct(struct bhnd_nvram_io *io, const char *name,
169 void *buf, size_t *len, bhnd_nvram_type type)
171 struct bhnd_nvram_tlv_env env;
172 char data[NVRAM_TLV_ENVP_DATA_MAX_LEN];
174 const char *key, *value;
181 namelen = strlen(name);
183 /* Iterate over the input looking for the requested variable */
185 while (!(error = bhnd_nvram_tlv_next_record(io, &next, &off, &tag))) {
187 case NVRAM_TLV_TYPE_END:
191 case NVRAM_TLV_TYPE_ENV:
192 /* Read the record header */
193 error = bhnd_nvram_io_read(io, off, &env, sizeof(env));
195 BHND_NV_LOG("error reading TLV_ENV record "
196 "header: %d\n", error);
200 /* Read the record data */
201 data_len = NVRAM_TLV_ENVP_DATA_LEN(&env);
202 error = bhnd_nvram_io_read(io, off + sizeof(env), data,
205 BHND_NV_LOG("error reading TLV_ENV record "
206 "data: %d\n", error);
210 /* Parse the key=value string */
211 error = bhnd_nvram_parse_env(data, data_len, '=', &key,
212 &keylen, &value, &vlen);
214 BHND_NV_LOG("error parsing TLV_ENV data: %d\n",
219 /* Match against requested variable name */
220 if (keylen == namelen &&
221 strncmp(key, name, namelen) == 0)
223 return (bhnd_nvram_value_coerce(value, vlen,
224 BHND_NVRAM_TYPE_STRING, buf, len, type));
230 /* Skip unknown tags */
240 bhnd_nvram_tlv_serialize(bhnd_nvram_data_class *cls, bhnd_nvram_plist *props,
241 bhnd_nvram_plist *options, void *outp, size_t *olen)
243 bhnd_nvram_prop *prop;
244 size_t limit, nbytes;
247 /* Determine output byte limit */
255 /* Write all properties */
257 while ((prop = bhnd_nvram_plist_next(props, prop)) != NULL) {
258 struct bhnd_nvram_tlv_env env;
261 size_t name_len, value_len;
264 env.hdr.tag = NVRAM_TLV_TYPE_ENV;
265 env.hdr.size = sizeof(env.flags);
268 /* Fetch name value and add to record length */
269 name = bhnd_nvram_prop_name(prop);
270 name_len = strlen(name) + 1 /* '=' */;
272 if (UINT8_MAX - env.hdr.size < name_len) {
273 BHND_NV_LOG("%s name exceeds maximum TLV record "
275 return (EFTYPE); /* would overflow TLV size */
278 env.hdr.size += name_len;
280 /* Add string value to record length */
281 error = bhnd_nvram_prop_encode(prop, NULL, &value_len,
282 BHND_NVRAM_TYPE_STRING);
284 BHND_NV_LOG("error serializing %s to required type "
286 bhnd_nvram_type_name(BHND_NVRAM_TYPE_STRING),
291 if (UINT8_MAX - env.hdr.size < value_len) {
292 BHND_NV_LOG("%s value exceeds maximum TLV record "
294 return (EFTYPE); /* would overflow TLV size */
297 env.hdr.size += value_len;
299 /* Calculate total record size */
300 rec_size = sizeof(env.hdr) + env.hdr.size;
301 if (SIZE_MAX - nbytes < rec_size)
302 return (EFTYPE); /* would overflow size_t */
304 /* Calculate our output pointer */
305 if (nbytes > limit || limit - nbytes < rec_size) {
306 /* buffer is full; cannot write */
309 p = (uint8_t *)outp + nbytes;
312 /* Write to output */
314 memcpy(p, &env, sizeof(env));
317 memcpy(p, name, name_len - 1);
318 p[name_len - 1] = '=';
321 error = bhnd_nvram_prop_encode(prop, p, &value_len,
322 BHND_NVRAM_TYPE_STRING);
324 BHND_NV_LOG("error serializing %s to required "
325 "type %s: %d\n", name,
326 bhnd_nvram_type_name(
327 BHND_NVRAM_TYPE_STRING),
336 /* Write terminating END record */
338 *((uint8_t *)outp + nbytes) = NVRAM_TLV_TYPE_END;
340 if (nbytes == SIZE_MAX)
341 return (EFTYPE); /* would overflow size_t */
344 /* Provide required length */
357 * Initialize @p tlv with the provided NVRAM TLV data mapped by @p src.
359 * @param tlv A newly allocated data instance.
362 bhnd_nvram_tlv_init(struct bhnd_nvram_tlv *tlv, struct bhnd_nvram_io *src)
364 struct bhnd_nvram_tlv_env *env;
369 BHND_NV_ASSERT(tlv->data == NULL, ("tlv data already initialized"));
371 /* Determine the actual size of the TLV source data */
372 if ((error = bhnd_nvram_tlv_parse_size(src, &size)))
375 /* Copy to our own internal buffer */
376 if ((tlv->data = bhnd_nvram_iobuf_copy_range(src, 0x0, size)) == NULL)
379 /* Initialize our backing buffer */
382 while ((env = bhnd_nvram_tlv_next_env(tlv, &next, NULL)) != NULL) {
386 /* TLV_ENV data must not be empty */
387 env_len = NVRAM_TLV_ENVP_DATA_LEN(env);
389 BHND_NV_LOG("cannot parse zero-length TLV_ENV record "
394 /* Parse the key=value string, and then replace the '='
395 * delimiter with '\0' to allow us to provide direct
396 * name pointers from our backing buffer */
397 error = bhnd_nvram_parse_env(env->envp, env_len, '=', NULL,
398 &name_len, NULL, NULL);
400 BHND_NV_LOG("error parsing TLV_ENV data: %d\n", error);
404 /* Replace '=' with '\0' */
405 *(env->envp + name_len) = '\0';
407 /* Add to variable count */
415 bhnd_nvram_tlv_new(struct bhnd_nvram_data *nv, struct bhnd_nvram_io *io)
418 struct bhnd_nvram_tlv *tlv;
421 /* Allocate and initialize the TLV data instance */
422 tlv = (struct bhnd_nvram_tlv *)nv;
424 /* Parse the TLV input data and initialize our backing
425 * data representation */
426 if ((error = bhnd_nvram_tlv_init(tlv, io))) {
427 bhnd_nvram_tlv_free(nv);
435 bhnd_nvram_tlv_free(struct bhnd_nvram_data *nv)
437 struct bhnd_nvram_tlv *tlv = (struct bhnd_nvram_tlv *)nv;
438 if (tlv->data != NULL)
439 bhnd_nvram_io_free(tlv->data);
443 bhnd_nvram_tlv_count(struct bhnd_nvram_data *nv)
445 struct bhnd_nvram_tlv *tlv = (struct bhnd_nvram_tlv *)nv;
450 static bhnd_nvram_plist *
451 bhnd_nvram_tlv_options(struct bhnd_nvram_data *nv)
457 bhnd_nvram_tlv_caps(struct bhnd_nvram_data *nv)
459 return (BHND_NVRAM_DATA_CAP_READ_PTR|BHND_NVRAM_DATA_CAP_DEVPATHS);
463 bhnd_nvram_tlv_next(struct bhnd_nvram_data *nv, void **cookiep)
465 struct bhnd_nvram_tlv *tlv;
466 struct bhnd_nvram_tlv_env *env;
469 tlv = (struct bhnd_nvram_tlv *)nv;
471 /* Find next readable TLV record */
472 if (*cookiep == NULL) {
473 /* Start search at offset 0x0 */
475 env = bhnd_nvram_tlv_next_env(tlv, &io_offset, cookiep);
477 /* Seek past the previous env record */
478 io_offset = bhnd_nvram_tlv_to_offset(tlv, *cookiep);
479 env = bhnd_nvram_tlv_next_env(tlv, &io_offset, NULL);
481 BHND_NV_PANIC("invalid cookiep; record missing");
483 /* Advance to next env record, update the caller's cookiep */
484 env = bhnd_nvram_tlv_next_env(tlv, &io_offset, cookiep);
491 /* Return the NUL terminated name */
496 bhnd_nvram_tlv_find(struct bhnd_nvram_data *nv, const char *name)
498 return (bhnd_nvram_data_generic_find(nv, name));
502 bhnd_nvram_tlv_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1,
505 if (cookiep1 < cookiep2)
508 if (cookiep1 > cookiep2)
515 bhnd_nvram_tlv_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf,
516 size_t *len, bhnd_nvram_type type)
518 return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type));
522 bhnd_nvram_tlv_copy_val(struct bhnd_nvram_data *nv, void *cookiep,
523 bhnd_nvram_val **value)
525 return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value));
529 bhnd_nvram_tlv_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep,
530 size_t *len, bhnd_nvram_type *type)
532 struct bhnd_nvram_tlv *tlv;
533 struct bhnd_nvram_tlv_env *env;
537 tlv = (struct bhnd_nvram_tlv *)nv;
539 /* Fetch pointer to the TLV_ENV record */
540 if ((env = bhnd_nvram_tlv_get_env(tlv, cookiep)) == NULL)
541 BHND_NV_PANIC("invalid cookiep: %p", cookiep);
543 /* Parse value pointer and length from key\0value data */
544 error = bhnd_nvram_parse_env(env->envp, NVRAM_TLV_ENVP_DATA_LEN(env),
545 '\0', NULL, NULL, &val, len);
547 BHND_NV_PANIC("unexpected error parsing '%s'", env->envp);
549 /* Type is always CSTR */
550 *type = BHND_NVRAM_TYPE_STRING;
556 bhnd_nvram_tlv_getvar_name(struct bhnd_nvram_data *nv, void *cookiep)
558 struct bhnd_nvram_tlv *tlv;
559 const struct bhnd_nvram_tlv_env *env;
561 tlv = (struct bhnd_nvram_tlv *)nv;
563 /* Fetch pointer to the TLV_ENV record */
564 if ((env = bhnd_nvram_tlv_get_env(tlv, cookiep)) == NULL)
565 BHND_NV_PANIC("invalid cookiep: %p", cookiep);
567 /* Return name pointer */
568 return (&env->envp[0]);
572 bhnd_nvram_tlv_filter_setvar(struct bhnd_nvram_data *nv, const char *name,
573 bhnd_nvram_val *value, bhnd_nvram_val **result)
577 bhnd_nvram_type itype;
579 size_t name_len, tlv_nremain;
582 tlv_nremain = NVRAM_TLV_ENVP_DATA_MAX_LEN;
584 /* Name (trimmed of any path prefix) must be valid */
585 if (!bhnd_nvram_validate_name(bhnd_nvram_trim_path_name(name)))
588 /* 'name=' must fit within the maximum TLV_ENV record length */
589 name_len = strlen(name) + 1; /* '=' */
590 if (tlv_nremain < name_len) {
591 BHND_NV_LOG("'%s=' exceeds maximum TLV_ENV record length\n",
595 tlv_nremain -= name_len;
597 /* Convert value to a (bcm-formatted) string */
598 error = bhnd_nvram_val_convert_new(&str, &bhnd_nvram_val_bcm_string_fmt,
599 value, BHND_NVRAM_VAL_DYNAMIC);
603 /* The string value must fit within remaining TLV_ENV record length */
604 inp = bhnd_nvram_val_bytes(str, &ilen, &itype);
605 if (tlv_nremain < ilen) {
606 BHND_NV_LOG("'%.*s\\0' exceeds maximum TLV_ENV record length\n",
607 BHND_NV_PRINT_WIDTH(ilen), inp);
609 bhnd_nvram_val_release(str);
612 tlv_nremain -= name_len;
614 /* Success. Transfer result ownership to the caller. */
620 bhnd_nvram_tlv_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name)
622 /* We permit deletion of any variable */
627 * Iterate over the records starting at @p next, returning the parsed
628 * record's @p tag, @p size, and @p offset.
630 * @param io The I/O context to parse.
631 * @param[in,out] next The next offset to be parsed, or 0x0
632 * to begin parsing. Upon successful
633 * return, will be set to the offset of the
634 * next record (or EOF, if
635 * NVRAM_TLV_TYPE_END was parsed).
636 * @param[out] offset The record's value offset.
637 * @param[out] tag The record's tag.
640 * @retval EINVAL if parsing @p io as TLV fails.
641 * @retval non-zero if reading @p io otherwise fails, a regular unix error
642 * code will be returned.
645 bhnd_nvram_tlv_next_record(struct bhnd_nvram_io *io, size_t *next, size_t
646 *offset, uint8_t *tag)
648 size_t io_offset, io_size;
654 io_size = bhnd_nvram_io_getsize(io);
656 /* Save the record offset */
660 /* Fetch initial tag */
661 error = bhnd_nvram_io_read(io, io_offset, tag, sizeof(*tag));
667 if (*tag == NVRAM_TLV_TYPE_END) {
672 /* Read length field */
673 if (*tag & NVRAM_TLV_TF_U8_LEN) {
674 error = bhnd_nvram_io_read(io, io_offset, &len_hdr,
677 BHND_NV_LOG("error reading TLV record size: %d\n",
682 parsed_len = len_hdr[0];
685 error = bhnd_nvram_io_read(io, io_offset, &len_hdr,
688 BHND_NV_LOG("error reading 16-bit TLV record "
689 "size: %d\n", error);
693 parsed_len = (len_hdr[0] << 8) | len_hdr[1];
697 /* Advance to next record */
698 if (parsed_len > io_size || io_size - parsed_len < io_offset) {
700 BHND_NV_LOG("TLV record length %hu truncated by input "
701 "size of %zu\n", parsed_len, io_size);
705 *next = io_offset + parsed_len;
707 /* Valid record found */
712 * Parse the TLV data in @p io to determine the total size of the TLV
713 * data mapped by @p io (which may be less than the size of @p io).
716 bhnd_nvram_tlv_parse_size(struct bhnd_nvram_io *io, size_t *size)
722 /* We have to perform a minimal parse to determine the actual length */
726 /* Iterate over the input until we hit END tag or the read fails */
728 error = bhnd_nvram_tlv_next_record(io, &next, NULL, &tag);
731 } while (tag != NVRAM_TLV_TYPE_END);
733 /* Offset should now point to EOF */
734 BHND_NV_ASSERT(next <= bhnd_nvram_io_getsize(io),
735 ("parse returned invalid EOF offset"));
742 * Iterate over the records in @p tlv, returning a pointer to the next
743 * NVRAM_TLV_TYPE_ENV record, or NULL if EOF is reached.
745 * @param tlv The TLV instance.
746 * @param[in,out] next The next offset to be parsed, or 0x0
747 * to begin parsing. Upon successful
748 * return, will be set to the offset of the
751 static struct bhnd_nvram_tlv_env *
752 bhnd_nvram_tlv_next_env(struct bhnd_nvram_tlv *tlv, size_t *next,
758 /* Find the next TLV_ENV record, starting at @p next */
763 /* Fetch the next TLV record */
764 error = bhnd_nvram_tlv_next_record(tlv->data, next, &offset,
767 BHND_NV_LOG("unexpected error in next_record(): %d\n",
772 /* Only interested in ENV records */
773 if (tag != NVRAM_TLV_TYPE_ENV)
776 /* Map and return TLV_ENV record pointer */
777 c = bhnd_nvram_tlv_to_cookie(tlv, offset);
779 /* Provide the cookiep value for the returned record */
783 return (bhnd_nvram_tlv_get_env(tlv, c));
784 } while (tag != NVRAM_TLV_TYPE_END);
786 /* No remaining ENV records */
791 * Return a pointer to the TLV_ENV record for @p cookiep, or NULL
794 static struct bhnd_nvram_tlv_env *
795 bhnd_nvram_tlv_get_env(struct bhnd_nvram_tlv *tlv, void *cookiep)
797 struct bhnd_nvram_tlv_env *env;
800 size_t io_offset, io_size;
803 io_size = bhnd_nvram_io_getsize(tlv->data);
804 io_offset = bhnd_nvram_tlv_to_offset(tlv, cookiep);
807 if (io_offset == io_size)
810 /* Fetch non-const pointer to the record entry */
811 error = bhnd_nvram_io_write_ptr(tlv->data, io_offset, &ptr,
812 sizeof(env->hdr), &navail);
814 /* Should never occur with a valid cookiep */
815 BHND_NV_LOG("error mapping record for cookiep: %d\n", error);
819 /* Validate the record pointer */
821 if (env->hdr.tag != NVRAM_TLV_TYPE_ENV) {
822 /* Should never occur with a valid cookiep */
823 BHND_NV_LOG("non-ENV record mapped for %p\n", cookiep);
827 /* Is the required variable name data is mapped? */
828 if (navail < sizeof(struct bhnd_nvram_tlv_env_hdr) + env->hdr.size ||
829 env->hdr.size == sizeof(env->flags))
831 /* Should never occur with a valid cookiep */
832 BHND_NV_LOG("TLV_ENV variable data not mapped for %p\n",
841 * Return a cookiep for the given I/O offset.
844 bhnd_nvram_tlv_to_cookie(struct bhnd_nvram_tlv *tlv, size_t io_offset)
849 BHND_NV_ASSERT(io_offset < bhnd_nvram_io_getsize(tlv->data),
850 ("io_offset %zu out-of-range", io_offset));
851 BHND_NV_ASSERT(io_offset < UINTPTR_MAX,
852 ("io_offset %#zx exceeds UINTPTR_MAX", io_offset));
854 error = bhnd_nvram_io_read_ptr(tlv->data, 0x0, &ptr, io_offset, NULL);
856 BHND_NV_PANIC("error mapping offset %zu: %d", io_offset, error);
858 ptr = (const uint8_t *)ptr + io_offset;
859 return (__DECONST(void *, ptr));
862 /* Convert a cookiep back to an I/O offset */
864 bhnd_nvram_tlv_to_offset(struct bhnd_nvram_tlv *tlv, void *cookiep)
871 BHND_NV_ASSERT(cookiep != NULL, ("null cookiep"));
873 io_size = bhnd_nvram_io_getsize(tlv->data);
875 error = bhnd_nvram_io_read_ptr(tlv->data, 0x0, &ptr, io_size, NULL);
877 BHND_NV_PANIC("error mapping offset %zu: %d", io_size, error);
879 offset = (const uint8_t *)cookiep - (const uint8_t *)ptr;
880 BHND_NV_ASSERT(offset >= 0, ("invalid cookiep"));
881 BHND_NV_ASSERT((uintptr_t)offset < SIZE_MAX, ("cookiep > SIZE_MAX)"));
882 BHND_NV_ASSERT((uintptr_t)offset <= io_size, ("cookiep > io_size)"));
884 return ((size_t)offset);