Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions images/raw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <unistd.h>
#include <sys/stat.h>
#include <filesystem>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/fs.h>


#include "logger.h"
#include "device_manager.h"
Expand Down Expand Up @@ -59,15 +63,17 @@ class RawImage : public DiskImage {
std::filesystem::copy_file(filepath_, temp, std::filesystem::copy_options::overwrite_existing);
filepath_ = temp;
}

fd_ = open(filepath_.c_str(), oflags);
if (fd_ < 0)
MV_PANIC("disk file not found: %s", filepath_.c_str());

struct stat st;
fstat(fd_, &st);
block_size_ = 512;
total_blocks_ = st.st_size / block_size_;
long long size_blockdevice;
if(ioctl(fd_,BLKGETSIZE64,&size_blockdevice)!=-1) {
total_blocks_ = size_blockdevice / block_size_;
block_size_ = 512;
total_blocks_ = size_blockdevice / block_size_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated code?

} else {
MV_PANIC("ioctl failed");
}
}

long HandleIoRequest(const ImageIoRequest& request) {
Expand Down
3 changes: 2 additions & 1 deletion main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ int main(int argc, char* argv[]) {
}

const char* displayVar = std::getenv("DISPLAY");
if (displayVar == nullptr) {
const char* waylandVar = std::getenv("WAYLAND_DISPLAY");
if (displayVar == nullptr && waylandVar == nullptr) {
if (vnc_port == 0) {
vnc_port = 5901;
}
Expand Down
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ project('mvisor', 'c', 'cpp',
license: 'GPLv3',
default_options: [
'buildtype=debugoptimized',
'warning_level=2',
'cpp_std=c++17',
'werror=true'
]
)

Expand Down