Add a convenience function for building nmount iov arrays.
This commit is contained in:
parent
53805858d2
commit
3e7c7ae093
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -138,3 +139,26 @@ checkpath(path, resolved)
|
|||||||
} else
|
} else
|
||||||
errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
|
errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (iovlen < 0)
|
||||||
|
return;
|
||||||
|
i = *iovlen;
|
||||||
|
*iov = realloc(*iov, sizeof **iov * (i + 2));
|
||||||
|
if (*iov == NULL) {
|
||||||
|
*iovlen = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(*iov)[i].iov_base = strdup(name);
|
||||||
|
(*iov)[i].iov_len = strlen(name) + 1;
|
||||||
|
i++;
|
||||||
|
(*iov)[i].iov_base = val;
|
||||||
|
if (len < 0)
|
||||||
|
len = strlen(val) + 1;
|
||||||
|
(*iov)[i].iov_len = len;
|
||||||
|
*iovlen = ++i;
|
||||||
|
}
|
||||||
|
@ -92,3 +92,4 @@ void getmntopts(const char *, const struct mntopt *, int *, int *);
|
|||||||
void rmslashes(char *, char *);
|
void rmslashes(char *, char *);
|
||||||
void checkpath(const char *, char resolved_path[]);
|
void checkpath(const char *, char resolved_path[]);
|
||||||
extern int getmnt_silent;
|
extern int getmnt_silent;
|
||||||
|
void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, int len);
|
||||||
|
Loading…
Reference in New Issue
Block a user