提交 f42b5c32 编写于 作者: P Peter Krempa

util: cgroup: Instrument virCgroupDenyDevice to handle -1 device number as *

Similarly to commit 47e5b5ae virCgroupDenyDevice will handle -1 as *.
上级 23087cfd
...@@ -3056,8 +3056,8 @@ virCgroupAllowDevicePath(virCgroupPtr group, const char *path, int perms) ...@@ -3056,8 +3056,8 @@ virCgroupAllowDevicePath(virCgroupPtr group, const char *path, int perms)
* *
* @group: The cgroup to deny a device for * @group: The cgroup to deny a device for
* @type: The device type (i.e., 'c' or 'b') * @type: The device type (i.e., 'c' or 'b')
* @major: The major number of the device * @major: The major number of the device, a negative value means '*'
* @minor: The minor number of the device * @minor: The minor number of the device, a negative value means '*'
* @perms: Bitwise or of VIR_CGROUP_DEVICE permission bits to deny * @perms: Bitwise or of VIR_CGROUP_DEVICE permission bits to deny
* *
* Returns: 0 on success * Returns: 0 on success
...@@ -3068,8 +3068,18 @@ virCgroupDenyDevice(virCgroupPtr group, char type, int major, int minor, ...@@ -3068,8 +3068,18 @@ virCgroupDenyDevice(virCgroupPtr group, char type, int major, int minor,
{ {
int ret = -1; int ret = -1;
char *devstr = NULL; char *devstr = NULL;
char *majorstr = NULL;
char *minorstr = NULL;
if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) ||
(major >= 0 && virAsprintf(&majorstr, "%i", major) < 0))
goto cleanup;
if (virAsprintf(&devstr, "%c %i:%i %s", type, major, minor, if ((minor < 0 && VIR_STRDUP(minorstr, "*") < 0) ||
(minor >= 0 && virAsprintf(&minorstr, "%i", minor) < 0))
goto cleanup;
if (virAsprintf(&devstr, "%c %s:%s %s", type, majorstr, minorstr,
virCgroupGetDevicePermsString(perms)) < 0) virCgroupGetDevicePermsString(perms)) < 0)
goto cleanup; goto cleanup;
...@@ -3083,6 +3093,8 @@ virCgroupDenyDevice(virCgroupPtr group, char type, int major, int minor, ...@@ -3083,6 +3093,8 @@ virCgroupDenyDevice(virCgroupPtr group, char type, int major, int minor,
cleanup: cleanup:
VIR_FREE(devstr); VIR_FREE(devstr);
VIR_FREE(majorstr);
VIR_FREE(minorstr);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册