1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/updater/automounter_gonk.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef AUTOMOUNTER_GONK_H__ 1.11 +#define AUTOMOUNTER_GONK_H__ 1.12 + 1.13 +typedef enum { 1.14 + ReadOnly, 1.15 + ReadWrite, 1.16 + Unknown 1.17 +} MountAccess; 1.18 + 1.19 +/** 1.20 + * This class will remount the /system partition as read-write in Gonk to allow 1.21 + * the updater write access. Upon destruction, /system will be remounted back to 1.22 + * read-only. If something causes /system to remain read-write, this class will 1.23 + * reboot the device and allow the system to mount as read-only. 1.24 + * 1.25 + * Code inspired from AOSP system/core/adb/remount_service.c 1.26 + */ 1.27 +class GonkAutoMounter 1.28 +{ 1.29 +public: 1.30 + GonkAutoMounter(); 1.31 + ~GonkAutoMounter(); 1.32 + 1.33 + const MountAccess GetAccess() 1.34 + { 1.35 + return mAccess; 1.36 + } 1.37 + 1.38 +private: 1.39 + bool RemountSystem(MountAccess access); 1.40 + bool ForceRemountReadOnly(); 1.41 + bool UpdateMountStatus(); 1.42 + bool ProcessMount(const char *mount); 1.43 + bool MountSystem(unsigned long flags); 1.44 + void Reboot(); 1.45 + 1.46 +private: 1.47 + char *mDevice; 1.48 + MountAccess mAccess; 1.49 +}; 1.50 + 1.51 +#endif // AUTOMOUNTER_GONK_H__