Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fcaa972 authored by Michael Gernoth's avatar Michael Gernoth Committed by Steve Kondik
Browse files

PackageInstallerSession: use ftruncate if fallocate is ENOTSUP

When posix_fallocate is not supported (e.g. on ext3), fall
back to using ftruncate instead.

Change-Id: I8f7792ed3f43504df21e86cff79ed34f3ba795d7
parent 08c57fca
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -381,7 +381,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                if (stageDir != null && deltaBytes > 0) {
                if (stageDir != null && deltaBytes > 0) {
                    mPm.freeStorage(params.volumeUuid, deltaBytes);
                    mPm.freeStorage(params.volumeUuid, deltaBytes);
                }
                }
                try {
                    Libcore.os.posix_fallocate(targetFd, 0, lengthBytes);
                    Libcore.os.posix_fallocate(targetFd, 0, lengthBytes);
                } catch (ErrnoException e) {
                    if (e.errno == OsConstants.ENOTSUP) {
                        Libcore.os.ftruncate(targetFd, lengthBytes);
                    } else {
                        throw e.rethrowAsIOException();
                    }
                }
            }
            }


            if (offsetBytes > 0) {
            if (offsetBytes > 0) {