提交 d2658a36 编写于 作者: 指向BIOS的野指针's avatar 指向BIOS的野指针

add achievement of the two getters

上级 5a2bc0c8
......@@ -25,7 +25,7 @@ namespace bwl
* @param pgid
* @return void*
*/
void *getPage(id_t pgid);
__page *getPage(id_t pgid);
/**
* @brief 获得一个窗口
......@@ -33,7 +33,7 @@ namespace bwl
* @param fid
* @return void*
*/
void *getFrame(id_t fid);
__frame *getFrame(id_t fid);
};
......
#define __bwl_server
#include "../includes/bsv.hh"
#include "../dbg/logs.hh"
......
#define __bwl_server
#define __bwl_client
#include "../includes/bwl.hh"
#include "../includes/pipe.hh"
......@@ -31,6 +31,9 @@ namespace std
namespace bwl
{
std::string monitor_device;
namespace bad_wayland_server
{
pid_t server_pid;
......@@ -40,6 +43,7 @@ namespace bwl
void initBadWayland(std::string __monitor_device)
{
monitor_device = __monitor_device;
std::fstream host(BWLDIR + "/host", std::ios::in);
if (!host.good())
{
......@@ -208,13 +212,34 @@ namespace bwl
return bad_wayland_server::pix_depth;
}
// TODO这两个getter没有实现
void *getPage(id_t pgid)
__page *getPage(id_t pgid)
{
int shmf = std::shm_open((SHMPAGEDIR + std::to_string(pgid) + "_shm").c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (shmf == -1)
{
return CREATE_PAGE_FAULT;
}
__page *page = (__page *)std::mmap(nullptr, sizeof(__page), PROT_READ, MAP_SHARED, shmf, 0);
std::close(shmf);
return page;
}
void *getFrame(id_t fid)
__frame *getFrame(id_t fid)
{
//映射数据
int shmf = std::shm_open((SHMFRMDIR + std::to_string(fid) + "_shm").c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (shmf == -1)
{
return CREATE_FRAME_FAULT;
}
__frame *frame = (__frame *)std::mmap(nullptr, sizeof(__frame),
PROT_READ, MAP_SHARED, shmf, 0);
int namelen = frame->namelen;
std::munmap(frame, sizeof(__frame));
frame = (__frame *)std::mmap(nullptr, sizeof(__frame) + namelen + 1,
PROT_READ, MAP_SHARED, shmf, 0);
std::close(shmf);
return frame;
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册