| 1253 | |
| 1254 | #ifndef _KERNEL |
| 1255 | int |
| 1256 | nvlist_send(int sock, const nvlist_t *nvl) |
| 1257 | { |
| 1258 | size_t datasize, nfds; |
| 1259 | int *fds; |
| 1260 | void *data; |
| 1261 | int64_t fdidx; |
| 1262 | int ret; |
| 1263 | |
| 1264 | if (nvlist_error(nvl) != 0) { |
| 1265 | ERRNO_SET(nvlist_error(nvl)); |
| 1266 | return (-1); |
| 1267 | } |
| 1268 | |
| 1269 | fds = nvlist_descriptors(nvl, &nfds); |
| 1270 | if (fds == NULL) |
| 1271 | return (-1); |
| 1272 | |
| 1273 | ret = -1; |
| 1274 | fdidx = 0; |
| 1275 | |
| 1276 | data = nvlist_xpack(nvl, &fdidx, &datasize); |
| 1277 | if (data == NULL) |
| 1278 | goto out; |
| 1279 | |
| 1280 | if (buf_send(sock, data, datasize) == -1) |
| 1281 | goto out; |
| 1282 | |
| 1283 | if (nfds > 0) { |
| 1284 | if (fd_send(sock, fds, nfds) == -1) |
| 1285 | goto out; |
| 1286 | } |
| 1287 | |
| 1288 | ret = 0; |
| 1289 | out: |
| 1290 | ERRNO_SAVE(); |
| 1291 | nv_free(fds); |
| 1292 | nv_free(data); |
| 1293 | ERRNO_RESTORE(); |
| 1294 | return (ret); |
| 1295 | } |
| 1296 | |
| 1297 | nvlist_t * |
| 1298 | nvlist_recv(int sock, int flags) |
no test coverage detected