Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
9ef45b43
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9ef45b43
编写于
4月 12, 2017
作者:
T
Thomas Voß
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Report errors if loopback device creation fails
上级
d8612d3e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
10 deletion
+20
-10
src/anbox/cmds/container_manager.cpp
src/anbox/cmds/container_manager.cpp
+10
-2
src/anbox/common/loop_device.cpp
src/anbox/common/loop_device.cpp
+4
-1
src/anbox/common/loop_device_allocator.cpp
src/anbox/common/loop_device_allocator.cpp
+6
-7
未找到文件。
src/anbox/cmds/container_manager.cpp
浏览文件 @
9ef45b43
...
...
@@ -100,9 +100,17 @@ bool anbox::cmds::ContainerManager::setup_mounts() {
if
(
!
fs
::
exists
(
android_rootfs_dir
))
fs
::
create_directory
(
android_rootfs_dir
);
auto
loop_device
=
common
::
LoopDeviceAllocator
::
new_device
();
if
(
!
loop_device
)
std
::
shared_ptr
<
common
::
LoopDevice
>
loop_device
;
try
{
loop_device
=
common
::
LoopDeviceAllocator
::
new_device
();
}
catch
(
const
std
::
exception
&
e
)
{
ERROR
(
"Could not create loopback device: %s"
,
e
.
what
());
return
false
;
}
catch
(...)
{
ERROR
(
"Could not create loopback device"
);
return
false
;
}
if
(
!
loop_device
->
attach_file
(
android_img_path
))
{
ERROR
(
"Failed to attach Android rootfs image to loopback device"
);
...
...
src/anbox/common/loop_device.cpp
浏览文件 @
9ef45b43
...
...
@@ -18,7 +18,10 @@
#include "anbox/common/loop_device.h"
#include "anbox/defer_action.h"
#include <system_error>
#include <linux/loop.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
...
...
@@ -27,7 +30,7 @@ namespace common {
std
::
shared_ptr
<
LoopDevice
>
LoopDevice
::
create
(
const
boost
::
filesystem
::
path
&
path
)
{
const
auto
fd
=
::
open
(
path
.
c_str
(),
O_RDWR
);
if
(
fd
<
0
)
return
nullptr
;
throw
std
::
system_error
{
errno
,
std
::
system_category
()}
;
return
std
::
shared_ptr
<
LoopDevice
>
(
new
LoopDevice
(
Fd
{
fd
},
path
));
}
...
...
src/anbox/common/loop_device_allocator.cpp
浏览文件 @
9ef45b43
...
...
@@ -23,9 +23,12 @@
#include <boost/filesystem.hpp>
#include <linux/loop.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <system_error>
namespace
fs
=
boost
::
filesystem
;
namespace
{
...
...
@@ -38,19 +41,15 @@ namespace common {
std
::
shared_ptr
<
LoopDevice
>
LoopDeviceAllocator
::
new_device
()
{
const
auto
ctl_fd
=
::
open
(
loop_control_path
,
O_RDWR
);
if
(
ctl_fd
<
0
)
return
nullptr
;
throw
std
::
system_error
{
errno
,
std
::
system_category
()}
;
DeferAction
close_ctl_fd
{[
&
]()
{
::
close
(
ctl_fd
);
}};
const
auto
device_nr
=
::
ioctl
(
ctl_fd
,
LOOP_CTL_GET_FREE
);
if
(
device_nr
<
0
)
return
nullptr
;
const
auto
path
=
utils
::
string_format
(
"%s%d"
,
base_loop_path
,
device_nr
);
if
(
!
fs
::
exists
(
path
))
return
nullptr
;
throw
std
::
system_error
{
errno
,
std
::
system_category
()};
return
LoopDevice
::
create
(
path
);
return
LoopDevice
::
create
(
utils
::
string_format
(
"%s%d"
,
base_loop_path
,
device_nr
)
);
}
}
// namespace common
}
// namespace anbox
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录