Skip to content

diff code to enable blockdevice ( /dev/xxx) #63

@limbo127

Description

@limbo127

blockdevice is like raw image, we just need to change the size calculation

--- tmp/mvisor/images/raw.cc 2024-10-28 12:01:10.003886443 +0100
+++ images/raw.cc 2024-10-28 13:38:35.627238165 +0100
@@ -26,6 +26,9 @@

#include "logger.h"
#include "device_manager.h"
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <linux/fs.h>

class RawImage : public DiskImage {
private:
@@ -64,10 +67,14 @@
if (fd_ < 0)
MV_PANIC("disk file not found: %s", filepath_.c_str());

  • long long size_;
    struct stat st;
    fstat(fd_, &st);
    block_size_ = 512;
    total_blocks_ = st.st_size / block_size_;

  • if(ioctl(fd_,BLKGETSIZE64,&size_)!=-1)
    
  •    total_blocks_ = size_ / block_size_;
    
  • }

    long HandleIoRequest(const ImageIoRequest& request) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions