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

Commit a394f4a4 authored by Michael Gernoth's avatar Michael Gernoth Committed by Ethan Chen
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 dfbc0f2b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -364,7 +364,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                if (stageDir != null && deltaBytes > 0) {
                    mPm.freeStorage(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) {