sprintf(gpath, "%s/%s", s->path, name);
- ret = mkdir(gpath, S_IRWXU|S_IRWXG|S_IRWXO);
- if (ret < 0) {
- ERRORNO("%s\n", gpath);
- return NULL;
- }
-
g = malloc(sizeof(struct gadget));
if (!g) {
ERRORNO("allocating gadget\n");
usbg_write_hex16(s->path, name, "idVendor", vendor);
usbg_write_hex16(s->path, name, "idProduct", product);
+ ret = mkdir(gpath, S_IRWXU|S_IRWXG|S_IRWXO);
+ if (ret < 0) {
+ ERRORNO("%s\n", gpath);
+ return NULL;
+ }
+
/* Insert in string order */
if (TAILQ_EMPTY(&s->gadgets) ||
(strcmp(name, TAILQ_FIRST(&s->gadgets)->name) < 0))
sprintf(fpath, "%s/%s/functions/%s", g->path, g->name, name);
- ret = mkdir(fpath, S_IRWXU|S_IRWXG|S_IRWXO);
- if (ret < 0) {
- ERRORNO("%s\n", fpath);
- return NULL;
- }
-
f = malloc(sizeof(struct function));
if (!f) {
ERRORNO("allocating function\n");
usbg_parse_function_attrs(f);
+ ret = mkdir(fpath, S_IRWXU|S_IRWXG|S_IRWXO);
+ if (ret < 0) {
+ ERRORNO("%s\n", fpath);
+ return NULL;
+ }
+
/* Insert in string order */
if (TAILQ_EMPTY(&g->functions) ||
(strcmp(name, TAILQ_FIRST(&g->functions)->name) < 0))
sprintf(cpath, "%s/%s/configs/%s", g->path, g->name, name);
- ret = mkdir(cpath, S_IRWXU|S_IRWXG|S_IRWXO);
- if (ret < 0) {
- ERRORNO("%s\n", cpath);
- return NULL;
- }
-
c = malloc(sizeof(struct config));
if (!c) {
ERRORNO("allocating configuration\n");
strcpy(c->name, name);
sprintf(c->path, "%s/%s/%s/%s", g->path, g->name, "configs", name);
+ ret = mkdir(cpath, S_IRWXU|S_IRWXG|S_IRWXO);
+ if (ret < 0) {
+ ERRORNO("%s\n", cpath);
+ return NULL;
+ }
+
/* Insert in string order */
if (TAILQ_EMPTY(&g->configs) ||
(strcmp(name, TAILQ_FIRST(&g->configs)->name) < 0))