mirror of
				https://github.com/Ascend/ascend-docker-runtime.git
				synced 2025-10-31 20:12:45 +08:00 
			
		
		
		
	Match-id-c6cbeee5e47608c24c4301878b5f1acceddee981
This commit is contained in:
		| @@ -73,9 +73,7 @@ int ParseFileByLine(char* buffer, int bufferSize, const ParseFileLine fn, const | |||||||
|     char resolvedPath[PATH_MAX] = {0x0}; |     char resolvedPath[PATH_MAX] = {0x0}; | ||||||
|  |  | ||||||
|     if (realpath(filepath, resolvedPath) == NULL && errno != ENOENT) { |     if (realpath(filepath, resolvedPath) == NULL && errno != ENOENT) { | ||||||
|         char* str = FormatLogMessage("cannot canonicalize path %s.", filepath); |         Logger("Cannot canonicalize path.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|     if (CheckLegality(resolvedPath) != 0) { |     if (CheckLegality(resolvedPath) != 0) { | ||||||
| @@ -170,9 +168,7 @@ int SetupDeviceCgroup(FILE *cgroupAllow, const char *devName) | |||||||
|  |  | ||||||
|     ret = stat((const char *)devPath, &devStat); |     ret = stat((const char *)devPath, &devStat); | ||||||
|     if (ret < 0) { |     if (ret < 0) { | ||||||
|         char* str = FormatLogMessage("failed to get stat of %s.", devPath); |         Logger("Failed to get stat of devpath.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -275,7 +271,6 @@ int SetupCgroup(const struct ParsedConfig *config) | |||||||
|  |  | ||||||
|     if (realpath(config->cgroupPath, resolvedCgroupPath) == NULL && errno != ENOENT) { |     if (realpath(config->cgroupPath, resolvedCgroupPath) == NULL && errno != ENOENT) { | ||||||
|         Logger("cannot canonicalize cgroup.", LEVEL_ERROR, SCREEN_YES); |         Logger("cannot canonicalize cgroup.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|     if (CheckLegality(resolvedCgroupPath) != 0) { |     if (CheckLegality(resolvedCgroupPath) != 0) { | ||||||
| @@ -285,7 +280,6 @@ int SetupCgroup(const struct ParsedConfig *config) | |||||||
|     cgroupAllow = fopen((const char *)resolvedCgroupPath, "a"); |     cgroupAllow = fopen((const char *)resolvedCgroupPath, "a"); | ||||||
|     if (cgroupAllow == NULL) { |     if (cgroupAllow == NULL) { | ||||||
|         Logger("failed to open cgroup file.", LEVEL_ERROR, SCREEN_YES); |         Logger("failed to open cgroup file.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -311,7 +305,6 @@ int SetupCgroup(const struct ParsedConfig *config) | |||||||
|         if (ret < 0) { |         if (ret < 0) { | ||||||
|             fclose(cgroupAllow); |             fclose(cgroupAllow); | ||||||
|             Logger("failed to setup cgroup.", LEVEL_ERROR, SCREEN_YES); |             Logger("failed to setup cgroup.", LEVEL_ERROR, SCREEN_YES); | ||||||
|             free(str); |  | ||||||
|             return -1; |             return -1; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -44,17 +44,13 @@ int EnterNsByPath(const char *path, int nsType) | |||||||
|  |  | ||||||
|     fd = open(path, O_RDONLY); // proc文件接口,非外部输入 |     fd = open(path, O_RDONLY); // proc文件接口,非外部输入 | ||||||
|     if (fd < 0) { |     if (fd < 0) { | ||||||
|         char* str = FormatLogMessage("failed to open ns path: %s.", path); |         Logger("Failed to open ns path.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ret = EnterNsByFd(fd, nsType); |     ret = EnterNsByFd(fd, nsType); | ||||||
|     if (ret < 0) { |     if (ret < 0) { | ||||||
|         char* str = FormatLogMessage("failed to set ns: %s.", path); |         Logger("failed to set ns.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         close(fd); |         close(fd); | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -128,25 +128,19 @@ int MakeMountPoints(const char *path, mode_t mode) | |||||||
|  |  | ||||||
|     int ret = MakeDirWithParent(parentDir, DEFAULT_DIR_MODE); |     int ret = MakeDirWithParent(parentDir, DEFAULT_DIR_MODE); | ||||||
|     if (ret < 0) { |     if (ret < 0) { | ||||||
|         char* str = FormatLogMessage("failed to make parent dir for file: %s", path); |         Logger("Failed to make parent dir for file.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     char resolvedPath[PATH_MAX] = {0}; |     char resolvedPath[PATH_MAX] = {0}; | ||||||
|     if (realpath(path, resolvedPath) == NULL && errno != ENOENT) { |     if (realpath(path, resolvedPath) == NULL && errno != ENOENT) { | ||||||
|         char* str = FormatLogMessage("failed to resolve path %s.", path); |         Logger("failed to resolve path.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     int fd = open(resolvedPath, O_NOFOLLOW | O_CREAT, mode); |     int fd = open(resolvedPath, O_NOFOLLOW | O_CREAT, mode); | ||||||
|     if (fd < 0) { |     if (fd < 0) { | ||||||
|         char* str = FormatLogMessage("cannot create file: %s.", resolvedPath); |         Logger("cannot create file.", LEVEL_ERROR, SCREEN_YES); | ||||||
|         Logger(str, LEVEL_ERROR, SCREEN_YES); |  | ||||||
|         free(str); |  | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|     close(fd); |     close(fd); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 BianTanggui
					BianTanggui