2
* Copyright (C) 2000-2006 SWsoft. All rights reserved.
2
* Copyright (C) 2000-2007 SWsoft. All rights reserved.
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
50
50
snprintf(buf1, sizeof(buf1), "%s/dev/%s", root, dev->name);
51
51
ret = lstat(buf1, &st);
52
52
if (ret && errno != ENOENT) {
53
logger(0, errno, "Unable to stat device %s", buf1);
53
logger(-1, errno, "Unable to stat device %s", buf1);
54
54
return VZ_SET_DEVICES;
57
57
snprintf(buf2, sizeof(buf2), "/dev/%s", dev->name);
58
58
if (lstat(buf2, &st)) {
59
59
if (errno == ENOENT)
60
logger(0, 0, "Incorrect name or no such device %s",
60
logger(-1, 0, "Incorrect name or no such device %s",
63
logger(0, errno, "Unable to stat device %s", buf2);
63
logger(-1, errno, "Unable to stat device %s", buf2);
64
64
return VZ_SET_DEVICES;
66
66
if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode)) {
67
logger(0, 0, "The %s is not block or character device", buf2);
67
logger(-1, 0, "The %s is not block or character device", buf2);
68
68
return VZ_SET_DEVICES;
70
70
if (make_dir(buf1, 0))
71
71
return VZ_SET_DEVICES;
72
72
if (mknod(buf1, st.st_mode, st.st_rdev)) {
73
logger(0, errno, "Unable to create device %s", buf1);
73
logger(-1, errno, "Unable to create device %s", buf1);
74
74
return VZ_SET_DEVICES;
87
87
devperms.type = dev->type;
89
89
if ((ret = ioctl(h->vzfd, VZCTL_SETDEVPERMS, &devperms)))
90
logger(0, errno, "Unable to set devperms");
90
logger(-1, errno, "Unable to set devperms");
95
/** Allow/disallow access to devices on host system from VPS.
95
/** Allow/disallow access to devices on host system from VE.
97
* @param h VPS handler.
99
* @param root VPS root.
97
* @param h VE handler.
99
* @param root VE root.
100
100
* @param dev devices list.
101
101
* @return 0 on success.
109
109
if (list_empty(dev_h))
111
111
if (!vps_is_run(h, veid)) {
112
logger(0, 0, "Unable to apply devperm: VPS is not running");
112
logger(-1, 0, "Unable to apply devperm: VE is not running");
113
113
return VZ_VE_NOT_RUNNING;
115
115
logger(0, 0, "Setting devices");