device_delete () Remove subdevices for eg. partitions
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 35s
Build documentation / build-and-deploy (push) Successful in 1m11s

This commit is contained in:
2026-04-07 21:55:37 +02:00
parent 7091b128df
commit 87ccdbc6cb
2 changed files with 29 additions and 2 deletions

View File

@@ -113,8 +113,35 @@ void device_delete (const char* key, struct proc* proc, struct reschedule_ctx* r
struct device* device = hash_entry (delete_link, struct device, device_table_link);
if (device != NULL)
if (device != NULL) {
/* Check for "subdevices", for eg. partition devices */
for (size_t i = 0; i < lengthof (device_table.device_buckets); i++) {
struct hash_node_link* hash_node = device_table.device_buckets[i];
while (hash_node != NULL) {
struct device* dev = hash_entry (hash_node, struct device, device_table_link);
hash_node = hash_node->next;
if (memcmp (dev->key, device->key, strlen (device->key)) == 0) {
struct hash_node_link* dev_delete_link;
size_t dev_key_len = strlen_null (dev->key);
uint32_t dev_hash = hash_fnv32 (dev->key, dev_key_len);
hash_delete (&device_table, dev->key, strlen_null (dev->key), dev_hash,
lengthof (device_table.device_buckets), device_buckets, struct device,
device_table_link, key, dev_delete_link);
dev->fini (dev, proc, rctx);
free (dev);
}
}
}
device->fini (device, proc, rctx);
free (device);
}
spin_unlock (&device_table.lock, fdt);
}

View File

@@ -52,7 +52,7 @@ static void usb_eject (const char* dev_key) {
if (strcmp (info->device_key, dev_key) == 0) {
int ret = volume_delete (info->volume_name);
mprintf ("Deleted volume %s: %s", info->volume_name, str_status[ret < 0 ? -ret : ret]);
mprintf ("Deleted volume %s: %s\n", info->volume_name, str_status[ret < 0 ? -ret : ret]);
break;
}
}