diff --git a/utils/self-extracting-executable/decompressor.cpp b/utils/self-extracting-executable/decompressor.cpp index be25d315d68..cd9cc51c45b 100644 --- a/utils/self-extracting-executable/decompressor.cpp +++ b/utils/self-extracting-executable/decompressor.cpp @@ -363,7 +363,7 @@ int decompressFiles(int input_fd, char * path, char * name, bool & have_compress #if !defined(OS_DARWIN) && !defined(OS_FREEBSD) -uint32_t getInode(const char * self) +uint64_t getInode(const char * self) { std::ifstream maps("/proc/self/maps"); if (maps.fail()) @@ -380,7 +380,7 @@ uint32_t getInode(const char * self) { std::stringstream ss(line); // STYLE_CHECK_ALLOW_STD_STRING_STREAM std::string addr, mode, offset, id, path; - uint32_t inode = 0; + uint64_t inode = 0; if (ss >> addr >> mode >> offset >> id >> inode >> path && path == self) return inode; } @@ -415,7 +415,7 @@ int main(int/* argc*/, char* argv[]) #if !defined(OS_DARWIN) && !defined(OS_FREEBSD) /// get inode of this executable - uint32_t inode = getInode(self); + uint64_t inode = getInode(self); if (inode == 0) { std::cerr << "Unable to obtain inode." << std::endl; @@ -447,6 +447,11 @@ int main(int/* argc*/, char* argv[]) return 1; } + /// inconsistency in WSL1 Ubuntu - inode reported in /proc/self/maps is a 64bit to + /// 32bit conversion of input_info.st_ino + if (input_info.st_ino & 0xFFFFFFFF00000000 && !(inode & 0xFFFFFFFF00000000)) + input_info.st_ino &= 0x00000000FFFFFFFF; + /// if decompression was performed by another process since this copy was started /// then file referred by path "self" is already pointing to different inode if (input_info.st_ino != inode)