* Assign a globally unique name to a node * Returns -1 if error and sets errno. */
| 190 | * Returns -1 if error and sets errno. |
| 191 | */ |
| 192 | int |
| 193 | NgNameNode(int cs, const char *path, const char *fmt, ...) |
| 194 | { |
| 195 | struct ngm_name ngn; |
| 196 | va_list args; |
| 197 | |
| 198 | /* Build message arg */ |
| 199 | va_start(args, fmt); |
| 200 | vsnprintf(ngn.name, sizeof(ngn.name), fmt, args); |
| 201 | va_end(args); |
| 202 | |
| 203 | /* Send message */ |
| 204 | if (NgSendMsg(cs, path, |
| 205 | NGM_GENERIC_COOKIE, NGM_NAME, &ngn, sizeof(ngn)) < 0) { |
| 206 | if (_gNgDebugLevel >= 1) |
| 207 | NGLOGX("%s: failed", __func__); |
| 208 | return (-1); |
| 209 | } |
| 210 | |
| 211 | /* Done */ |
| 212 | return (0); |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | * Read a packet from a data socket |