Changeset ca127f37 in mainline for uspace/srv/volsrv/volume.c
- Timestamp:
- 2024-09-07T18:33:36Z (11 days ago)
- Branches:
- master
- Children:
- 430442d, 47bfcfb, de4f165, e132103b
- Parents:
- e90019d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/volsrv/volume.c
re90019d rca127f37 185 185 free(volumes); 186 186 187 return rc; 188 } 189 190 /** Merge list of volumes into new file. 191 * 192 * @param volumes List of volumes 193 * @param cfg_path Path to file containing configuration repository in SIF 194 * @return EOK on success, ENOMEM if out of memory 195 */ 196 errno_t vol_volumes_merge_to(vol_volumes_t *volumes, const char *cfg_path) 197 { 198 sif_doc_t *doc = NULL; 199 sif_node_t *node; 200 const char *ntype; 201 char *dcfg_path; 202 errno_t rc; 203 204 dcfg_path = str_dup(cfg_path); 205 if (dcfg_path == NULL) { 206 rc = ENOMEM; 207 goto error; 208 } 209 210 free(volumes->cfg_path); 211 volumes->cfg_path = dcfg_path; 212 213 /* Try opening existing repository */ 214 rc = sif_load(cfg_path, &doc); 215 if (rc != EOK) { 216 /* Failed to open existing, create new repository */ 217 rc = vol_volumes_sync(volumes); 218 if (rc != EOK) 219 goto error; 220 } else { 221 /* 222 * Loaded existing configuration. Find 'volumes' node, should 223 * be the first child of the root node. 224 */ 225 node = sif_node_first_child(sif_get_root(doc)); 226 227 /* Verify it's the correct node type */ 228 ntype = sif_node_get_type(node); 229 if (str_cmp(ntype, "volumes") != 0) { 230 rc = EIO; 231 goto error; 232 } 233 234 rc = vol_volumes_load(node, volumes); 235 if (rc != EOK) 236 goto error; 237 238 sif_delete(doc); 239 } 240 241 return EOK; 242 error: 243 if (doc != NULL) 244 (void) sif_delete(doc); 187 245 return rc; 188 246 }
Note:
See TracChangeset
for help on using the changeset viewer.