mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-25 06:10:20 +08:00
Match-id-e09f4bfabe86ff28154841143128cab741c4e76a
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#define MAX_DEVICE_NR 1024
|
||||
#define MAX_MOUNT_NR 512
|
||||
|
||||
#define LOG(level, fmt, ...) \
|
||||
#define LOG_ERROR(fmt, ...) \
|
||||
do { \
|
||||
char _content[BUF_SIZE] = {0}; \
|
||||
int _ret = sprintf_s(_content, BUF_SIZE, fmt, ##__VA_ARGS__); \
|
||||
@@ -29,8 +29,6 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_ERROR(fmt, ...) LOG('E', fmt, ##__VA_ARGS__)
|
||||
|
||||
#define ALLOW_PATH "/devices.allow"
|
||||
#define ROOT_GAP 4
|
||||
#define FSTYPE_GAP 2
|
||||
|
||||
@@ -96,6 +96,19 @@ int MountDevice(const char *rootfs, const char *deviceName)
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
struct stat dstStat;
|
||||
ret = stat((const char *)dst, &dstStat);
|
||||
if (ret == 0 && S_ISCHR(dstStat.st_mode)) {
|
||||
return 0; // 特权容器自动挂载HOST所有设备,故此处跳过
|
||||
} else if (ret == 0) {
|
||||
LOG_ERROR("error: %s already exists but not a char device as expected.", dst);
|
||||
return -1;
|
||||
} else if (ret < 0 && errno != ENOENT) {
|
||||
LOG_ERROR("error: failed to check dst %s stat: %s.", dst, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = CreateFile(dst, srcStat.st_mode);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR("error: failed to create mount dst file: %s.", dst);
|
||||
|
||||
Reference in New Issue
Block a user