michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef AUTOMOUNTER_GONK_H__ michael@0: #define AUTOMOUNTER_GONK_H__ michael@0: michael@0: typedef enum { michael@0: ReadOnly, michael@0: ReadWrite, michael@0: Unknown michael@0: } MountAccess; michael@0: michael@0: /** michael@0: * This class will remount the /system partition as read-write in Gonk to allow michael@0: * the updater write access. Upon destruction, /system will be remounted back to michael@0: * read-only. If something causes /system to remain read-write, this class will michael@0: * reboot the device and allow the system to mount as read-only. michael@0: * michael@0: * Code inspired from AOSP system/core/adb/remount_service.c michael@0: */ michael@0: class GonkAutoMounter michael@0: { michael@0: public: michael@0: GonkAutoMounter(); michael@0: ~GonkAutoMounter(); michael@0: michael@0: const MountAccess GetAccess() michael@0: { michael@0: return mAccess; michael@0: } michael@0: michael@0: private: michael@0: bool RemountSystem(MountAccess access); michael@0: bool ForceRemountReadOnly(); michael@0: bool UpdateMountStatus(); michael@0: bool ProcessMount(const char *mount); michael@0: bool MountSystem(unsigned long flags); michael@0: void Reboot(); michael@0: michael@0: private: michael@0: char *mDevice; michael@0: MountAccess mAccess; michael@0: }; michael@0: michael@0: #endif // AUTOMOUNTER_GONK_H__