| 1025 | |
| 1026 | |
| 1027 | FileInfo createFileInfo(const string& path, const struct stat& s) |
| 1028 | { |
| 1029 | FileInfo file; |
| 1030 | file.set_path(path); |
| 1031 | file.set_nlink(s.st_nlink); |
| 1032 | file.set_size(s.st_size); |
| 1033 | file.mutable_mtime()->set_nanoseconds(Seconds((s.st_mtime)).ns()); |
| 1034 | file.set_mode(s.st_mode); |
| 1035 | |
| 1036 | // NOTE: `getpwuid` and `getgrgid` return `nullptr` on Windows. |
| 1037 | passwd* p = getpwuid(s.st_uid); |
| 1038 | if (p != nullptr) { |
| 1039 | file.set_uid(p->pw_name); |
| 1040 | } else { |
| 1041 | file.set_uid(stringify(s.st_uid)); |
| 1042 | } |
| 1043 | |
| 1044 | struct group* g = getgrgid(s.st_gid); |
| 1045 | if (g != nullptr) { |
| 1046 | file.set_gid(g->gr_name); |
| 1047 | } else { |
| 1048 | file.set_gid(stringify(s.st_gid)); |
| 1049 | } |
| 1050 | |
| 1051 | return file; |
| 1052 | } |
| 1053 | |
| 1054 | |
| 1055 | ContainerID getRootContainerId(const ContainerID& containerId) |