* Plain argument. * * If length is -1, treat value as a C string. */
| 2381 | * If length is -1, treat value as a C string. |
| 2382 | */ |
| 2383 | struct mntarg * |
| 2384 | mount_arg(struct mntarg *ma, const char *name, const void *val, int len) |
| 2385 | { |
| 2386 | |
| 2387 | if (ma == NULL) { |
| 2388 | ma = malloc(sizeof *ma, M_MOUNT, M_WAITOK | M_ZERO); |
| 2389 | SLIST_INIT(&ma->list); |
| 2390 | } |
| 2391 | if (ma->error) |
| 2392 | return (ma); |
| 2393 | |
| 2394 | ma->v = realloc(ma->v, sizeof *ma->v * (ma->len + 2), |
| 2395 | M_MOUNT, M_WAITOK); |
| 2396 | ma->v[ma->len].iov_base = (void *)(uintptr_t)name; |
| 2397 | ma->v[ma->len].iov_len = strlen(name) + 1; |
| 2398 | ma->len++; |
| 2399 | |
| 2400 | ma->v[ma->len].iov_base = (void *)(uintptr_t)val; |
| 2401 | if (len < 0) |
| 2402 | ma->v[ma->len].iov_len = strlen(val) + 1; |
| 2403 | else |
| 2404 | ma->v[ma->len].iov_len = len; |
| 2405 | ma->len++; |
| 2406 | return (ma); |
| 2407 | } |
| 2408 | |
| 2409 | /* |
| 2410 | * Free a mntarg structure |
no test coverage detected