Lines Matching defs:fd

57 static int writeDependencies(int fd, u4 modWhen, u4 crc);
58 static bool writeOptData(int fd, const DexClassLookup* pClassLookup,\
60 static bool computeFileChecksum(int fd, off_t start, size_t length, u4* pSum);
107 * Return the fd of an open file in the DEX file cache area. If the cache
132 int fd, cc;
143 fd = createIfMissing ? open(cacheFileName, O_CREAT|O_RDWR, 0644) : -1;
144 if (fd < 0) {
145 fd = open(cacheFileName, O_RDONLY, 0);
146 if (fd < 0) {
154 return fd;
158 fchmod(fd, 0644);
166 ALOGV("DexOpt: locking cache file %s (fd=%d, boot=%d)",
167 cacheFileName, fd, isBootstrap);
169 cc = flock(fd, LOCK_EX | LOCK_NB);
172 cc = flock(fd, LOCK_EX);
177 close(fd);
183 * Check to see if the fd we opened and locked matches the file in
189 cc = fstat(fd, &fdStat);
201 flock(fd, LOCK_UN);
202 close(fd);
219 cc = dexOptCreateEmptyHeader(fd);
247 if (!dvmCheckOptHeaderAndDependencies(fd, true, modWhen, crc,
287 if (ftruncate(fd, 0) != 0) {
298 flock(fd, LOCK_UN);
299 close(fd);
306 assert(fd >= 0);
307 return fd;
310 flock(fd, LOCK_UN);
311 close(fd);
320 bool dvmUnlockCachedDexFile(int fd)
322 LOGVV("DexOpt: unlocking cache file fd=%d", fd);
323 return (flock(fd, LOCK_UN) == 0);
331 * The file pointed to by "fd" is expected to be a locked shared resource
349 * Returns "true" on success. All data will have been written to "fd".
351 bool dvmOptimizeDexFile(int fd, off_t dexOffset, long dexLength,
424 sprintf(values[3], "%d", fd);
527 bool dvmContinueOptimization(int fd, off_t dexOffset, long dexLength,
567 MAP_SHARED, fd, 0);
660 depsOffset = lseek(fd, 0, SEEK_END);
670 lseek(fd, depsOffset, SEEK_SET);
676 if (writeDependencies(fd, modWhen, crc) != 0) {
682 optOffset = lseek(fd, 0, SEEK_END);
690 lseek(fd, optOffset, SEEK_SET);
696 if (!writeOptData(fd, pClassLookup, pRegMapBuilder)) {
701 endOffset = lseek(fd, 0, SEEK_END);
705 if (!computeFileChecksum(fd, depsOffset,
732 fsync(fd); /* ensure previous writes go before header is written */
734 lseek(fd, 0, SEEK_SET);
735 if (sysWriteFully(fd, &optHdr, sizeof(optHdr), "DexOpt opt header") != 0)
1170 bool dvmCheckOptHeaderAndDependencies(int fd, bool sourceAvail, u4 modWhen,
1184 if (lseek(fd, 0, SEEK_SET) != 0) {
1193 actual = read(fd, &optHdr, sizeof(optHdr));
1242 posn = lseek(fd, optHdr.depsOffset, SEEK_SET);
1257 actual = read(fd, depData, optHdr.depsLength);
1359 * Write the dependency info to "fd" at the current file position.
1361 static int writeDependencies(int fd, u4 modWhen, u4 crc)
1422 result = sysWriteFully(fd, buf, bufLen, "DexOpt dep info");
1435 static bool writeChunk(int fd, u4 type, const void* data, size_t size)
1451 if (sysWriteFully(fd, &header, sizeof(header),
1458 if (sysWriteFully(fd, data, size, "DexOpt opt chunk write") != 0)
1466 lseek(fd, padSize, SEEK_CUR);
1469 assert( ((int)lseek(fd, 0, SEEK_CUR) & 7) == 0);
1482 static bool writeOptData(int fd, const DexClassLookup* pClassLookup,
1486 if (!writeChunk(fd, (u4) kDexChunkClassLookup,
1494 if (!writeChunk(fd, (u4) kDexChunkRegisterMaps,
1502 if (!writeChunk(fd, (u4) kDexChunkEnd, NULL, 0)) {
1516 static bool computeFileChecksum(int fd, off_t start, size_t length, u4* pSum)
1522 if (lseek(fd, start, SEEK_SET) != start) {
1532 actual = read(fd, readBuf, wanted);