Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
limbo127 opened this issue Oct 28, 2024 · 1 comment
Closed

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

limbo127 opened this issue Oct 28, 2024 · 1 comment

Comments

@limbo127
Copy link

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) {

@limbo127
Copy link
Author

close by pull request submit #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant