bool attach_nbd(char *src, struct lxc_conf *conf) { __do_free char *orig; char *p, path[50]; int i = 0; orig = must_copy_string(src); /* if path is followed by a partition, drop that for now */ p = strchr(orig, ':'); if (p) *p = '\0'; for (;;) { sprintf(path, "/dev/nbd%d", i); if (!file_exists(path)) return false; if (nbd_busy(i)) { i++; continue; } if (!clone_attach_nbd(path, orig)) return false; conf->nbd_idx = i; return true; } }
bool attach_nbd(char *src, struct lxc_conf *conf) { char *orig = alloca(strlen(src)+1), *p, path[50]; int i = 0; strcpy(orig, src); /* if path is followed by a partition, drop that for now */ p = strchr(orig, ':'); if (p) *p = '\0'; while (1) { sprintf(path, "/dev/nbd%d", i); if (!file_exists(path)) return false; if (nbd_busy(i)) { i++; continue; } if (!clone_attach_nbd(path, orig)) return false; conf->nbd_idx = i; return true; } }