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

Function mount_argf

freebsd/kern/vfs_mount.c:2315–2352  ·  view source on GitHub ↗

* Add an argument printf style */

Source from the content-addressed store, hash-verified

2313 * Add an argument printf style
2314 */
2315struct mntarg *
2316mount_argf(struct mntarg *ma, const char *name, const char *fmt, ...)
2317{
2318 va_list ap;
2319 struct mntaarg *maa;
2320 struct sbuf *sb;
2321 int len;
2322
2323 if (ma == NULL) {
2324 ma = malloc(sizeof *ma, M_MOUNT, M_WAITOK | M_ZERO);
2325 SLIST_INIT(&ma->list);
2326 }
2327 if (ma->error)
2328 return (ma);
2329
2330 ma->v = realloc(ma->v, sizeof *ma->v * (ma->len + 2),
2331 M_MOUNT, M_WAITOK);
2332 ma->v[ma->len].iov_base = (void *)(uintptr_t)name;
2333 ma->v[ma->len].iov_len = strlen(name) + 1;
2334 ma->len++;
2335
2336 sb = sbuf_new_auto();
2337 va_start(ap, fmt);
2338 sbuf_vprintf(sb, fmt, ap);
2339 va_end(ap);
2340 sbuf_finish(sb);
2341 len = sbuf_len(sb) + 1;
2342 maa = malloc(sizeof *maa + len, M_MOUNT, M_WAITOK | M_ZERO);
2343 SLIST_INSERT_HEAD(&ma->list, maa, next);
2344 bcopy(sbuf_data(sb), maa + 1, len);
2345 sbuf_delete(sb);
2346
2347 ma->v[ma->len].iov_base = maa + 1;
2348 ma->v[ma->len].iov_len = len;
2349 ma->len++;
2350
2351 return (ma);
2352}
2353
2354/*
2355 * Add an argument which is a userland string.

Callers

nothing calls this directly

Calls 7

mallocFunction · 0.85
sbuf_vprintfFunction · 0.85
sbuf_finishFunction · 0.85
sbuf_lenFunction · 0.85
sbuf_dataFunction · 0.85
sbuf_deleteFunction · 0.85
reallocFunction · 0.70

Tested by

no test coverage detected