Previously, the devfs entry for each virtio-fs device was derived from
virtio::virtio_driver::_disk_idx, which is used by virtio-blk and
virtio-scsi, which anyway share a devfs namespace. This introduced
unnecessary complexity, since e.g. changing the number of virtio-blk
devices could introduce a shift in the naming of virtio-fs devices.

This switches virtio-fs to using a separate, exclusive id. The logic
behind the devfs name (i.e. virtiofs-<instance>) remains the same.

Signed-off-by: Fotis Xenakis <[email protected]>
---
 drivers/virtio-fs.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio-fs.cc b/drivers/virtio-fs.cc
index 00f862a1..a8a81265 100644
--- a/drivers/virtio-fs.cc
+++ b/drivers/virtio-fs.cc
@@ -131,10 +131,14 @@ fs::fs(virtio_device& virtio_dev)
     // Step 8
     add_dev_status(VIRTIO_CONFIG_S_DRIVER_OK);
 
+    // TODO: Don't ignore the virtio-fs tag and use that instead of _id for
+    // identifying the device (e.g. something like /dev/virtiofs/<tag> or at
+    // least /dev/virtiofs-<tag> would be nice, but devfs does not support
+    // nested directories or device names > 12). Linux does not create a devfs
+    // entry and instead uses the virtio-fs tag passed to mount directly.
     std::string dev_name("virtiofs");
-    dev_name += std::to_string(_disk_idx++);
-
-    struct device* dev = device_create(&fs_driver, dev_name.c_str(), D_BLK); 
// TODO Should it be really D_BLK?
+    dev_name += std::to_string(_id);
+    struct device* dev = device_create(&fs_driver, dev_name.c_str(), D_BLK);
     dev->private_data = this;
     debugf("virtio-fs: Add device instance %d as [%s]\n", _id,
         dev_name.c_str());
-- 
2.28.0

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/AM0PR03MB6292CF9F494991191B18CABAA65D0%40AM0PR03MB6292.eurprd03.prod.outlook.com.

Reply via email to