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

Unverified Commit 21457ffe authored by Michael Gernoth's avatar Michael Gernoth Committed by Michael Bestas
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 95ab519e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -462,7 +462,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                if (stageDir != null && deltaBytes > 0) {
                    mPm.freeStorage(params.volumeUuid, deltaBytes);
                }
                try {
                    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) {