提交 801ebb5e 编写于 作者: J Ján Tomko

util: introduce readonly attribute to virPCIDeviceConfigOpenInternal

Allow wrappers to open PCI config as read-only.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 fabb7430
......@@ -291,11 +291,11 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name)
static int
virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal)
virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool readonly, bool fatal)
{
int fd;
fd = open(dev->path, O_RDWR);
fd = open(dev->path, readonly ? O_RDONLY : O_RDWR);
if (fd < 0) {
if (fatal) {
......@@ -317,13 +317,13 @@ virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal)
static int
virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal)
{
return virPCIDeviceConfigOpenInternal(dev, fatal);
return virPCIDeviceConfigOpenInternal(dev, false, fatal);
}
static int
virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev)
{
return virPCIDeviceConfigOpenInternal(dev, true);
return virPCIDeviceConfigOpenInternal(dev, false, true);
}
static void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册