Lines Matching refs:fd
67 static inline int32_t read_int32(borrowed_fd fd) { in read_int32() argument
69 return ReadFdExactly(fd, &result, sizeof(result)) ? result : -1; in read_int32()
72 static inline int32_t skip_int(borrowed_fd fd) { in skip_int() argument
73 return adb_lseek(fd, 4, SEEK_CUR); in skip_int()
76 static inline void append_int(borrowed_fd fd, std::vector<char>* bytes) { in append_int() argument
77 int32_t le_val = read_int32(fd); in append_int()
83 static inline bool append_bytes_with_size(borrowed_fd fd, std::vector<char>* bytes, in append_bytes_with_size() argument
85 int32_t le_size = read_int32(fd); in append_bytes_with_size()
100 ReadFdExactly(fd, bytes->data() + old_size + sizeof(le_size), size); in append_bytes_with_size()
104 static inline int32_t skip_bytes_with_size(borrowed_fd fd) { in skip_bytes_with_size() argument
105 int32_t le_size = read_int32(fd); in skip_bytes_with_size()
110 return (int32_t)adb_lseek(fd, size, SEEK_CUR); in skip_bytes_with_size()
113 std::pair<std::vector<char>, int32_t> read_id_sig_headers(borrowed_fd fd) { in read_id_sig_headers() argument
115 append_int(fd, &signature); // version in read_id_sig_headers()
118 if (!append_bytes_with_size(fd, &signature, &max_size) || in read_id_sig_headers()
119 !append_bytes_with_size(fd, &signature, &max_size)) { in read_id_sig_headers()
122 auto le_tree_size = read_int32(fd); in read_id_sig_headers()
127 std::pair<off64_t, ssize_t> skip_id_sig_headers(borrowed_fd fd) { in skip_id_sig_headers() argument
128 skip_int(fd); // version in skip_id_sig_headers()
129 skip_bytes_with_size(fd); // hashingInfo in skip_id_sig_headers()
130 auto offset = skip_bytes_with_size(fd); // signingInfo in skip_id_sig_headers()
131 auto le_tree_size = read_int32(fd); in skip_id_sig_headers()
137 static T valueAt(borrowed_fd fd, off64_t offset) { in valueAt() argument
140 if (adb_pread(fd, &t, sizeof(T), offset) != sizeof(T)) { in valueAt()
165 static off64_t CentralDirOffset(borrowed_fd fd, Size fileSize) { in CentralDirOffset() argument
178 sigBuf = valueAt<int32_t>(fd, maxEocdOffset - commentLen); in CentralDirOffset()
181 fd, maxEocdOffset - commentLen + kZipEocdCommentLengthFieldOffset); in CentralDirOffset()
194 valueAt<int32_t>(fd, eocdOffset + kZipEocdCentralDirSizeFieldOffset)); in CentralDirOffset()
200 static off64_t SignerBlockOffset(borrowed_fd fd, Size fileSize) { in SignerBlockOffset() argument
206 off64_t cdOffset = CentralDirOffset(fd, fileSize); in SignerBlockOffset()
212 valueAt<int64_t>(fd, cdOffset - 2 * sizeof(int64_t)) != APK_SIG_BLOCK_MAGIC_LO || in SignerBlockOffset()
213 valueAt<int64_t>(fd, cdOffset - sizeof(int64_t)) != APK_SIG_BLOCK_MAGIC_HI) { in SignerBlockOffset()
216 int32_t signerSizeInFooter = valueAt<int32_t>(fd, cdOffset - kApkSigBlockFooterSize); in SignerBlockOffset()
221 int32_t signerSizeInHeader = valueAt<int32_t>(fd, signerBlockOffset); in SignerBlockOffset()
257 [[maybe_unused]] static ZipArchiveHandle openZipArchiveFd(borrowed_fd fd) { in openZipArchiveFd() argument
269 auto handle = adb_get_os_handle(fd); in openZipArchiveFd()
284 int osfd = fd.get(); in openZipArchiveFd()
299 borrowed_fd fd, Size fileSize) { in openZipArchive() argument
302 return {openZipArchiveFd(fd), nullptr}; in openZipArchive()
306 android::base::MappedFile::FromOsHandle(adb_get_os_handle(fd), 0, fileSize, PROT_READ); in openZipArchive()
319 static std::vector<int32_t> InstallationPriorityBlocks(borrowed_fd fd, Size fileSize) { in InstallationPriorityBlocks() argument
322 auto [zip, _] = openZipArchive(fd, fileSize); in InstallationPriorityBlocks()
373 std::vector<int32_t> PriorityBlocksForFile(const std::string& filepath, borrowed_fd fd, in PriorityBlocksForFile() argument
378 off64_t signerOffset = SignerBlockOffset(fd, fileSize); in PriorityBlocksForFile()
384 std::vector<int32_t> installationPriorityBlocks = InstallationPriorityBlocks(fd, fileSize); in PriorityBlocksForFile()